From 67705589ac757baeccfeba12b938e815699465f8 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 17 Apr 2018 15:43:52 +0200 Subject: [PATCH] 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 --- src/tests/elementary/elm_suite.c | 52 +++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/src/tests/elementary/elm_suite.c b/src/tests/elementary/elm_suite.c index 30b7e3ae38..0bf03b3b7e 100644 --- a/src/tests/elementary/elm_suite.c +++ b/src/tests/elementary/elm_suite.c @@ -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; }