This way we can loop through them instead of having to add them manually.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
}
}
+extern const struct test_collection __start_test_collection_section,
+ __stop_test_collection_section;
+
+static void
+setup_tests(void)
+{
+ const struct test_collection *c;
+
+ for (c = &__start_test_collection_section;
+ c < &__stop_test_collection_section;
+ c++) {
+ c->setup();
+ }
+}
+
int
main(int argc, char **argv)
{
if (mode == LITEST_MODE_ERROR)
return EXIT_FAILURE;
- litest_setup_tests_udev();
- litest_setup_tests_path();
- litest_setup_tests_pointer();
- litest_setup_tests_touch();
- litest_setup_tests_log();
- litest_setup_tests_tablet();
- litest_setup_tests_pad();
- litest_setup_tests_touchpad();
- litest_setup_tests_touchpad_tap();
- litest_setup_tests_touchpad_buttons();
- litest_setup_tests_trackpoint();
- litest_setup_tests_trackball();
- litest_setup_tests_misc();
- litest_setup_tests_keyboard();
- litest_setup_tests_device();
- litest_setup_tests_gestures();
- litest_setup_tests_lid();
+ setup_tests();
if (mode == LITEST_MODE_LIST) {
litest_list_tests(&all_tests);
__VA_ARGS__ \
};
+struct test_collection {
+ const char *name;
+ void (*setup)(void);
+} __attribute__((aligned(16)));
+
+#define TEST_COLLECTION(name) \
+ static void (name##_setup)(void); \
+ static const struct test_collection _test_collection \
+ __attribute__ ((used)) \
+ __attribute__ ((section ("test_collection_section"))) = { \
+ #name, name##_setup \
+ }; \
+ static void (name##_setup)(void)
+
extern void litest_setup_tests_udev(void);
extern void litest_setup_tests_path(void);
extern void litest_setup_tests_pointer(void);
}
END_TEST
-void
-litest_setup_tests_device(void)
+TEST_COLLECTION(device)
{
struct range abs_range = { 0, ABS_MISC };
struct range abs_mt_range = { ABS_MT_SLOT + 1, ABS_CNT };
}
END_TEST
-void
-litest_setup_tests_gestures(void)
+TEST_COLLECTION(gestures)
{
/* N, NE, ... */
struct range cardinals = { 0, 8 };
}
END_TEST
-void
-litest_setup_tests_keyboard(void)
+TEST_COLLECTION(keyboard)
{
litest_add_no_device("keyboard:seat key count", keyboard_seat_key_count);
litest_add_no_device("keyboard:key counting", keyboard_ignore_no_pressed_release);
}
END_TEST
-void
-litest_setup_tests_log(void)
+TEST_COLLECTION(log)
{
struct range axes = { ABS_X, ABS_Y + 1};
}
END_TEST
-void
-litest_setup_tests_misc(void)
+TEST_COLLECTION(misc)
{
litest_add_no_device("events:conversion", event_conversion_device_notify);
litest_add_for_device("events:conversion", event_conversion_pointer, LITEST_MOUSE);
}
END_TEST
-void
-litest_setup_tests_pad(void)
+TEST_COLLECTION(tablet_pad)
{
litest_add("pad:cap", pad_cap, LITEST_TABLET_PAD, LITEST_ANY);
litest_add("pad:cap", pad_no_cap, LITEST_ANY, LITEST_TABLET_PAD);
}
END_TEST
-void
-litest_setup_tests_path(void)
+TEST_COLLECTION(path)
{
litest_add_no_device("path:create", path_create_NULL);
litest_add_no_device("path:create", path_create_invalid);
}
END_TEST
-void
-litest_setup_tests_pointer(void)
+TEST_COLLECTION(pointer)
{
struct range axis_range = {ABS_X, ABS_Y + 1};
struct range compass = {0, 7}; /* cardinal directions */
litest_assert_empty_queue(li);
}
END_TEST
-void
-litest_setup_tests_lid(void)
+
+TEST_COLLECTION(switch)
{
struct range switches = { LIBINPUT_SWITCH_LID,
LIBINPUT_SWITCH_TABLET_MODE + 1};
}
END_TEST
-void
-litest_setup_tests_tablet(void)
+TEST_COLLECTION(tablet)
{
struct range with_timeout = { 0, 2 };
}
END_TEST
-void
-litest_setup_tests_touch(void)
+TEST_COLLECTION(touch)
{
struct range axes = { ABS_X, ABS_Y + 1};
}
END_TEST
-void
-litest_setup_tests_touchpad_buttons(void)
+TEST_COLLECTION(touchpad_buttons)
{
litest_add("touchpad:clickfinger", touchpad_1fg_clickfinger, LITEST_CLICKPAD, LITEST_ANY);
litest_add("touchpad:clickfinger", touchpad_1fg_clickfinger_no_touch, LITEST_CLICKPAD, LITEST_ANY);
}
END_TEST
-void
-litest_setup_tests_touchpad_tap(void)
+TEST_COLLECTION(touchpad_tap)
{
struct range multitap_range = {3, 5};
struct range tap_map_range = { LIBINPUT_CONFIG_TAP_MAP_LRM,
}
END_TEST
-void
-litest_setup_tests_touchpad(void)
+TEST_COLLECTION(touchpad)
{
struct range axis_range = {ABS_X, ABS_Y + 1};
struct range twice = {0, 2 };
}
END_TEST
-void
-litest_setup_tests_trackball(void)
+TEST_COLLECTION(trackball)
{
litest_add("trackball:rotation", trackball_rotation_config_defaults, LITEST_TRACKBALL, LITEST_ANY);
litest_add("trackball:rotation", trackball_rotation_config_invalid_range, LITEST_TRACKBALL, LITEST_ANY);
}
END_TEST
-void
-litest_setup_tests_trackpoint(void)
+TEST_COLLECTION(trackpoint)
{
litest_add("trackpoint:middlebutton", trackpoint_middlebutton, LITEST_POINTINGSTICK, LITEST_ANY);
litest_add("trackpoint:middlebutton", trackpoint_middlebutton_noscroll, LITEST_POINTINGSTICK, LITEST_ANY);
}
END_TEST
-void
-litest_setup_tests_udev(void)
+TEST_COLLECTION(udev)
{
litest_add_no_device("udev:create", udev_create_NULL);
litest_add_no_device("udev:create", udev_create_seat0);