[PATCH libinput 1/6] test: move main() into litest

Peter Hutterer peter.hutterer at who-t.net
Tue May 19 20:24:57 PDT 2015


This allows us to filter things based on argv before setting up tests, etc.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 test/device.c     |  5 ++---
 test/keyboard.c   |  6 ++----
 test/litest.c     | 10 +++++++++-
 test/litest.h     |  2 +-
 test/log.c        |  5 ++---
 test/misc.c       |  5 ++---
 test/path.c       |  6 ++----
 test/pointer.c    |  5 ++---
 test/touch.c      |  6 ++----
 test/touchpad.c   |  5 ++---
 test/trackpoint.c |  5 ++---
 test/udev.c       |  6 ++----
 12 files changed, 30 insertions(+), 36 deletions(-)

diff --git a/test/device.c b/test/device.c
index 22569d2..c44efab 100644
--- a/test/device.c
+++ b/test/device.c
@@ -946,7 +946,8 @@ START_TEST(device_wheel_only)
 }
 END_TEST
 
-int main (int argc, char **argv)
+void
+litest_setup_tests(void)
 {
 	struct range abs_range = { 0, ABS_MISC };
 	struct range abs_mt_range = { ABS_MT_SLOT + 1, ABS_CNT };
@@ -987,6 +988,4 @@ int main (int argc, char **argv)
 	litest_add_no_device("device:invalid devices", abs_mt_device_missing_res);
 
 	litest_add("device:wheel", device_wheel_only, LITEST_WHEEL, LITEST_RELATIVE|LITEST_ABSOLUTE);
-
-	return litest_run(argc, argv);
 }
diff --git a/test/keyboard.c b/test/keyboard.c
index 03d62dd..1c8092b 100644
--- a/test/keyboard.c
+++ b/test/keyboard.c
@@ -310,14 +310,12 @@ START_TEST(keyboard_keys_bad_device)
 }
 END_TEST
 
-int
-main(int argc, char **argv)
+void
+litest_setup_tests(void)
 {
 	litest_add_no_device("keyboard:seat key count", keyboard_seat_key_count);
 	litest_add_no_device("keyboard:key counting", keyboard_ignore_no_pressed_release);
 	litest_add_no_device("keyboard:key counting", keyboard_key_auto_release);
 	litest_add("keyboard:keys", keyboard_has_key, LITEST_KEYS, LITEST_ANY);
 	litest_add("keyboard:keys", keyboard_keys_bad_device, LITEST_ANY, LITEST_ANY);
-
-	return litest_run(argc, argv);
 }
diff --git a/test/litest.c b/test/litest.c
index f637d4e..c0b515b 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -462,7 +462,7 @@ static const struct option opts[] = {
 	{ 0, 0, 0, 0}
 };
 
-int
+static int
 litest_run(int argc, char **argv)
 {
 	struct suite *s, *snext;
@@ -1886,3 +1886,11 @@ litest_semi_mt_touch_up(struct litest_device *d,
 
 	litest_event(d, EV_SYN, SYN_REPORT, 0);
 }
+
+int
+main(int argc, char **argv)
+{
+	litest_setup_tests();
+
+	return litest_run(argc, argv);
+}
diff --git a/test/litest.h b/test/litest.h
index 38d3c1b..b6aaa6f 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -130,7 +130,7 @@ void litest_add_ranged_no_device(const char *name,
 				 void *func,
 				 const struct range *range);
 
-int litest_run(int argc, char **argv);
+extern void litest_setup_tests(void);
 struct litest_device * litest_create_device(enum litest_device_type which);
 struct litest_device * litest_add_device(struct libinput *libinput,
 					 enum litest_device_type which);
diff --git a/test/log.c b/test/log.c
index 4eb554d..504f4c8 100644
--- a/test/log.c
+++ b/test/log.c
@@ -139,12 +139,11 @@ START_TEST(log_priority)
 }
 END_TEST
 
-int main (int argc, char **argv)
+void
+litest_setup_tests(void)
 {
 	litest_add_no_device("log:defaults", log_default_priority);
 	litest_add_no_device("log:logging", log_handler_invoked);
 	litest_add_no_device("log:logging", log_handler_NULL);
 	litest_add_no_device("log:logging", log_priority);
-
-	return litest_run(argc, argv);
 }
diff --git a/test/misc.c b/test/misc.c
index e9d5462..ec6d820 100644
--- a/test/misc.c
+++ b/test/misc.c
@@ -583,7 +583,8 @@ START_TEST(trackpoint_accel_parser)
 }
 END_TEST
 
-int main (int argc, char **argv)
+void
+litest_setup_tests(void)
 {
 	litest_add_no_device("events:conversion", event_conversion_device_notify);
 	litest_add_for_device("events:conversion", event_conversion_pointer, LITEST_MOUSE);
@@ -600,6 +601,4 @@ int main (int argc, char **argv)
 	litest_add_no_device("misc:dpi parser", dpi_parser);
 	litest_add_no_device("misc:wheel click parser", wheel_click_parser);
 	litest_add_no_device("misc:trackpoint accel parser", trackpoint_accel_parser);
-
-	return litest_run(argc, argv);
 }
diff --git a/test/path.c b/test/path.c
index df649da..c28c6ff 100644
--- a/test/path.c
+++ b/test/path.c
@@ -874,8 +874,8 @@ START_TEST(path_seat_recycle)
 }
 END_TEST
 
-int
-main(int argc, char **argv)
+void
+litest_setup_tests(void)
 {
 	litest_add_no_device("path:create", path_create_NULL);
 	litest_add_no_device("path:create", path_create_invalid);
@@ -896,6 +896,4 @@ main(int argc, char **argv)
 	litest_add_for_device("path:device events", path_remove_device, LITEST_SYNAPTICS_CLICKPAD);
 	litest_add_for_device("path:device events", path_double_remove_device, LITEST_SYNAPTICS_CLICKPAD);
 	litest_add_no_device("path:seat", path_seat_recycle);
-
-	return litest_run(argc, argv);
 }
diff --git a/test/pointer.c b/test/pointer.c
index 9eebedd..149277d 100644
--- a/test/pointer.c
+++ b/test/pointer.c
@@ -1316,7 +1316,8 @@ START_TEST(middlebutton_default_disabled)
 }
 END_TEST
 
-int main (int argc, char **argv)
+void
+litest_setup_tests(void)
 {
 	struct range axis_range = {ABS_X, ABS_Y + 1};
 
@@ -1358,6 +1359,4 @@ int main (int argc, char **argv)
 	litest_add("pointer:middlebutton", middlebutton_default_disabled, LITEST_ANY, LITEST_BUTTON);
 
 	litest_add_ranged("pointer:state", pointer_absolute_initial_state, LITEST_ABSOLUTE, LITEST_ANY, &axis_range);
-
-	return litest_run(argc, argv);
 }
diff --git a/test/touch.c b/test/touch.c
index 828c6ed..2c07e09 100644
--- a/test/touch.c
+++ b/test/touch.c
@@ -650,8 +650,8 @@ START_TEST(touch_initial_state)
 }
 END_TEST
 
-int
-main(int argc, char **argv)
+void
+litest_setup_tests(void)
 {
 	struct range axes = { ABS_X, ABS_Y + 1};
 
@@ -676,6 +676,4 @@ main(int argc, char **argv)
 	litest_add("touch:protocol a", touch_protocol_a_2fg_touch, LITEST_PROTOCOL_A, LITEST_ANY);
 
 	litest_add_ranged("touch:state", touch_initial_state, LITEST_TOUCH, LITEST_PROTOCOL_A, &axes);
-
-	return litest_run(argc, argv);
 }
diff --git a/test/touchpad.c b/test/touchpad.c
index 3bdcc2b..0f9c8b4 100644
--- a/test/touchpad.c
+++ b/test/touchpad.c
@@ -4589,7 +4589,8 @@ START_TEST(touchpad_initial_state)
 }
 END_TEST
 
-int main(int argc, char **argv)
+void
+litest_setup_tests(void)
 {
 	struct range multitap_range = {3, 8};
 	struct range axis_range = {ABS_X, ABS_Y + 1};
@@ -4736,6 +4737,4 @@ int main(int argc, char **argv)
 	litest_add_for_device("touchpad:trackpoint", touchpad_trackpoint_no_trackpoint, LITEST_SYNAPTICS_TRACKPOINT_BUTTONS);
 
 	litest_add_ranged("touchpad:state", touchpad_initial_state, LITEST_TOUCHPAD, LITEST_ANY, &axis_range);
-
-	return litest_run(argc, argv);
 }
diff --git a/test/trackpoint.c b/test/trackpoint.c
index ac6173e..9fcce6f 100644
--- a/test/trackpoint.c
+++ b/test/trackpoint.c
@@ -130,12 +130,11 @@ START_TEST(trackpoint_scroll_source)
 }
 END_TEST
 
-int main(int argc, char **argv)
+void
+litest_setup_tests(void)
 {
 	litest_add("trackpoint:middlebutton", trackpoint_middlebutton, LITEST_POINTINGSTICK, LITEST_ANY);
 	litest_add("trackpoint:middlebutton", trackpoint_middlebutton_noscroll, LITEST_POINTINGSTICK, LITEST_ANY);
 	litest_add("trackpoint:scroll", trackpoint_scroll, LITEST_POINTINGSTICK, LITEST_ANY);
 	litest_add("trackpoint:scroll", trackpoint_scroll_source, LITEST_POINTINGSTICK, LITEST_ANY);
-
-	return litest_run(argc, argv);
 }
diff --git a/test/udev.c b/test/udev.c
index c351bed..4ec956b 100644
--- a/test/udev.c
+++ b/test/udev.c
@@ -502,8 +502,8 @@ START_TEST(udev_seat_recycle)
 }
 END_TEST
 
-int
-main(int argc, char **argv)
+void
+litest_setup_tests(void)
 {
 	litest_add_no_device("udev:create", udev_create_NULL);
 	litest_add_no_device("udev:create", udev_create_seat0);
@@ -518,6 +518,4 @@ main(int argc, char **argv)
 	litest_add_for_device("udev:suspend", udev_suspend_resume, LITEST_SYNAPTICS_CLICKPAD);
 	litest_add_for_device("udev:device events", udev_device_sysname, LITEST_SYNAPTICS_CLICKPAD);
 	litest_add_for_device("udev:seat", udev_seat_recycle, LITEST_SYNAPTICS_CLICKPAD);
-
-	return litest_run(argc, argv);
 }
-- 
2.3.5



More information about the wayland-devel mailing list