mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-20 11:30:06 +01:00
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: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1065>
This commit is contained in:
parent
dba296d290
commit
0135b0b41c
4 changed files with 21 additions and 50 deletions
|
|
@ -559,7 +559,7 @@ vm-tap:
|
||||||
extends:
|
extends:
|
||||||
- .fedora:40@test-suite-vm
|
- .fedora:40@test-suite-vm
|
||||||
variables:
|
variables:
|
||||||
SUITE_NAMES: 'touchpad-tap'
|
SUITE_NAMES: 'touchpad_tap'
|
||||||
|
|
||||||
vm-tap-no-libwacom:
|
vm-tap-no-libwacom:
|
||||||
extends:
|
extends:
|
||||||
|
|
@ -572,7 +572,7 @@ vm-touchpad-buttons:
|
||||||
extends:
|
extends:
|
||||||
- .fedora:40@test-suite-vm
|
- .fedora:40@test-suite-vm
|
||||||
variables:
|
variables:
|
||||||
SUITE_NAMES: 'touchpad-buttons'
|
SUITE_NAMES: 'touchpad_buttons'
|
||||||
|
|
||||||
vm-touchpad-buttons-no-libwacom:
|
vm-touchpad-buttons-no-libwacom:
|
||||||
extends:
|
extends:
|
||||||
|
|
@ -895,8 +895,8 @@ check-test-suites:
|
||||||
- |
|
- |
|
||||||
cat <<EOF > ci-testsuites ;
|
cat <<EOF > ci-testsuites ;
|
||||||
libinput-test-suite-touchpad
|
libinput-test-suite-touchpad
|
||||||
libinput-test-suite-touchpad-tap
|
libinput-test-suite-touchpad_tap
|
||||||
libinput-test-suite-touchpad-buttons
|
libinput-test-suite-touchpad_buttons
|
||||||
libinput-test-suite-tablet
|
libinput-test-suite-tablet
|
||||||
libinput-test-suite-gestures
|
libinput-test-suite-gestures
|
||||||
libinput-test-suite-device
|
libinput-test-suite-device
|
||||||
|
|
|
||||||
|
|
@ -174,10 +174,10 @@ test_suites:
|
||||||
- touchpad
|
- touchpad
|
||||||
- name: tap
|
- name: tap
|
||||||
suites:
|
suites:
|
||||||
- touchpad-tap
|
- touchpad_tap
|
||||||
- name: touchpad-buttons
|
- name: touchpad-buttons
|
||||||
suites:
|
suites:
|
||||||
- touchpad-buttons
|
- touchpad_buttons
|
||||||
- name: tablet
|
- name: tablet
|
||||||
suites:
|
suites:
|
||||||
- tablet
|
- tablet
|
||||||
|
|
|
||||||
|
|
@ -938,6 +938,7 @@ if get_option('tests')
|
||||||
foreach testfile : tests_sources
|
foreach testfile : tests_sources
|
||||||
tfile = testfile.split('test/test-')[1]
|
tfile = testfile.split('test/test-')[1]
|
||||||
group = tfile.split('.c')[0]
|
group = tfile.split('.c')[0]
|
||||||
|
group = group.replace('-', '_')
|
||||||
test('libinput-test-suite-@0@'.format(group),
|
test('libinput-test-suite-@0@'.format(group),
|
||||||
libinput_test_runner,
|
libinput_test_runner,
|
||||||
suite : ['all', 'valgrind', 'root', 'hardware'],
|
suite : ['all', 'valgrind', 'root', 'hardware'],
|
||||||
|
|
|
||||||
|
|
@ -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
|
static struct list created_files_list; /* list of all files to remove at the end
|
||||||
of the test run */
|
of the test run */
|
||||||
|
static struct suite *current_suite = NULL;
|
||||||
|
|
||||||
static void litest_init_udev_rules(struct list *created_files_list);
|
static void litest_init_udev_rules(struct list *created_files_list);
|
||||||
static void litest_remove_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);
|
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
|
static void
|
||||||
litest_add_tcase(const char *filename,
|
litest_add_tcase(const char *filename,
|
||||||
const char *funcname,
|
const char *funcname,
|
||||||
|
|
@ -540,8 +508,6 @@ litest_add_tcase(const char *filename,
|
||||||
int64_t excluded,
|
int64_t excluded,
|
||||||
const struct range *range)
|
const struct range *range)
|
||||||
{
|
{
|
||||||
char suite_name[65];
|
|
||||||
struct suite *suite;
|
|
||||||
bool added = false;
|
bool added = false;
|
||||||
|
|
||||||
litest_assert(required >= LITEST_DEVICELESS);
|
litest_assert(required >= LITEST_DEVICELESS);
|
||||||
|
|
@ -551,13 +517,11 @@ litest_add_tcase(const char *filename,
|
||||||
fnmatch(filter_test, funcname, 0) != 0)
|
fnmatch(filter_test, funcname, 0) != 0)
|
||||||
return;
|
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;
|
return;
|
||||||
|
|
||||||
suite = get_suite(suite_name);
|
|
||||||
|
|
||||||
if (required == LITEST_DEVICELESS &&
|
if (required == LITEST_DEVICELESS &&
|
||||||
excluded == LITEST_DEVICELESS) {
|
excluded == LITEST_DEVICELESS) {
|
||||||
litest_add_tcase_deviceless(suite, func, funcname, range);
|
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,
|
enum litest_device_type type,
|
||||||
const struct range *range)
|
const struct range *range)
|
||||||
{
|
{
|
||||||
struct suite *s;
|
|
||||||
struct litest_test_device *dev;
|
struct litest_test_device *dev;
|
||||||
bool device_filtered = false;
|
bool device_filtered = false;
|
||||||
char suite_name[64];
|
|
||||||
|
|
||||||
litest_assert(type < LITEST_NO_DEVICE);
|
litest_assert(type < LITEST_NO_DEVICE);
|
||||||
|
|
||||||
|
|
@ -702,12 +664,11 @@ _litest_add_ranged_for_device(const char *filename,
|
||||||
fnmatch(filter_test, funcname, 0) != 0)
|
fnmatch(filter_test, funcname, 0) != 0)
|
||||||
return;
|
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;
|
return;
|
||||||
|
|
||||||
s = get_suite(suite_name);
|
|
||||||
list_for_each(dev, &devices, node) {
|
list_for_each(dev, &devices, node) {
|
||||||
if (filter_device &&
|
if (filter_device &&
|
||||||
fnmatch(filter_device, dev->shortname, 0) != 0) {
|
fnmatch(filter_device, dev->shortname, 0) != 0) {
|
||||||
|
|
@ -4927,7 +4888,16 @@ setup_tests(void)
|
||||||
for (c = &__start_test_collection_section;
|
for (c = &__start_test_collection_section;
|
||||||
c < &__stop_test_collection_section;
|
c < &__stop_test_collection_section;
|
||||||
c++) {
|
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();
|
c->setup();
|
||||||
|
current_suite = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue