From: Peter Hutterer Date: Thu, 17 Oct 2024 09:55:25 +0000 (+1000) Subject: test: detach the suite handling from the file names X-Git-Tag: 1.27.0~72 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0135b0b41c841ee62be94bf6f9f80c606af9e75c;p=platform%2Fupstream%2Flibinput.git test: detach the suite handling from the file names Instead of extracting the suite name from the test's file name use the current suite that is being parsed. This way we pave the way for multiple suites in the same file. This uses a global because otherwise we'd have to redo all the litest_add() functions but it does the job here. Part-of: --- diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 18dc1900..5e90da3a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -559,7 +559,7 @@ vm-tap: extends: - .fedora:40@test-suite-vm variables: - SUITE_NAMES: 'touchpad-tap' + SUITE_NAMES: 'touchpad_tap' vm-tap-no-libwacom: extends: @@ -572,7 +572,7 @@ vm-touchpad-buttons: extends: - .fedora:40@test-suite-vm variables: - SUITE_NAMES: 'touchpad-buttons' + SUITE_NAMES: 'touchpad_buttons' vm-touchpad-buttons-no-libwacom: extends: @@ -895,8 +895,8 @@ check-test-suites: - | cat < ci-testsuites ; libinput-test-suite-touchpad - libinput-test-suite-touchpad-tap - libinput-test-suite-touchpad-buttons + libinput-test-suite-touchpad_tap + libinput-test-suite-touchpad_buttons libinput-test-suite-tablet libinput-test-suite-gestures libinput-test-suite-device diff --git a/.gitlab-ci/config.yml b/.gitlab-ci/config.yml index 004f503b..f8cbc374 100644 --- a/.gitlab-ci/config.yml +++ b/.gitlab-ci/config.yml @@ -174,10 +174,10 @@ test_suites: - touchpad - name: tap suites: - - touchpad-tap + - touchpad_tap - name: touchpad-buttons suites: - - touchpad-buttons + - touchpad_buttons - name: tablet suites: - tablet diff --git a/meson.build b/meson.build index dccc32c2..23947b4e 100644 --- a/meson.build +++ b/meson.build @@ -938,6 +938,7 @@ if get_option('tests') foreach testfile : tests_sources tfile = testfile.split('test/test-')[1] group = tfile.split('.c')[0] + group = group.replace('-', '_') test('libinput-test-suite-@0@'.format(group), libinput_test_runner, suite : ['all', 'valgrind', 'root', 'hardware'], diff --git a/test/litest.c b/test/litest.c index 958ae8db..bb649569 100644 --- a/test/litest.c +++ b/test/litest.c @@ -108,6 +108,7 @@ created_file_unlink(struct created_file *f) static struct list created_files_list; /* list of all files to remove at the end of the test run */ +static struct suite *current_suite = NULL; static void litest_init_udev_rules(struct list *created_files_list); static void litest_remove_udev_rules(struct list *created_files_list); @@ -499,39 +500,6 @@ litest_add_tcase_deviceless(struct suite *suite, list_insert(&suite->tests, &t->node); } -static struct suite * -get_suite(const char *name) -{ - struct suite *s; - - list_for_each(s, &all_test_suites, node) { - if (streq(s->name, name)) - return s; - } - - s = zalloc(sizeof(*s)); - s->name = safe_strdup(name); - - list_init(&s->tests); - list_insert(&all_test_suites, &s->node); - - return s; -} - -static void -create_suite_name(const char *filename, char suitename[64]) -{ - char *trunk = trunkname(filename); - char *p = trunk; - - /* strip the test- prefix */ - if (strstartswith(trunk, "test-")) - p += 5; - - snprintf(suitename, 64, "%s", p); - free(trunk); -} - static void litest_add_tcase(const char *filename, const char *funcname, @@ -540,8 +508,6 @@ litest_add_tcase(const char *filename, int64_t excluded, const struct range *range) { - char suite_name[65]; - struct suite *suite; bool added = false; litest_assert(required >= LITEST_DEVICELESS); @@ -551,13 +517,11 @@ litest_add_tcase(const char *filename, fnmatch(filter_test, funcname, 0) != 0) return; - create_suite_name(filename, suite_name); + struct suite *suite = current_suite; - if (filter_group && fnmatch(filter_group, suite_name, 0) != 0) + if (filter_group && fnmatch(filter_group, suite->name, 0) != 0) return; - suite = get_suite(suite_name); - if (required == LITEST_DEVICELESS && excluded == LITEST_DEVICELESS) { litest_add_tcase_deviceless(suite, func, funcname, range); @@ -691,10 +655,8 @@ _litest_add_ranged_for_device(const char *filename, enum litest_device_type type, const struct range *range) { - struct suite *s; struct litest_test_device *dev; bool device_filtered = false; - char suite_name[64]; litest_assert(type < LITEST_NO_DEVICE); @@ -702,12 +664,11 @@ _litest_add_ranged_for_device(const char *filename, fnmatch(filter_test, funcname, 0) != 0) return; - create_suite_name(filename, suite_name); + struct suite *s = current_suite; - if (filter_group && fnmatch(filter_group, suite_name, 0) != 0) + if (filter_group && fnmatch(filter_group, s->name, 0) != 0) return; - s = get_suite(suite_name); list_for_each(dev, &devices, node) { if (filter_device && fnmatch(filter_device, dev->shortname, 0) != 0) { @@ -4927,7 +4888,16 @@ setup_tests(void) for (c = &__start_test_collection_section; c < &__stop_test_collection_section; c++) { + struct suite *s; + s = zalloc(sizeof(*s)); + s->name = safe_strdup(c->name); + + list_init(&s->tests); + list_insert(&all_test_suites, &s->node); + + current_suite = s; c->setup(); + current_suite = NULL; } }