[PATCH libinput] test: move all the _setup() functions into a special section
Peter Hutterer
peter.hutterer at who-t.net
Wed Mar 21 05:23:09 UTC 2018
This way we can loop through them instead of having to add them manually.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
test/litest.c | 25 ++++++++-----------------
test/litest.h | 14 ++++++++++++++
test/test-device.c | 3 +--
test/test-gestures.c | 3 +--
test/test-keyboard.c | 3 +--
test/test-log.c | 3 +--
test/test-misc.c | 3 +--
test/test-pad.c | 3 +--
test/test-path.c | 3 +--
test/test-pointer.c | 3 +--
test/test-switch.c | 4 ++--
test/test-tablet.c | 3 +--
test/test-touch.c | 3 +--
test/test-touchpad-buttons.c | 3 +--
test/test-touchpad-tap.c | 3 +--
test/test-touchpad.c | 3 +--
test/test-trackball.c | 3 +--
test/test-trackpoint.c | 3 +--
test/test-udev.c | 3 +--
19 files changed, 40 insertions(+), 51 deletions(-)
diff --git a/test/litest.c b/test/litest.c
index 7f4bd77a..f3d4cfee 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -3700,11 +3700,14 @@ litest_init_test_devices(void)
}
}
+extern const struct test_collection __start_test_collection_section, __stop_test_collection_section;
+
int
main(int argc, char **argv)
{
const struct rlimit corelimit = { 0, 0 };
enum litest_mode mode;
+ const struct test_collection *c;
if (getuid() != 0) {
fprintf(stderr,
@@ -3735,23 +3738,11 @@ 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();
+ for (c = &__start_test_collection_section;
+ c < &__stop_test_collection_section;
+ c++) {
+ c->setup();
+ }
if (mode == LITEST_MODE_LIST) {
litest_list_tests(&all_tests);
diff --git a/test/litest.h b/test/litest.h
index df725f87..05ea2d7f 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -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);
diff --git a/test/test-device.c b/test/test-device.c
index 769ecaf4..3a26c7d9 100644
--- a/test/test-device.c
+++ b/test/test-device.c
@@ -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 };
diff --git a/test/test-gestures.c b/test/test-gestures.c
index 1d0a13c5..db0e6731 100644
--- a/test/test-gestures.c
+++ b/test/test-gestures.c
@@ -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 };
diff --git a/test/test-keyboard.c b/test/test-keyboard.c
index db836381..4b6b5315 100644
--- a/test/test-keyboard.c
+++ b/test/test-keyboard.c
@@ -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);
diff --git a/test/test-log.c b/test/test-log.c
index 02ff0185..1dac01b6 100644
--- a/test/test-log.c
+++ b/test/test-log.c
@@ -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};
diff --git a/test/test-misc.c b/test/test-misc.c
index 94cbfcc1..c62cd03e 100644
--- a/test/test-misc.c
+++ b/test/test-misc.c
@@ -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);
diff --git a/test/test-pad.c b/test/test-pad.c
index cfa28b17..eaa2bfaa 100644
--- a/test/test-pad.c
+++ b/test/test-pad.c
@@ -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);
diff --git a/test/test-path.c b/test/test-path.c
index c28c6e38..f7c4de6f 100644
--- a/test/test-path.c
+++ b/test/test-path.c
@@ -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);
diff --git a/test/test-pointer.c b/test/test-pointer.c
index a4dcdaa3..73717aa2 100644
--- a/test/test-pointer.c
+++ b/test/test-pointer.c
@@ -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 */
diff --git a/test/test-switch.c b/test/test-switch.c
index 65e85102..74cb43e0 100644
--- a/test/test-switch.c
+++ b/test/test-switch.c
@@ -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};
diff --git a/test/test-tablet.c b/test/test-tablet.c
index a5a58bc9..1de82c19 100644
--- a/test/test-tablet.c
+++ b/test/test-tablet.c
@@ -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 };
diff --git a/test/test-touch.c b/test/test-touch.c
index b3a6d0a0..53ec11f0 100644
--- a/test/test-touch.c
+++ b/test/test-touch.c
@@ -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};
diff --git a/test/test-touchpad-buttons.c b/test/test-touchpad-buttons.c
index 9f38e833..7cc0b1d7 100644
--- a/test/test-touchpad-buttons.c
+++ b/test/test-touchpad-buttons.c
@@ -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);
diff --git a/test/test-touchpad-tap.c b/test/test-touchpad-tap.c
index 68b4dc06..b81decd1 100644
--- a/test/test-touchpad-tap.c
+++ b/test/test-touchpad-tap.c
@@ -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,
diff --git a/test/test-touchpad.c b/test/test-touchpad.c
index 4759bfb6..8c4c28d8 100644
--- a/test/test-touchpad.c
+++ b/test/test-touchpad.c
@@ -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 };
diff --git a/test/test-trackball.c b/test/test-trackball.c
index 28639ad0..55025850 100644
--- a/test/test-trackball.c
+++ b/test/test-trackball.c
@@ -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);
diff --git a/test/test-trackpoint.c b/test/test-trackpoint.c
index 46a66893..a924f5e2 100644
--- a/test/test-trackpoint.c
+++ b/test/test-trackpoint.c
@@ -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);
diff --git a/test/test-udev.c b/test/test-udev.c
index b3922824..6a6e6763 100644
--- a/test/test-udev.c
+++ b/test/test-udev.c
@@ -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);
--
2.14.3
More information about the wayland-devel
mailing list