tests: preload elm_init and default theme groups in elm_suite

Summary:
opening the default theme file can take up to 0.2s in worst case during
a test

ref T6864
Depends on D5914

Reviewers: stefan_schmidt

Reviewed By: stefan_schmidt

Subscribers: cedric

Maniphest Tasks: T6864

Differential Revision: https://phab.enlightenment.org/D5915
This commit is contained in:
Mike Blumenkrantz 2018-04-17 15:43:52 +02:00 committed by Stefan Schmidt
parent 22cb35c9a4
commit 67705589ac
1 changed files with 47 additions and 5 deletions

View File

@ -6,6 +6,9 @@
#include "elm_suite.h"
#include "../efl_check.h"
static int main_pid = -1;
static Eina_Bool did_shutdown;
static const Efl_Test_Case etc[] = {
{ "elm_config", elm_test_config },
{ "elm_check", elm_test_check },
@ -93,6 +96,24 @@ SUITE_INIT(elm)
ck_assert_int_eq(elm_init(1, args), 1);
}
SUITE_INIT(elm2)
{
char *args[] = { "exe" };
if (getpid() != main_pid)
{
ecore_fork_reset();
return;
}
if (!did_shutdown)
{
/* if running un-forked then remove cached init */
ck_assert_int_eq(elm_shutdown(), 0);
did_shutdown = 1;
}
ck_assert_int_eq(elm_init(1, args), 1);
}
SUITE_SHUTDOWN(elm)
{
ck_assert_int_eq(elm_shutdown(), 0);
@ -123,13 +144,34 @@ main(int argc, char **argv)
if (eina_streq(getenv("ELM_ENGINE"), "buffer"))
putenv("TESTS_GL_DISABLED=1");
main_pid = getpid();
failed_count = _efl_suite_build_and_run(argc - 1, (const char **)argv + 1,
"Elementary_Init", etc_init, SUITE_INIT_FN(elm), SUITE_SHUTDOWN_FN(elm));
if (!failed_count)
{
failed_count += _efl_suite_build_and_run(argc - 1, (const char **)argv + 1,
"Elementary", etc, SUITE_INIT_FN(elm), SUITE_SHUTDOWN_FN(elm));
}
failed_count += !elm_init(1, (char*[]){"exe"});
EINA_SAFETY_ON_TRUE_RETURN_VAL(failed_count, 255);
/* preload default theme */
failed_count += !elm_theme_group_path_find(NULL, "elm/button/base/default");
EINA_SAFETY_ON_TRUE_RETURN_VAL(failed_count, 255);
failed_count += !elm_theme_group_path_find(NULL, "elm/win/base/default");
EINA_SAFETY_ON_TRUE_RETURN_VAL(failed_count, 255);
/* none of these will be found in the default theme,
* but all are "fetched" hundreds of times
* T6865
*/
elm_theme_group_path_find(NULL, "elm/cursor/top_side/default");
elm_theme_group_path_find(NULL, "elm/cursor/bottom_side/default");
elm_theme_group_path_find(NULL, "elm/cursor/top_left_corner/default");
elm_theme_group_path_find(NULL, "elm/cursor/bottom_left_corner/default");
elm_theme_group_path_find(NULL, "elm/cursor/top_right_corner/default");
elm_theme_group_path_find(NULL, "elm/cursor/bottom_right_corner/default");
elm_theme_group_path_find(NULL, "elm/colorselector/item/color/default");
failed_count += _efl_suite_build_and_run(argc - 1, (const char **)argv + 1,
"Elementary", etc, SUITE_INIT_FN(elm2), SUITE_SHUTDOWN_FN(elm));
return (failed_count == 0) ? 0 : 255;
}