test: move all the _setup() functions into a special section
authorPeter Hutterer <peter.hutterer@who-t.net>
Wed, 21 Mar 2018 02:54:10 +0000 (12:54 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Fri, 23 Mar 2018 00:17:52 +0000 (10:17 +1000)
This way we can loop through them instead of having to add them manually.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
19 files changed:
test/litest.c
test/litest.h
test/test-device.c
test/test-gestures.c
test/test-keyboard.c
test/test-log.c
test/test-misc.c
test/test-pad.c
test/test-path.c
test/test-pointer.c
test/test-switch.c
test/test-tablet.c
test/test-touch.c
test/test-touchpad-buttons.c
test/test-touchpad-tap.c
test/test-touchpad.c
test/test-trackball.c
test/test-trackpoint.c
test/test-udev.c

index 7f4bd77..d0d03f3 100644 (file)
@@ -3700,6 +3700,21 @@ litest_init_test_devices(void)
        }
 }
 
+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)
 {
@@ -3735,23 +3750,7 @@ 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);
index df725f8..05ea2d7 100644 (file)
@@ -60,6 +60,20 @@ struct test_device {
                __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);
index 769ecaf..3a26c7d 100644 (file)
@@ -1577,8 +1577,7 @@ START_TEST(device_seat_phys_name)
 }
 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 };
index 1d0a13c..db0e673 100644 (file)
@@ -1057,8 +1057,7 @@ START_TEST(gestures_3fg_buttonarea_scroll_btntool)
 }
 END_TEST
 
-void
-litest_setup_tests_gestures(void)
+TEST_COLLECTION(gestures)
 {
        /* N, NE, ... */
        struct range cardinals = { 0, 8 };
index db83638..4b6b531 100644 (file)
@@ -476,8 +476,7 @@ START_TEST(keyboard_no_scroll)
 }
 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);
index 02ff018..1dac01b 100644 (file)
@@ -200,8 +200,7 @@ START_TEST(log_axisrange_warning)
 }
 END_TEST
 
-void
-litest_setup_tests_log(void)
+TEST_COLLECTION(log)
 {
        struct range axes = { ABS_X, ABS_Y + 1};
 
index 94cbfcc..c62cd03 100644 (file)
@@ -1492,8 +1492,7 @@ START_TEST(timer_flush)
 }
 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);
index cfa28b1..eaa2bfa 100644 (file)
@@ -917,8 +917,7 @@ START_TEST(pad_mode_group_has_no_toggle)
 }
 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);
index c28c6e3..f7c4de6 100644 (file)
@@ -981,8 +981,7 @@ START_TEST(path_ignore_device)
 }
 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);
index a4dcdaa..73717aa 100644 (file)
@@ -2534,8 +2534,7 @@ START_TEST(debounce_spurious_switch_to_otherbutton)
 }
 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 */
index 65e8510..74cb43e 100644 (file)
@@ -1040,8 +1040,8 @@ START_TEST(dock_toggle)
        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};
index a5a58bc..1de82c1 100644 (file)
@@ -4682,8 +4682,7 @@ START_TEST(huion_static_btn_tool_pen_disable_quirk_on_prox_out)
 }
 END_TEST
 
-void
-litest_setup_tests_tablet(void)
+TEST_COLLECTION(tablet)
 {
        struct range with_timeout = { 0, 2 };
 
index b3a6d0a..53ec11f 100644 (file)
@@ -945,8 +945,7 @@ START_TEST(touch_release_on_unplug)
 }
 END_TEST
 
-void
-litest_setup_tests_touch(void)
+TEST_COLLECTION(touch)
 {
        struct range axes = { ABS_X, ABS_Y + 1};
 
index 9f38e83..7cc0b1d 100644 (file)
@@ -1978,8 +1978,7 @@ START_TEST(clickpad_middleemulation_click_disable_while_down)
 }
 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);
index 68b4dc0..b81decd 100644 (file)
@@ -3383,8 +3383,7 @@ START_TEST(touchpad_tap_palm_dwt_tap)
 }
 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,
index 4759bfb..8c4c28d 100644 (file)
@@ -5758,8 +5758,7 @@ START_TEST(touchpad_speed_ignore_finger_edgescroll)
 }
 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 };
index 28639ad..5502585 100644 (file)
@@ -259,8 +259,7 @@ START_TEST(trackball_rotation_accel)
 }
 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);
index 46a6689..a924f5e 100644 (file)
@@ -379,8 +379,7 @@ START_TEST(trackpoint_palmdetect_require_min_events)
 }
 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);
index b392282..6a6e676 100644 (file)
@@ -646,8 +646,7 @@ START_TEST(udev_ignore_device)
 }
 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);