[PATCH libinput] test: switch to a TEST_DEVICE macro for all the litest test devices

Peter Hutterer peter.hutterer at who-t.net
Thu Sep 21 05:08:05 UTC 2017


The test device initialization code was a bit of duplicated boilerplate and
required adding a reference to the devices to the 'devices' list in litest.c.
Automate this with a new TEST_DEVICE macro that adds the devices to a custom
section in the binary, then loops throught that section to get the device out.

This reduces the boilerplate for each test device to just the TEST_MACRO and
the LITEST_foo device enum entry. It also now automates the shortname of the
device.

The device's shortname was standardised in this approach as well, lowercase
and dashes only.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
Interesting bits are the last two hunks, the rest is just the same
search/replace all over in the test devices.

Idea stolen from the weston tests.

 meson.build                                     |   9 +-
 test/litest-device-acer-hawaii-keyboard.c       |  12 +-
 test/litest-device-acer-hawaii-touchpad.c       |  13 +-
 test/litest-device-alps-dualpoint.c             |  13 +-
 test/litest-device-alps-semi-mt.c               |  13 +-
 test/litest-device-anker-mouse-kbd.c            |  12 +-
 test/litest-device-apple-appletouch.c           |  13 +-
 test/litest-device-apple-internal-keyboard.c    |  12 +-
 test/litest-device-apple-magicmouse.c           |  12 +-
 test/litest-device-asus-rog-gladius.c           |  12 +-
 test/litest-device-atmel-hover.c                |  13 +-
 test/litest-device-bcm5974.c                    |  12 +-
 test/litest-device-calibrated-touchscreen.c     |  13 +-
 test/litest-device-cyborg-rat-5.c               |  12 +-
 test/litest-device-elantech-touchpad.c          |  13 +-
 test/litest-device-generic-singletouch.c        |  13 +-
 test/litest-device-gpio-keys.c                  |  13 +-
 test/litest-device-huion-pentablet.c            |  12 +-
 test/litest-device-ignored-mouse.c              |  12 +-
 test/litest-device-keyboard-all-codes.c         |  20 +--
 test/litest-device-keyboard-razer-blackwidow.c  |  12 +-
 test/litest-device-keyboard.c                   |  12 +-
 test/litest-device-lid-switch-surface3.c        |  13 +-
 test/litest-device-lid-switch.c                 |  13 +-
 test/litest-device-logitech-trackball.c         |  12 +-
 test/litest-device-magic-trackpad.c             |  12 +-
 test/litest-device-mouse-low-dpi.c              |  12 +-
 test/litest-device-mouse-roccat.c               |  12 +-
 test/litest-device-mouse-wheel-click-angle.c    |  12 +-
 test/litest-device-mouse-wheel-click-count.c    |  12 +-
 test/litest-device-mouse-wheel-tilt.c           |  12 +-
 test/litest-device-mouse.c                      |  12 +-
 test/litest-device-ms-surface-cover.c           |  13 +-
 test/litest-device-nexus4-touch-screen.c        |  13 +-
 test/litest-device-protocol-a-touch-screen.c    |  13 +-
 test/litest-device-qemu-usb-tablet.c            |  13 +-
 test/litest-device-synaptics-hover.c            |  13 +-
 test/litest-device-synaptics-i2c.c              |  13 +-
 test/litest-device-synaptics-rmi4.c             |  13 +-
 test/litest-device-synaptics-st.c               |  13 +-
 test/litest-device-synaptics-t440.c             |  13 +-
 test/litest-device-synaptics-x1-carbon-3rd.c    |  13 +-
 test/litest-device-synaptics.c                  |  13 +-
 test/litest-device-thinkpad-extrabuttons.c      |  12 +-
 test/litest-device-touch-screen.c               |  13 +-
 test/litest-device-touchscreen-fuzz.c           |  13 +-
 test/litest-device-trackpoint.c                 |  12 +-
 test/litest-device-uclogic-tablet.c             |  12 +-
 test/litest-device-vmware-virtual-usb-mouse.c   |  13 +-
 test/litest-device-wacom-bamboo-16fg-pen.c      |  12 +-
 test/litest-device-wacom-cintiq-12wx-pen.c      |  12 +-
 test/litest-device-wacom-cintiq-13hdt-finger.c  |  12 +-
 test/litest-device-wacom-cintiq-13hdt-pad.c     |  12 +-
 test/litest-device-wacom-cintiq-13hdt-pen.c     |  12 +-
 test/litest-device-wacom-cintiq-24hd-pen.c      |  12 +-
 test/litest-device-wacom-cintiq-24hdt-pad.c     |  15 +--
 test/litest-device-wacom-ekr.c                  |  13 +-
 test/litest-device-wacom-hid4800-pen.c          |  12 +-
 test/litest-device-wacom-intuos3-pad.c          |  13 +-
 test/litest-device-wacom-intuos5-finger.c       |  13 +-
 test/litest-device-wacom-intuos5-pad.c          |  13 +-
 test/litest-device-wacom-intuos5-pen.c          |  12 +-
 test/litest-device-wacom-isdv4-e6-finger.c      |  13 +-
 test/litest-device-wacom-isdv4-e6-pen.c         |  12 +-
 test/litest-device-wacom-mobilestudio-pro-pad.c |  12 +-
 test/litest-device-waltop-tablet.c              |  12 +-
 test/litest-device-wheel-only.c                 |  12 +-
 test/litest-device-xen-virtual-pointer.c        |  13 +-
 test/litest-device-yubikey.c                    |  12 +-
 test/litest.c                                   | 168 ++++--------------------
 test/litest.h                                   |  24 ++++
 71 files changed, 197 insertions(+), 862 deletions(-)

diff --git a/meson.build b/meson.build
index dc3ab1b6..2c827bc5 100644
--- a/meson.build
+++ b/meson.build
@@ -631,17 +631,16 @@ if get_option('tests')
 		def_no_main,
 		def_disable_backtrace
 	]
-	test_litest_selftest_sources = [
+	test_litest_selftest_sources = lib_litest_sources + [
 		'test/litest-selftest.c',
 		'test/litest.c',
 		'test/litest-int.h',
 		'test/litest.h'
 	]
-	deps_litest_selftest = [dep_litest]
 	test_litest_selftest = executable('test-litest-selftest',
 					  test_litest_selftest_sources,
 					  include_directories : [includes_src, includes_include],
-					  dependencies : deps_litest_selftest,
+					  dependencies : deps_litest,
 					  c_args : defs_litest_selftest,
 					  install : false)
 	test('test-litest-selftest', test_litest_selftest)
@@ -651,7 +650,7 @@ if get_option('tests')
 	     test_symbols_leak,
 	     args : [ meson.current_source_dir() ])
 
-	libinput_test_runner_sources = [
+	libinput_test_runner_sources = lib_litest_sources + [
 		'src/libinput-util.h',
 		'src/libinput-util.c',
 		'test/test-udev.c',
@@ -676,7 +675,7 @@ if get_option('tests')
 	libinput_test_runner = executable('libinput-test-suite-runner',
 					  libinput_test_runner_sources,
 					  include_directories : [includes_src, includes_include],
-					  dependencies : dep_litest,
+					  dependencies : deps_litest,
 					  c_args : [ def_LT_VERSION ],
 					  install : false)
 	test('libinput-test-suite-runner',
diff --git a/test/litest-device-acer-hawaii-keyboard.c b/test/litest-device-acer-hawaii-keyboard.c
index 1691e9c1..040a26a9 100644
--- a/test/litest-device-acer-hawaii-keyboard.c
+++ b/test/litest-device-acer-hawaii-keyboard.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_keyboard_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_ACER_HAWAII_KEYBOARD);
-	litest_set_current_device(d);
-}
-
 static struct input_id input_id = {
 	.bustype = 0x3,
 	.vendor = 0x4f2,
@@ -194,15 +188,13 @@ static int events[] = {
 	-1, -1,
 };
 
-struct litest_test_device litest_acer_hawaii_keyboard_device = {
+TEST_DEVICE("hawaii-keyboard",
 	.type = LITEST_ACER_HAWAII_KEYBOARD,
 	.features = LITEST_KEYS,
-	.shortname = "hawaii-keyboard",
-	.setup = litest_keyboard_setup,
 	.interface = NULL,
 
 	.name = "Chicony ACER Hawaii Keyboard",
 	.id = &input_id,
 	.events = events,
 	.absinfo = NULL,
-};
+)
diff --git a/test/litest-device-acer-hawaii-touchpad.c b/test/litest-device-acer-hawaii-touchpad.c
index 1dcd4ce0..8ededb34 100644
--- a/test/litest-device-acer-hawaii-touchpad.c
+++ b/test/litest-device-acer-hawaii-touchpad.c
@@ -26,13 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void
-litest_touchpad_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_ACER_HAWAII_TOUCHPAD);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN  },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -98,11 +91,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"touchpad_end\"";
 
-struct litest_test_device litest_acer_hawaii_touchpad_device = {
+TEST_DEVICE("hawaii-touchpad",
 	.type = LITEST_ACER_HAWAII_TOUCHPAD,
 	.features = LITEST_TOUCHPAD | LITEST_CLICKPAD | LITEST_BUTTON,
-	.shortname = "hawaii-touchpad",
-	.setup = litest_touchpad_setup,
 	.interface = &interface,
 
 	.name = "Chicony ACER Hawaii Keyboard Touchpad",
@@ -110,4 +101,4 @@ struct litest_test_device litest_acer_hawaii_touchpad_device = {
 	.events = events,
 	.absinfo = absinfo,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-alps-dualpoint.c b/test/litest-device-alps-dualpoint.c
index 90fdbcaf..7e68ec61 100644
--- a/test/litest-device-alps-dualpoint.c
+++ b/test/litest-device-alps-dualpoint.c
@@ -30,13 +30,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void
-litest_alps_dualpoint_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_ALPS_DUALPOINT);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN  },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -120,11 +113,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"touchpad_end\"";
 
-struct litest_test_device litest_alps_dualpoint_device = {
+TEST_DEVICE("alps-dualpoint",
 	.type = LITEST_ALPS_DUALPOINT,
 	.features = LITEST_TOUCHPAD | LITEST_BUTTON | LITEST_SEMI_MT,
-	.shortname = "alps dualpoint",
-	.setup = litest_alps_dualpoint_setup,
 	.interface = &interface,
 
 	.name = "AlpsPS/2 ALPS DualPoint TouchPad",
@@ -132,4 +123,4 @@ struct litest_test_device litest_alps_dualpoint_device = {
 	.events = events,
 	.absinfo = absinfo,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-alps-semi-mt.c b/test/litest-device-alps-semi-mt.c
index de0eb3ab..59aac969 100644
--- a/test/litest-device-alps-semi-mt.c
+++ b/test/litest-device-alps-semi-mt.c
@@ -30,13 +30,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void
-litest_alps_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_ALPS_SEMI_MT);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN  },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -110,15 +103,13 @@ static struct input_absinfo absinfo[] = {
 	{ .value = -1 }
 };
 
-struct litest_test_device litest_alps_device = {
+TEST_DEVICE("alps-semi-mt",
 	.type = LITEST_ALPS_SEMI_MT,
 	.features = LITEST_TOUCHPAD | LITEST_BUTTON | LITEST_SEMI_MT,
-	.shortname = "alps semi-mt",
-	.setup = litest_alps_setup,
 	.interface = &interface,
 
 	.name = "AlpsPS/2 ALPS GlidePoint",
 	.id = &input_id,
 	.events = events,
 	.absinfo = absinfo,
-};
+)
diff --git a/test/litest-device-anker-mouse-kbd.c b/test/litest-device-anker-mouse-kbd.c
index 3971c771..ef515364 100644
--- a/test/litest-device-anker-mouse-kbd.c
+++ b/test/litest-device-anker-mouse-kbd.c
@@ -30,12 +30,6 @@
  * This is the keyboard device for this mouse.
  */
 
-static void litest_anker_mouse_kbd_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_ANKER_MOUSE_KBD);
-	litest_set_current_device(d);
-}
-
 static struct input_id input_id = {
 	.bustype = 0x3,
 	.vendor = 0x4d9,
@@ -209,15 +203,13 @@ static struct input_absinfo absinfo[] = {
 	{ .value = -1 },
 };
 
-struct litest_test_device litest_anker_mouse_kbd_device = {
+TEST_DEVICE("anker-kbd",
 	.type = LITEST_ANKER_MOUSE_KBD,
 	.features = LITEST_KEYS | LITEST_WHEEL,
-	.shortname = "anker_kbd",
-	.setup = litest_anker_mouse_kbd_setup,
 	.interface = NULL,
 
 	.name = "USB Laser Game Mouse",
 	.id = &input_id,
 	.absinfo = absinfo,
 	.events = events,
-};
+)
diff --git a/test/litest-device-apple-appletouch.c b/test/litest-device-apple-appletouch.c
index 08c07687..fa13e8e5 100644
--- a/test/litest-device-apple-appletouch.c
+++ b/test/litest-device-apple-appletouch.c
@@ -26,13 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void
-litest_appletouch_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_APPLETOUCH);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN  },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -100,11 +93,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"touchpad_end\"";
 
-struct litest_test_device litest_appletouch_device = {
+TEST_DEVICE("appletouch",
 	.type = LITEST_APPLETOUCH,
 	.features = LITEST_TOUCHPAD | LITEST_BUTTON | LITEST_SINGLE_TOUCH,
-	.shortname = "appletouch",
-	.setup = litest_appletouch_setup,
 	.interface = &interface,
 
 	.name = "appletouch",
@@ -112,4 +103,4 @@ struct litest_test_device litest_appletouch_device = {
 	.events = events,
 	.absinfo = absinfo,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-apple-internal-keyboard.c b/test/litest-device-apple-internal-keyboard.c
index 4b500ae2..ca1159e8 100644
--- a/test/litest-device-apple-internal-keyboard.c
+++ b/test/litest-device-apple-internal-keyboard.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_apple_keyboard_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_APPLE_KEYBOARD);
-	litest_set_current_device(d);
-}
-
 static struct input_id input_id = {
 	.bustype = 0x3,
 	.vendor = 0x5ac,
@@ -223,15 +217,13 @@ static int events[] = {
 	-1, -1
 };
 
-struct litest_test_device litest_apple_keyboard_device = {
+TEST_DEVICE("apple-keyboard",
 	.type = LITEST_APPLE_KEYBOARD,
 	.features = LITEST_KEYS,
-	.shortname = "apple_keyboard",
-	.setup = litest_apple_keyboard_setup,
 	.interface = NULL,
 
 	.name = "Apple Inc. Apple Internal Keyboard / Trackpad",
 	.id = &input_id,
 	.events = events,
 	.absinfo = NULL,
-};
+)
diff --git a/test/litest-device-apple-magicmouse.c b/test/litest-device-apple-magicmouse.c
index 0ba84a56..f657415a 100644
--- a/test/litest-device-apple-magicmouse.c
+++ b/test/litest-device-apple-magicmouse.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_magicmouse_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_MAGICMOUSE);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = LITEST_AUTO_ASSIGN },
@@ -106,11 +100,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"mouse_end\"";
 
-struct litest_test_device litest_magicmouse_device = {
+TEST_DEVICE("litest-magicmouse-device",
 	.type = LITEST_MAGICMOUSE,
 	.features = LITEST_RELATIVE | LITEST_BUTTON | LITEST_WHEEL,
-	.shortname = "magicmouse",
-	.setup = litest_magicmouse_setup,
 	.interface = &interface,
 
 	.name = "Apple Magic Mouse",
@@ -118,4 +110,4 @@ struct litest_test_device litest_magicmouse_device = {
 	.events = events,
 	.absinfo = absinfo,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-asus-rog-gladius.c b/test/litest-device-asus-rog-gladius.c
index 8d4ffe59..2617713d 100644
--- a/test/litest-device-asus-rog-gladius.c
+++ b/test/litest-device-asus-rog-gladius.c
@@ -29,12 +29,6 @@
 /* Note: this is the second event node of this mouse only, the first event
  * node is just a normal mouse */
 
-static void litest_mouse_gladius_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_MOUSE_GLADIUS);
-	litest_set_current_device(d);
-}
-
 static struct input_id input_id = {
 	.bustype = 0x3,
 	.vendor = 0x0b05,
@@ -318,15 +312,13 @@ static struct input_absinfo absinfo[] = {
 	{ .value = -1 }
 };
 
-struct litest_test_device litest_mouse_gladius_device = {
+TEST_DEVICE("mouse-gladius",
 	.type = LITEST_MOUSE_GLADIUS,
 	.features = LITEST_RELATIVE | LITEST_WHEEL | LITEST_KEYS,
-	.shortname = "mouse_gladius",
-	.setup = litest_mouse_gladius_setup,
 	.interface = NULL,
 
 	.name = "ASUS ROG GLADIUS",
 	.id = &input_id,
 	.absinfo = absinfo,
 	.events = events,
-};
+)
diff --git a/test/litest-device-atmel-hover.c b/test/litest-device-atmel-hover.c
index f528784a..f94bd535 100644
--- a/test/litest-device-atmel-hover.c
+++ b/test/litest-device-atmel-hover.c
@@ -30,13 +30,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void
-litest_atmel_hover_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_ATMEL_HOVER);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN  },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -128,15 +121,13 @@ static struct input_absinfo absinfo[] = {
 	{ .value = -1 }
 };
 
-struct litest_test_device litest_atmel_hover_device = {
+TEST_DEVICE("atmel-hover",
 	.type = LITEST_ATMEL_HOVER,
 	.features = LITEST_TOUCHPAD | LITEST_BUTTON | LITEST_CLICKPAD | LITEST_HOVER,
-	.shortname = "atmel hover",
-	.setup = litest_atmel_hover_setup,
 	.interface = &interface,
 
 	.name = "Atmel maXTouch Touchpad",
 	.id = &input_id,
 	.events = events,
 	.absinfo = absinfo,
-};
+)
diff --git a/test/litest-device-bcm5974.c b/test/litest-device-bcm5974.c
index 1e6a002f..0a3002f6 100644
--- a/test/litest-device-bcm5974.c
+++ b/test/litest-device-bcm5974.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_bcm5974_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_BCM5974);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN  },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -121,16 +115,14 @@ static int events[] = {
 	-1, -1
 };
 
-struct litest_test_device litest_bcm5974_device = {
+TEST_DEVICE("bcm5974",
 	.type = LITEST_BCM5974,
 	.features = LITEST_TOUCHPAD | LITEST_CLICKPAD |
 		    LITEST_BUTTON | LITEST_APPLE_CLICKPAD,
-	.shortname = "bcm5974",
-	.setup = litest_bcm5974_setup,
 	.interface = &interface,
 
 	.name = "bcm5974",
 	.id = &input_id,
 	.events = events,
 	.absinfo = absinfo,
-};
+)
diff --git a/test/litest-device-calibrated-touchscreen.c b/test/litest-device-calibrated-touchscreen.c
index c750e86d..e243921c 100644
--- a/test/litest-device-calibrated-touchscreen.c
+++ b/test/litest-device-calibrated-touchscreen.c
@@ -26,13 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_calibrated_touchscreen_setup(void)
-{
-	struct litest_device *d =
-		litest_create_device(LITEST_CALIBRATED_TOUCHSCREEN);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = LITEST_AUTO_ASSIGN },
@@ -87,11 +80,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"calibrated_touchscreen_end\"";
 
-struct litest_test_device litest_calibrated_touchscreen_device = {
+TEST_DEVICE("calibrated-touchscreen",
 	.type = LITEST_CALIBRATED_TOUCHSCREEN,
 	.features = LITEST_TOUCH,
-	.shortname = "calibrated-touchscreen",
-	.setup = litest_calibrated_touchscreen_setup,
 	.interface = &interface,
 
 	.name = "Calibrated Touchscreen",
@@ -99,4 +90,4 @@ struct litest_test_device litest_calibrated_touchscreen_device = {
 	.events = events,
 	.absinfo = absinfo,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-cyborg-rat-5.c b/test/litest-device-cyborg-rat-5.c
index e14f9760..9fd09789 100644
--- a/test/litest-device-cyborg-rat-5.c
+++ b/test/litest-device-cyborg-rat-5.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_cyborg_rat_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_CYBORG_RAT);
-	litest_set_current_device(d);
-}
-
 static struct input_id input_id = {
 	.bustype = 0x3,
 	.vendor = 0x6a3,
@@ -55,15 +49,13 @@ static int events[] = {
 	-1 , -1,
 };
 
-struct litest_test_device litest_cyborg_rat_device = {
+TEST_DEVICE("cyborg-rat",
 	.type = LITEST_CYBORG_RAT,
 	.features = LITEST_RELATIVE | LITEST_BUTTON | LITEST_WHEEL,
-	.shortname = "cyborg_rat",
-	.setup = litest_cyborg_rat_setup,
 	.interface = NULL,
 
 	.name = "Saitek Cyborg R.A.T.5 Mouse",
 	.id = &input_id,
 	.absinfo = NULL,
 	.events = events,
-};
+)
diff --git a/test/litest-device-elantech-touchpad.c b/test/litest-device-elantech-touchpad.c
index 9c5422c6..ab87f105 100644
--- a/test/litest-device-elantech-touchpad.c
+++ b/test/litest-device-elantech-touchpad.c
@@ -26,13 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void
-litest_elantech_touchpad_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_ELANTECH_TOUCHPAD);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN  },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -105,15 +98,13 @@ static struct input_absinfo absinfo[] = {
 	{ .value = -1 }
 };
 
-struct litest_test_device litest_elantech_touchpad_device = {
+TEST_DEVICE("elantech",
 	.type = LITEST_ELANTECH_TOUCHPAD,
 	.features = LITEST_TOUCHPAD | LITEST_BUTTON,
-	.shortname = "elantech",
-	.setup = litest_elantech_touchpad_setup,
 	.interface = &interface,
 
 	.name = "ETPS/2 Elantech Touchpad",
 	.id = &input_id,
 	.events = events,
 	.absinfo = absinfo,
-};
+)
diff --git a/test/litest-device-generic-singletouch.c b/test/litest-device-generic-singletouch.c
index 519045d5..306fd73d 100644
--- a/test/litest-device-generic-singletouch.c
+++ b/test/litest-device-generic-singletouch.c
@@ -26,13 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void
-litest_generic_singletouch_touch_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_GENERIC_SINGLETOUCH);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -72,15 +65,13 @@ static int events[] = {
 	-1, -1,
 };
 
-struct litest_test_device litest_generic_singletouch_device = {
+TEST_DEVICE("generic-singletouch",
 	.type = LITEST_GENERIC_SINGLETOUCH,
 	.features = LITEST_SINGLE_TOUCH,
-	.shortname = "generic-singletouch",
-	.setup = litest_generic_singletouch_touch_setup,
 	.interface = &interface,
 
 	.name = "generic_singletouch",
 	.id = &input_id,
 	.events = events,
 	.absinfo = absinfo,
-};
+)
diff --git a/test/litest-device-gpio-keys.c b/test/litest-device-gpio-keys.c
index 37b058c1..88cf28b2 100644
--- a/test/litest-device-gpio-keys.c
+++ b/test/litest-device-gpio-keys.c
@@ -26,13 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void
-litest_gpio_keys_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_GPIO_KEYS);
-	litest_set_current_device(d);
-}
-
 static struct input_id input_id = {
 	.bustype = 0x19,
 	.vendor = 0x1,
@@ -59,11 +52,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"switch_end\"";
 
-struct litest_test_device litest_gpio_keys_device = {
+TEST_DEVICE("gpio-keys",
 	.type = LITEST_GPIO_KEYS,
 	.features = LITEST_SWITCH,
-	.shortname = "gpio keys",
-	.setup = litest_gpio_keys_setup,
 	.interface = NULL,
 
 	.name = "gpio-keys",
@@ -72,4 +63,4 @@ struct litest_test_device litest_gpio_keys_device = {
 	.absinfo = NULL,
 
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-huion-pentablet.c b/test/litest-device-huion-pentablet.c
index dbbdcb01..053212b9 100644
--- a/test/litest-device-huion-pentablet.c
+++ b/test/litest-device-huion-pentablet.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_huion_tablet_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_HUION_TABLET);
-	litest_set_current_device(d);
-}
-
 static struct input_event proximity_in[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -104,11 +98,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"huion_end\"";
 
-struct litest_test_device litest_huion_tablet_device = {
+TEST_DEVICE("huion-tablet",
 	.type = LITEST_HUION_TABLET,
 	.features = LITEST_TABLET,
-	.shortname = "huion-tablet",
-	.setup = litest_huion_tablet_setup,
 	.interface = &interface,
 
 	.name = "HUION PenTablet Pen",
@@ -116,4 +108,4 @@ struct litest_test_device litest_huion_tablet_device = {
 	.events = events,
 	.absinfo = absinfo,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-ignored-mouse.c b/test/litest-device-ignored-mouse.c
index 8fde32c7..08f75388 100644
--- a/test/litest-device-ignored-mouse.c
+++ b/test/litest-device-ignored-mouse.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_mouse_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_IGNORED_MOUSE);
-	litest_set_current_device(d);
-}
-
 static struct input_id input_id = {
 	.bustype = 0x3,
 	.vendor = 0x17ef,
@@ -58,11 +52,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"mouse_end\"";
 
-struct litest_test_device litest_ignored_mouse_device = {
+TEST_DEVICE("ignored-mouse",
 	.type = LITEST_IGNORED_MOUSE,
 	.features = LITEST_IGNORED | LITEST_BUTTON | LITEST_RELATIVE,
-	.shortname = "ignored-mouse",
-	.setup = litest_mouse_setup,
 	.interface = NULL,
 
 	.name = "Ignored Mouse",
@@ -70,4 +62,4 @@ struct litest_test_device litest_ignored_mouse_device = {
 	.absinfo = NULL,
 	.events = events,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-keyboard-all-codes.c b/test/litest-device-keyboard-all-codes.c
index 38e891f4..268cff79 100644
--- a/test/litest-device-keyboard-all-codes.c
+++ b/test/litest-device-keyboard-all-codes.c
@@ -26,33 +26,27 @@
 #include "litest.h"
 #include "litest-int.h"
 
+#define NAME "All event codes keyboard"
+
 static void all_codes_create(struct litest_device *d);
 
-static void litest_keyboard_all_codes_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_KEYBOARD_ALL_CODES);
-	litest_set_current_device(d);
-}
-
 static struct input_id input_id = {
 	.bustype = 0x11,
 	.vendor = 0x1,
 	.product = 0x1,
 };
 
-struct litest_test_device litest_keyboard_all_codes_device = {
+TEST_DEVICE("keyboard-all-codes",
 	.type = LITEST_KEYBOARD_ALL_CODES,
 	.features = LITEST_KEYS,
-	.shortname = "keyboard all event codes",
-	.setup = litest_keyboard_all_codes_setup,
 	.interface = NULL,
 	.create = all_codes_create,
 
-	.name = "All event codes keyboard",
+	.name = NAME,
 	.id = &input_id,
 	.events = NULL,
 	.absinfo = NULL,
-};
+)
 
 static void
 all_codes_create(struct litest_device *d)
@@ -72,8 +66,8 @@ all_codes_create(struct litest_device *d)
 	events[idx++] = -1;
 	events[idx++] = -1;
 
-	d->uinput = litest_create_uinput_device_from_description(litest_keyboard_all_codes_device.name,
-								 litest_keyboard_all_codes_device.id,
+	d->uinput = litest_create_uinput_device_from_description(NAME,
+								 &input_id,
 								 NULL,
 								 events);
 }
diff --git a/test/litest-device-keyboard-razer-blackwidow.c b/test/litest-device-keyboard-razer-blackwidow.c
index 70b12025..5dee7f46 100644
--- a/test/litest-device-keyboard-razer-blackwidow.c
+++ b/test/litest-device-keyboard-razer-blackwidow.c
@@ -32,12 +32,6 @@
  * file.
  */
 
-static void litest_blackwidow_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_KEYBOARD_BLACKWIDOW);
-	litest_set_current_device(d);
-}
-
 static struct input_id input_id = {
 	.bustype = 0x3,
 	.vendor = 0x1532,
@@ -335,15 +329,13 @@ static struct input_absinfo absinfo[] = {
 	{ .value = -1 },
 };
 
-struct litest_test_device litest_keyboard_blackwidow_device = {
+TEST_DEVICE("blackwidow",
 	.type = LITEST_KEYBOARD_BLACKWIDOW,
 	.features = LITEST_KEYS | LITEST_WHEEL,
-	.shortname = "blackwidow",
-	.setup = litest_blackwidow_setup,
 	.interface = NULL,
 
 	.name = "Razer Razer BlackWidow 2013",
 	.id = &input_id,
 	.absinfo = absinfo,
 	.events = events,
-};
+)
diff --git a/test/litest-device-keyboard.c b/test/litest-device-keyboard.c
index 10d8f3ff..6f6c6260 100644
--- a/test/litest-device-keyboard.c
+++ b/test/litest-device-keyboard.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_keyboard_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_KEYBOARD);
-	litest_set_current_device(d);
-}
-
 static struct input_id input_id = {
 	.bustype = 0x11,
 	.vendor = 0x1,
@@ -197,15 +191,13 @@ static int events[] = {
 	-1, -1,
 };
 
-struct litest_test_device litest_keyboard_device = {
+TEST_DEVICE("default-keyboard",
 	.type = LITEST_KEYBOARD,
 	.features = LITEST_KEYS,
-	.shortname = "default keyboard",
-	.setup = litest_keyboard_setup,
 	.interface = NULL,
 
 	.name = "AT Translated Set 2 keyboard",
 	.id = &input_id,
 	.events = events,
 	.absinfo = NULL,
-};
+)
diff --git a/test/litest-device-lid-switch-surface3.c b/test/litest-device-lid-switch-surface3.c
index fde15c2f..a0df1696 100644
--- a/test/litest-device-lid-switch-surface3.c
+++ b/test/litest-device-lid-switch-surface3.c
@@ -27,13 +27,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void
-litest_lid_switch_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_LID_SWITCH_SURFACE3);
-	litest_set_current_device(d);
-}
-
 static struct input_id input_id = {
 	.bustype = 0x19,
 	.vendor = 0x0,
@@ -55,11 +48,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"switch_end\"";
 
-struct litest_test_device litest_lid_switch_surface3_device = {
+TEST_DEVICE("lid-switch-surface3",
 	.type = LITEST_LID_SWITCH_SURFACE3,
 	.features = LITEST_SWITCH,
-	.shortname = "lid-switch-surface3",
-	.setup = litest_lid_switch_setup,
 	.interface = NULL,
 
 	.name = "Lid Switch Surface3",
@@ -68,4 +59,4 @@ struct litest_test_device litest_lid_switch_surface3_device = {
 	.absinfo = NULL,
 
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-lid-switch.c b/test/litest-device-lid-switch.c
index b96592dc..c6fb597c 100644
--- a/test/litest-device-lid-switch.c
+++ b/test/litest-device-lid-switch.c
@@ -26,13 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void
-litest_lid_switch_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_LID_SWITCH);
-	litest_set_current_device(d);
-}
-
 static struct input_id input_id = {
 	.bustype = 0x19,
 	.vendor = 0x0,
@@ -54,11 +47,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"switch_end\"";
 
-struct litest_test_device litest_lid_switch_device = {
+TEST_DEVICE("lid-switch",
 	.type = LITEST_LID_SWITCH,
 	.features = LITEST_SWITCH,
-	.shortname = "lid switch",
-	.setup = litest_lid_switch_setup,
 	.interface = NULL,
 
 	.name = "Lid Switch",
@@ -67,4 +58,4 @@ struct litest_test_device litest_lid_switch_device = {
 	.absinfo = NULL,
 
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-logitech-trackball.c b/test/litest-device-logitech-trackball.c
index 2c59f052..747b66cf 100644
--- a/test/litest-device-logitech-trackball.c
+++ b/test/litest-device-logitech-trackball.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_logitech_trackball_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_LOGITECH_TRACKBALL);
-	litest_set_current_device(d);
-}
-
 static struct input_id input_id = {
 	.bustype = 0x3,
 	.vendor = 0x46d,
@@ -49,15 +43,13 @@ static int events[] = {
 	-1 , -1,
 };
 
-struct litest_test_device litest_logitech_trackball_device = {
+TEST_DEVICE("logitech-trackball",
 	.type = LITEST_LOGITECH_TRACKBALL,
 	.features = LITEST_RELATIVE | LITEST_BUTTON | LITEST_TRACKBALL,
-	.shortname = "logitech trackball",
-	.setup = litest_logitech_trackball_setup,
 	.interface = NULL,
 
 	.name = "Logitech USB Trackball",
 	.id = &input_id,
 	.absinfo = NULL,
 	.events = events,
-};
+)
diff --git a/test/litest-device-magic-trackpad.c b/test/litest-device-magic-trackpad.c
index 56d42344..e569f4d9 100644
--- a/test/litest-device-magic-trackpad.c
+++ b/test/litest-device-magic-trackpad.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_magicpad_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_MAGIC_TRACKPAD);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN  },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -121,12 +115,10 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"touchpad_end\"";
 
-struct litest_test_device litest_magicpad_device = {
+TEST_DEVICE("magic-trackpad",
 	.type = LITEST_MAGIC_TRACKPAD,
 	.features = LITEST_TOUCHPAD | LITEST_CLICKPAD |
 		    LITEST_BUTTON | LITEST_APPLE_CLICKPAD,
-	.shortname = "magic trackpad",
-	.setup = litest_magicpad_setup,
 	.interface = &interface,
 
 	.name = "Apple Wireless Trackpad",
@@ -134,4 +126,4 @@ struct litest_test_device litest_magicpad_device = {
 	.events = events,
 	.absinfo = absinfo,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-mouse-low-dpi.c b/test/litest-device-mouse-low-dpi.c
index ac224613..3339b3aa 100644
--- a/test/litest-device-mouse-low-dpi.c
+++ b/test/litest-device-mouse-low-dpi.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_mouse_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_MOUSE_LOW_DPI);
-	litest_set_current_device(d);
-}
-
 static struct input_id input_id = {
 	.bustype = 0x3,
 	.vendor = 0x1,
@@ -58,11 +52,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"touchpad_end\"";
 
-struct litest_test_device litest_mouse_low_dpi_device = {
+TEST_DEVICE("low-dpi-mouse",
 	.type = LITEST_MOUSE_LOW_DPI,
 	.features = LITEST_RELATIVE | LITEST_BUTTON | LITEST_WHEEL,
-	.shortname = "low-dpi mouse",
-	.setup = litest_mouse_setup,
 	.interface = NULL,
 
 	.name = "Low DPI Mouse",
@@ -70,4 +62,4 @@ struct litest_test_device litest_mouse_low_dpi_device = {
 	.absinfo = NULL,
 	.events = events,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-mouse-roccat.c b/test/litest-device-mouse-roccat.c
index 3b4edc80..c7d41cef 100644
--- a/test/litest-device-mouse-roccat.c
+++ b/test/litest-device-mouse-roccat.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_mouse_roccat_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_MOUSE_ROCCAT);
-	litest_set_current_device(d);
-}
-
 static struct input_id input_id = {
 	.bustype = 0x3,
 	.vendor = 0x1e7d,
@@ -190,15 +184,13 @@ static struct input_absinfo absinfo[] = {
 	{ .value = -1 }
 };
 
-struct litest_test_device litest_mouse_roccat_device = {
+TEST_DEVICE("mouse-roccat",
 	.type = LITEST_MOUSE_ROCCAT,
 	.features = LITEST_RELATIVE | LITEST_BUTTON | LITEST_WHEEL | LITEST_KEYS,
-	.shortname = "mouse_roccat",
-	.setup = litest_mouse_roccat_setup,
 	.interface = NULL,
 
 	.name = "ROCCAT ROCCAT Kone XTD",
 	.id = &input_id,
 	.absinfo = absinfo,
 	.events = events,
-};
+)
diff --git a/test/litest-device-mouse-wheel-click-angle.c b/test/litest-device-mouse-wheel-click-angle.c
index 74bfcb5f..2de3f2a2 100644
--- a/test/litest-device-mouse-wheel-click-angle.c
+++ b/test/litest-device-mouse-wheel-click-angle.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_mouse_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_MOUSE_WHEEL_CLICK_ANGLE);
-	litest_set_current_device(d);
-}
-
 static struct input_id input_id = {
 	.bustype = 0x3,
 	.vendor = 0x1234,
@@ -58,11 +52,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"wheel_click_angle_end\"";
 
-struct litest_test_device litest_mouse_wheel_click_angle_device = {
+TEST_DEVICE("mouse-wheelclickangle",
 	.type = LITEST_MOUSE_WHEEL_CLICK_ANGLE,
 	.features = LITEST_RELATIVE | LITEST_BUTTON | LITEST_WHEEL,
-	.shortname = "mouse-wheelclickangle",
-	.setup = litest_mouse_setup,
 	.interface = NULL,
 
 	.name = "Wheel Click Angle Mouse",
@@ -70,4 +62,4 @@ struct litest_test_device litest_mouse_wheel_click_angle_device = {
 	.absinfo = NULL,
 	.events = events,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-mouse-wheel-click-count.c b/test/litest-device-mouse-wheel-click-count.c
index cd5e1037..dcd5d160 100644
--- a/test/litest-device-mouse-wheel-click-count.c
+++ b/test/litest-device-mouse-wheel-click-count.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_mouse_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_MOUSE_WHEEL_CLICK_COUNT);
-	litest_set_current_device(d);
-}
-
 static struct input_id input_id = {
 	.bustype = 0x3,
 	.vendor = 0x1234,
@@ -60,11 +54,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"wheel_click_count_end\"";
 
-struct litest_test_device litest_mouse_wheel_click_count_device = {
+TEST_DEVICE("mouse-wheelclickcount",
 	.type = LITEST_MOUSE_WHEEL_CLICK_COUNT,
 	.features = LITEST_RELATIVE | LITEST_BUTTON | LITEST_WHEEL,
-	.shortname = "mouse-wheelclickcount",
-	.setup = litest_mouse_setup,
 	.interface = NULL,
 
 	.name = "Wheel Click Count Mouse",
@@ -72,4 +64,4 @@ struct litest_test_device litest_mouse_wheel_click_count_device = {
 	.absinfo = NULL,
 	.events = events,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-mouse-wheel-tilt.c b/test/litest-device-mouse-wheel-tilt.c
index 2a63469c..0ea1f1fe 100644
--- a/test/litest-device-mouse-wheel-tilt.c
+++ b/test/litest-device-mouse-wheel-tilt.c
@@ -28,12 +28,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_mouse_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_MOUSE_WHEEL_TILT);
-	litest_set_current_device(d);
-}
-
 static struct input_id input_id = {
 	.bustype = 0x3,
 	.vendor = 0x17ef,
@@ -61,11 +55,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"wheel_wheel_tilt_end\"";
 
-struct litest_test_device litest_mouse_wheel_tilt_device = {
+TEST_DEVICE("mouse-wheel-tilt",
 	.type = LITEST_MOUSE_WHEEL_TILT,
 	.features = LITEST_RELATIVE | LITEST_BUTTON | LITEST_WHEEL,
-	.shortname = "mouse-wheel-tilt",
-	.setup = litest_mouse_setup,
 	.interface = NULL,
 
 	.name = "Wheel Tilt Mouse",
@@ -73,4 +65,4 @@ struct litest_test_device litest_mouse_wheel_tilt_device = {
 	.absinfo = NULL,
 	.events = events,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-mouse.c b/test/litest-device-mouse.c
index 31953f26..68275be8 100644
--- a/test/litest-device-mouse.c
+++ b/test/litest-device-mouse.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_mouse_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_MOUSE);
-	litest_set_current_device(d);
-}
-
 static struct input_id input_id = {
 	.bustype = 0x3,
 	.vendor = 0x17ef,
@@ -48,15 +42,13 @@ static int events[] = {
 	-1 , -1,
 };
 
-struct litest_test_device litest_mouse_device = {
+TEST_DEVICE("mouse",
 	.type = LITEST_MOUSE,
 	.features = LITEST_RELATIVE | LITEST_BUTTON | LITEST_WHEEL,
-	.shortname = "mouse",
-	.setup = litest_mouse_setup,
 	.interface = NULL,
 
 	.name = "Lenovo Optical USB Mouse",
 	.id = &input_id,
 	.absinfo = NULL,
 	.events = events,
-};
+)
diff --git a/test/litest-device-ms-surface-cover.c b/test/litest-device-ms-surface-cover.c
index 31195d14..31147211 100644
--- a/test/litest-device-ms-surface-cover.c
+++ b/test/litest-device-ms-surface-cover.c
@@ -26,13 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void
-litest_ms_surface_cover_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_MS_SURFACE_COVER);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -374,15 +367,13 @@ static int events[] = {
 	-1, -1,
 };
 
-struct litest_test_device litest_ms_surface_cover_device = {
+TEST_DEVICE("ms-surface-cover",
 	.type = LITEST_MS_SURFACE_COVER,
 	.features = LITEST_KEYS | LITEST_ABSOLUTE | LITEST_RELATIVE | LITEST_FAKE_MT | LITEST_BUTTON | LITEST_WHEEL,
-	.shortname = "MS surface cover",
-	.setup = litest_ms_surface_cover_setup,
 	.interface = &interface,
 
 	.name = "Microsoft Surface Type Cover",
 	.id = &input_id,
 	.events = events,
 	.absinfo = absinfo,
-};
+)
diff --git a/test/litest-device-nexus4-touch-screen.c b/test/litest-device-nexus4-touch-screen.c
index f0477629..9e70aa29 100644
--- a/test/litest-device-nexus4-touch-screen.c
+++ b/test/litest-device-nexus4-touch-screen.c
@@ -26,13 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_nexus4_setup(void)
-{
-	struct litest_device *d =
-		litest_create_device(LITEST_NEXUS4_TOUCH_SCREEN);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = LITEST_AUTO_ASSIGN },
@@ -83,15 +76,13 @@ static int events[] = {
 	-1, -1
 };
 
-struct litest_test_device litest_nexus4_device = {
+TEST_DEVICE("nexus4",
 	.type = LITEST_NEXUS4_TOUCH_SCREEN,
 	.features = LITEST_TOUCH|LITEST_ELLIPSE,
-	.shortname = "nexus4",
-	.setup = litest_nexus4_setup,
 	.interface = &interface,
 
 	.name = "Nexus 4 touch screen",
 	.id = &input_id,
 	.events = events,
 	.absinfo = absinfo,
-};
+)
diff --git a/test/litest-device-protocol-a-touch-screen.c b/test/litest-device-protocol-a-touch-screen.c
index 98216ad7..29df2274 100644
--- a/test/litest-device-protocol-a-touch-screen.c
+++ b/test/litest-device-protocol-a-touch-screen.c
@@ -26,13 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void
-litest_protocol_a_touch_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_PROTOCOL_A_SCREEN);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -82,15 +75,13 @@ static int events[] = {
 	-1, -1,
 };
 
-struct litest_test_device litest_protocol_a_screen = {
+TEST_DEVICE("protocol-a",
 	.type = LITEST_PROTOCOL_A_SCREEN,
 	.features = LITEST_PROTOCOL_A,
-	.shortname = "protocol A",
-	.setup = litest_protocol_a_touch_setup,
 	.interface = &interface,
 
 	.name = "Protocol A touch screen",
 	.id = &input_id,
 	.events = events,
 	.absinfo = absinfo,
-};
+)
diff --git a/test/litest-device-qemu-usb-tablet.c b/test/litest-device-qemu-usb-tablet.c
index e5e8b5a7..bfcbc736 100644
--- a/test/litest-device-qemu-usb-tablet.c
+++ b/test/litest-device-qemu-usb-tablet.c
@@ -27,13 +27,6 @@
 #include "litest-int.h"
 #include <assert.h>
 
-static void
-litest_qemu_tablet_touch_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_QEMU_TABLET);
-	litest_set_current_device(d);
-}
-
 static void touch_down(struct litest_device *d, unsigned int slot,
 		       double x, double y)
 {
@@ -86,15 +79,13 @@ static int events[] = {
 	-1, -1,
 };
 
-struct litest_test_device litest_qemu_tablet_device = {
+TEST_DEVICE("qemu-tablet",
 	.type = LITEST_QEMU_TABLET,
 	.features = LITEST_WHEEL | LITEST_BUTTON | LITEST_ABSOLUTE,
-	.shortname = "qemu tablet",
-	.setup = litest_qemu_tablet_touch_setup,
 	.interface = &interface,
 
 	.name = "QEMU 0.12.1 QEMU USB Tablet",
 	.id = &input_id,
 	.events = events,
 	.absinfo = absinfo,
-};
+)
diff --git a/test/litest-device-synaptics-hover.c b/test/litest-device-synaptics-hover.c
index 9c0c7bda..2cade172 100644
--- a/test/litest-device-synaptics-hover.c
+++ b/test/litest-device-synaptics-hover.c
@@ -30,13 +30,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void
-litest_synaptics_hover_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_SYNAPTICS_HOVER_SEMI_MT);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN  },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -118,11 +111,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"synaptics_semi_mt_end\"";
 
-struct litest_test_device litest_synaptics_hover_device = {
+TEST_DEVICE("synaptics-hover",
 	.type = LITEST_SYNAPTICS_HOVER_SEMI_MT,
 	.features = LITEST_TOUCHPAD | LITEST_SEMI_MT | LITEST_BUTTON,
-	.shortname = "synaptics hover",
-	.setup = litest_synaptics_hover_setup,
 	.interface = &interface,
 
 	.name = "SynPS/2 Synaptics TouchPad",
@@ -130,4 +121,4 @@ struct litest_test_device litest_synaptics_hover_device = {
 	.events = events,
 	.absinfo = absinfo,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-synaptics-i2c.c b/test/litest-device-synaptics-i2c.c
index 3e1d5e4b..d32e0a50 100644
--- a/test/litest-device-synaptics-i2c.c
+++ b/test/litest-device-synaptics-i2c.c
@@ -26,13 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void
-litest_synaptics_i2c_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_SYNAPTICS_I2C);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN  },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -96,11 +89,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"touchpad_end\"";
 
-struct litest_test_device litest_synaptics_i2c_device = {
+TEST_DEVICE("synaptics-i2c",
 	.type = LITEST_SYNAPTICS_I2C,
 	.features = LITEST_TOUCHPAD | LITEST_CLICKPAD | LITEST_BUTTON,
-	.shortname = "synaptics-i2c",
-	.setup = litest_synaptics_i2c_setup,
 	.interface = &interface,
 
 	.name = "DLL0704:01 06CB:76AD Touchpad",
@@ -108,4 +99,4 @@ struct litest_test_device litest_synaptics_i2c_device = {
 	.events = events,
 	.absinfo = absinfo,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-synaptics-rmi4.c b/test/litest-device-synaptics-rmi4.c
index 87a85e91..c44bb68a 100644
--- a/test/litest-device-synaptics-rmi4.c
+++ b/test/litest-device-synaptics-rmi4.c
@@ -26,13 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void
-litest_synaptics_rmi4_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_SYNAPTICS_RMI4);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN  },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -118,15 +111,13 @@ static struct input_absinfo absinfo[] = {
 	{ .value = -1 }
 };
 
-struct litest_test_device litest_synaptics_rmi4_device = {
+TEST_DEVICE("synaptics-rmi4",
 	.type = LITEST_SYNAPTICS_RMI4,
 	.features = LITEST_TOUCHPAD | LITEST_CLICKPAD | LITEST_BUTTON,
-	.shortname = "synaptics rmi4",
-	.setup = litest_synaptics_rmi4_setup,
 	.interface = &interface,
 
 	.name = "Synaptics TM3053-004",
 	.id = &input_id,
 	.events = events,
 	.absinfo = absinfo,
-};
+)
diff --git a/test/litest-device-synaptics-st.c b/test/litest-device-synaptics-st.c
index bbde1ef0..e23dcd86 100644
--- a/test/litest-device-synaptics-st.c
+++ b/test/litest-device-synaptics-st.c
@@ -26,13 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void
-litest_synaptics_touchpad_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_SYNAPTICS_TOUCHPAD);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -95,15 +88,13 @@ static int events[] = {
 	-1, -1,
 };
 
-struct litest_test_device litest_synaptics_touchpad_device = {
+TEST_DEVICE("synaptics-st",
 	.type = LITEST_SYNAPTICS_TOUCHPAD,
 	.features = LITEST_TOUCHPAD | LITEST_BUTTON | LITEST_SINGLE_TOUCH,
-	.shortname = "synaptics ST",
-	.setup = litest_synaptics_touchpad_setup,
 	.interface = &interface,
 
 	.name = "SynPS/2 Synaptics TouchPad",
 	.id = &input_id,
 	.events = events,
 	.absinfo = absinfo,
-};
+)
diff --git a/test/litest-device-synaptics-t440.c b/test/litest-device-synaptics-t440.c
index 8bbdc2b3..e9f552bf 100644
--- a/test/litest-device-synaptics-t440.c
+++ b/test/litest-device-synaptics-t440.c
@@ -26,13 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void
-litest_synaptics_t440_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_SYNAPTICS_TOPBUTTONPAD);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN  },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -110,15 +103,13 @@ static struct input_absinfo absinfo[] = {
 	{ .value = -1 }
 };
 
-struct litest_test_device litest_synaptics_t440_device = {
+TEST_DEVICE("synaptics-t440",
 	.type = LITEST_SYNAPTICS_TOPBUTTONPAD,
 	.features = LITEST_TOUCHPAD | LITEST_CLICKPAD | LITEST_BUTTON | LITEST_TOPBUTTONPAD,
-	.shortname = "synaptics t440",
-	.setup = litest_synaptics_t440_setup,
 	.interface = &interface,
 
 	.name = "SynPS/2 Synaptics TouchPad",
 	.id = &input_id,
 	.events = events,
 	.absinfo = absinfo,
-};
+)
diff --git a/test/litest-device-synaptics-x1-carbon-3rd.c b/test/litest-device-synaptics-x1-carbon-3rd.c
index 1b30a4b5..73fac59a 100644
--- a/test/litest-device-synaptics-x1-carbon-3rd.c
+++ b/test/litest-device-synaptics-x1-carbon-3rd.c
@@ -26,13 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void
-litest_synaptics_carbon3rd_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_SYNAPTICS_TRACKPOINT_BUTTONS);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN  },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -122,11 +115,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"touchpad_end\"";
 
-struct litest_test_device litest_synaptics_carbon3rd_device = {
+TEST_DEVICE("synaptics-carbon3rd",
 	.type = LITEST_SYNAPTICS_TRACKPOINT_BUTTONS,
 	.features = LITEST_TOUCHPAD | LITEST_CLICKPAD | LITEST_BUTTON,
-	.shortname = "synaptics carbon3rd",
-	.setup = litest_synaptics_carbon3rd_setup,
 	.interface = &interface,
 
 	.name = "SynPS/2 Synaptics TouchPad X1C3rd",
@@ -134,4 +125,4 @@ struct litest_test_device litest_synaptics_carbon3rd_device = {
 	.events = events,
 	.absinfo = absinfo,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-synaptics.c b/test/litest-device-synaptics.c
index 94981272..50ddc44c 100644
--- a/test/litest-device-synaptics.c
+++ b/test/litest-device-synaptics.c
@@ -26,13 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void
-litest_synaptics_clickpad_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_SYNAPTICS_CLICKPAD_X220);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN  },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -109,15 +102,13 @@ static struct input_absinfo absinfo[] = {
 	{ .value = -1 }
 };
 
-struct litest_test_device litest_synaptics_clickpad_device = {
+TEST_DEVICE("synaptics",
 	.type = LITEST_SYNAPTICS_CLICKPAD_X220,
 	.features = LITEST_TOUCHPAD | LITEST_CLICKPAD | LITEST_BUTTON,
-	.shortname = "synaptics",
-	.setup = litest_synaptics_clickpad_setup,
 	.interface = &interface,
 
 	.name = "SynPS/2 Synaptics TouchPad",
 	.id = &input_id,
 	.events = events,
 	.absinfo = absinfo,
-};
+)
diff --git a/test/litest-device-thinkpad-extrabuttons.c b/test/litest-device-thinkpad-extrabuttons.c
index 84541493..42e5886f 100644
--- a/test/litest-device-thinkpad-extrabuttons.c
+++ b/test/litest-device-thinkpad-extrabuttons.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_extrabuttons_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_THINKPAD_EXTRABUTTONS);
-	litest_set_current_device(d);
-}
-
 static struct input_id input_id = {
 	.bustype = 0x19,
 	.vendor = 0x17aa,
@@ -76,15 +70,13 @@ static int events[] = {
 	-1, -1,
 };
 
-struct litest_test_device litest_thinkpad_extrabuttons_device = {
+TEST_DEVICE("thinkpad-extrabuttons",
 	.type = LITEST_THINKPAD_EXTRABUTTONS,
 	.features = LITEST_KEYS | LITEST_SWITCH,
-	.shortname = "thinkpad-extrabuttons",
-	.setup = litest_extrabuttons_setup,
 	.interface = NULL,
 
 	.name = "ThinkPad Extra Buttons",
 	.id = &input_id,
 	.events = events,
 	.absinfo = NULL,
-};
+)
diff --git a/test/litest-device-touch-screen.c b/test/litest-device-touch-screen.c
index a631884c..3cdbc2d4 100644
--- a/test/litest-device-touch-screen.c
+++ b/test/litest-device-touch-screen.c
@@ -26,13 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_generic_mt_setup(void)
-{
-	struct litest_device *d =
-		litest_create_device(LITEST_GENERIC_MULTITOUCH_SCREEN);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = LITEST_AUTO_ASSIGN },
@@ -89,15 +82,13 @@ static int events[] = {
 	-1, -1
 };
 
-struct litest_test_device litest_generic_multitouch_screen_device = {
+TEST_DEVICE("generic-mt",
 	.type = LITEST_GENERIC_MULTITOUCH_SCREEN,
 	.features = LITEST_TOUCH|LITEST_ELLIPSE,
-	.shortname = "generic-mt",
-	.setup = litest_generic_mt_setup,
 	.interface = &interface,
 
 	.name = "generic-mt",
 	.id = &input_id,
 	.events = events,
 	.absinfo = absinfo,
-};
+)
diff --git a/test/litest-device-touchscreen-fuzz.c b/test/litest-device-touchscreen-fuzz.c
index 931a5b98..77577a7f 100644
--- a/test/litest-device-touchscreen-fuzz.c
+++ b/test/litest-device-touchscreen-fuzz.c
@@ -26,13 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_fuzz_mt_setup(void)
-{
-	struct litest_device *d =
-		litest_create_device(LITEST_MULTITOUCH_FUZZ_SCREEN);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = LITEST_AUTO_ASSIGN },
@@ -80,15 +73,13 @@ static int events[] = {
 	-1, -1
 };
 
-struct litest_test_device litest_multitouch_fuzz_screen_device = {
+TEST_DEVICE("touchscreen-fuzz",
 	.type = LITEST_MULTITOUCH_FUZZ_SCREEN,
 	.features = LITEST_TOUCH,
-	.shortname = "touchscreen-fuzz",
-	.setup = litest_fuzz_mt_setup,
 	.interface = &interface,
 
 	.name = "touchscreen with fuzz",
 	.id = &input_id,
 	.events = events,
 	.absinfo = absinfo,
-};
+)
diff --git a/test/litest-device-trackpoint.c b/test/litest-device-trackpoint.c
index 4ebb4f93..eaad8b74 100644
--- a/test/litest-device-trackpoint.c
+++ b/test/litest-device-trackpoint.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_trackpoint_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_TRACKPOINT);
-	litest_set_current_device(d);
-}
-
 static struct input_id input_id = {
 	.bustype = 0x11,
 	.vendor = 0x2,
@@ -49,11 +43,9 @@ static int events[] = {
 	-1, -1,
 };
 
-struct litest_test_device litest_trackpoint_device = {
+TEST_DEVICE("trackpoint",
 	.type = LITEST_TRACKPOINT,
 	.features = LITEST_RELATIVE | LITEST_BUTTON | LITEST_POINTINGSTICK,
-	.shortname = "trackpoint",
-	.setup = litest_trackpoint_setup,
 	.interface = NULL,
 
 	.name = "TPPS/2 IBM TrackPoint",
@@ -61,4 +53,4 @@ struct litest_test_device litest_trackpoint_device = {
 	.absinfo = NULL,
 	.events = events,
 
-};
+)
diff --git a/test/litest-device-uclogic-tablet.c b/test/litest-device-uclogic-tablet.c
index b0393d65..3c64c29f 100644
--- a/test/litest-device-uclogic-tablet.c
+++ b/test/litest-device-uclogic-tablet.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_uclogic_tablet_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_UCLOGIC_TABLET);
-	litest_set_current_device(d);
-}
-
 static struct input_event proximity_in[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -92,15 +86,13 @@ static int events[] = {
 	-1, -1,
 };
 
-struct litest_test_device litest_uclogic_tablet_device = {
+TEST_DEVICE("uclogic-tablet",
 	.type = LITEST_UCLOGIC_TABLET,
 	.features = LITEST_TABLET,
-	.shortname = "uclogic-tablet",
-	.setup = litest_uclogic_tablet_setup,
 	.interface = &interface,
 
 	.name = "uclogic PenTablet Pen",
 	.id = &input_id,
 	.events = events,
 	.absinfo = absinfo,
-};
+)
diff --git a/test/litest-device-vmware-virtual-usb-mouse.c b/test/litest-device-vmware-virtual-usb-mouse.c
index ba2be4ec..545316c3 100644
--- a/test/litest-device-vmware-virtual-usb-mouse.c
+++ b/test/litest-device-vmware-virtual-usb-mouse.c
@@ -27,13 +27,6 @@
 #include "litest-int.h"
 #include <assert.h>
 
-static void
-litest_vmware_virtmouse_touch_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_VMWARE_VIRTMOUSE);
-	litest_set_current_device(d);
-}
-
 static void touch_down(struct litest_device *d, unsigned int slot,
 		       double x, double y)
 {
@@ -100,15 +93,13 @@ static int events[] = {
 	-1, -1,
 };
 
-struct litest_test_device litest_vmware_virtmouse_device = {
+TEST_DEVICE("vmware-virtmouse",
 	.type = LITEST_VMWARE_VIRTMOUSE,
 	.features = LITEST_WHEEL | LITEST_BUTTON | LITEST_ABSOLUTE,
-	.shortname = "vmware virtmouse",
-	.setup = litest_vmware_virtmouse_touch_setup,
 	.interface = &interface,
 
 	.name = "VMware VMware Virtual USB Mouse",
 	.id = &input_id,
 	.events = events,
 	.absinfo = absinfo,
-};
+)
diff --git a/test/litest-device-wacom-bamboo-16fg-pen.c b/test/litest-device-wacom-bamboo-16fg-pen.c
index 9e77c6f9..3569add9 100644
--- a/test/litest-device-wacom-bamboo-16fg-pen.c
+++ b/test/litest-device-wacom-bamboo-16fg-pen.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_wacom_bamboo_tablet_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_WACOM_BAMBOO);
-	litest_set_current_device(d);
-}
-
 static struct input_event proximity_in[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -104,15 +98,13 @@ static int events[] = {
 	-1, -1,
 };
 
-struct litest_test_device litest_wacom_bamboo_tablet_device = {
+TEST_DEVICE("wacom-bamboo-tablet",
 	.type = LITEST_WACOM_BAMBOO,
 	.features = LITEST_TABLET | LITEST_DISTANCE,
-	.shortname = "wacom-bamboo-tablet",
-	.setup = litest_wacom_bamboo_tablet_setup,
 	.interface = &interface,
 
 	.name = "Wacom Bamboo 16FG 4x5 Pen",
 	.id = &input_id,
 	.events = events,
 	.absinfo = absinfo,
-};
+)
diff --git a/test/litest-device-wacom-cintiq-12wx-pen.c b/test/litest-device-wacom-cintiq-12wx-pen.c
index c6a9f4c0..2bc74a89 100644
--- a/test/litest-device-wacom-cintiq-12wx-pen.c
+++ b/test/litest-device-wacom-cintiq-12wx-pen.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_wacom_cintiq_tablet_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_WACOM_CINTIQ);
-	litest_set_current_device(d);
-}
-
 static struct input_event proximity_in[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -143,15 +137,13 @@ static int events[] = {
 	-1, -1,
 };
 
-struct litest_test_device litest_wacom_cintiq_tablet_device = {
+TEST_DEVICE("wacom-cintiq-tablet",
 	.type = LITEST_WACOM_CINTIQ,
 	.features = LITEST_TABLET | LITEST_DISTANCE | LITEST_TOOL_SERIAL | LITEST_TILT,
-	.shortname = "wacom-cintiq-tablet",
-	.setup = litest_wacom_cintiq_tablet_setup,
 	.interface = &interface,
 
 	.name = "Wacom Cintiq 12WX",
 	.id = &input_id,
 	.events = events,
 	.absinfo = absinfo,
-};
+)
diff --git a/test/litest-device-wacom-cintiq-13hdt-finger.c b/test/litest-device-wacom-cintiq-13hdt-finger.c
index a831babc..c1c7737d 100644
--- a/test/litest-device-wacom-cintiq-13hdt-finger.c
+++ b/test/litest-device-wacom-cintiq-13hdt-finger.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_wacom_cintiq_tablet_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_WACOM_CINTIQ_13HDT_FINGER);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -96,11 +90,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"rule_end\"";
 
-struct litest_test_device litest_wacom_cintiq_13hdt_finger_device = {
+TEST_DEVICE("wacom-cintiq-13hdt-finger",
 	.type = LITEST_WACOM_CINTIQ_13HDT_FINGER,
 	.features = LITEST_TOUCH,
-	.shortname = "wacom-cintiq-13hdt-finger",
-	.setup = litest_wacom_cintiq_tablet_setup,
 	.interface = &interface,
 
 	.name = "Wacom Cintiq 13 HD touch Finger",
@@ -108,4 +100,4 @@ struct litest_test_device litest_wacom_cintiq_13hdt_finger_device = {
 	.events = events,
 	.absinfo = absinfo,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-wacom-cintiq-13hdt-pad.c b/test/litest-device-wacom-cintiq-13hdt-pad.c
index c0681088..f3fae269 100644
--- a/test/litest-device-wacom-cintiq-13hdt-pad.c
+++ b/test/litest-device-wacom-cintiq-13hdt-pad.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_wacom_cintiq_pad_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_WACOM_CINTIQ_13HDT_PAD);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = -1, .code = -1 },
 };
@@ -106,11 +100,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"pad_end\"";
 
-struct litest_test_device litest_wacom_cintiq_13hdt_pad_device = {
+TEST_DEVICE("wacom-cintiq-13hdt-pad",
 	.type = LITEST_WACOM_CINTIQ_13HDT_PAD,
 	.features = LITEST_TABLET_PAD | LITEST_RING,
-	.shortname = "wacom-cintiq-13hdt-pad",
-	.setup = litest_wacom_cintiq_pad_setup,
 	.interface = &interface,
 
 	.name = "Wacom Cintiq 13 HD touch Pad",
@@ -118,4 +110,4 @@ struct litest_test_device litest_wacom_cintiq_13hdt_pad_device = {
 	.events = events,
 	.absinfo = absinfo,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-wacom-cintiq-13hdt-pen.c b/test/litest-device-wacom-cintiq-13hdt-pen.c
index 35ffe5e5..1129ca5f 100644
--- a/test/litest-device-wacom-cintiq-13hdt-pen.c
+++ b/test/litest-device-wacom-cintiq-13hdt-pen.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_wacom_cintiq_tablet_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_WACOM_CINTIQ_13HDT_PEN);
-	litest_set_current_device(d);
-}
-
 static struct input_event proximity_in[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -141,11 +135,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"rule_end\"";
 
-struct litest_test_device litest_wacom_cintiq_13hdt_pen_device = {
+TEST_DEVICE("wacom-cintiq-13hdt-pen-tablet",
 	.type = LITEST_WACOM_CINTIQ_13HDT_PEN,
 	.features = LITEST_TABLET | LITEST_DISTANCE | LITEST_TOOL_SERIAL | LITEST_TILT,
-	.shortname = "wacom-cintiq-13hdt-pen-tablet",
-	.setup = litest_wacom_cintiq_tablet_setup,
 	.interface = &interface,
 
 	.name = "Wacom Cintiq 13 HD touch Pen",
@@ -153,4 +145,4 @@ struct litest_test_device litest_wacom_cintiq_13hdt_pen_device = {
 	.events = events,
 	.absinfo = absinfo,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-wacom-cintiq-24hd-pen.c b/test/litest-device-wacom-cintiq-24hd-pen.c
index 6a41d85f..0aaa9ac8 100644
--- a/test/litest-device-wacom-cintiq-24hd-pen.c
+++ b/test/litest-device-wacom-cintiq-24hd-pen.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_wacom_cintiq_tablet_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_WACOM_CINTIQ_24HD);
-	litest_set_current_device(d);
-}
-
 static struct input_event proximity_in[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -132,15 +126,13 @@ static int events[] = {
 	-1, -1,
 };
 
-struct litest_test_device litest_wacom_cintiq_24hd_device = {
+TEST_DEVICE("wacom-cintiq-24hd-tablet",
 	.type = LITEST_WACOM_CINTIQ_24HD,
 	.features = LITEST_TABLET | LITEST_DISTANCE | LITEST_TOOL_SERIAL | LITEST_TILT,
-	.shortname = "wacom-cintiq-24hd-tablet",
-	.setup = litest_wacom_cintiq_tablet_setup,
 	.interface = &interface,
 
 	.name = "Wacom Cintiq 24 HD Pen",
 	.id = &input_id,
 	.events = events,
 	.absinfo = absinfo,
-};
+)
diff --git a/test/litest-device-wacom-cintiq-24hdt-pad.c b/test/litest-device-wacom-cintiq-24hdt-pad.c
index 4e655aee..06c6b864 100644
--- a/test/litest-device-wacom-cintiq-24hdt-pad.c
+++ b/test/litest-device-wacom-cintiq-24hdt-pad.c
@@ -31,15 +31,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_wacom_cintiq_pad_setup(void)
-{
-	struct litest_device *d;
-
-	d = litest_create_device(LITEST_WACOM_CINTIQ_24HDT_PAD);
-
-	litest_set_current_device(d);
-}
-
 static void
 litest_wacom_cintiq_pad_teardown(void)
 {
@@ -131,11 +122,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"pad_end\"";
 
-struct litest_test_device litest_wacom_cintiq_24hdt_pad_device = {
+TEST_DEVICE("wacom-cintiq-24hdt-pad",
 	.type = LITEST_WACOM_CINTIQ_24HDT_PAD,
 	.features = LITEST_TABLET_PAD | LITEST_RING,
-	.shortname = "wacom-cintiq-24hdt-pad",
-	.setup = litest_wacom_cintiq_pad_setup,
 	.teardown = litest_wacom_cintiq_pad_teardown,
 	.interface = &interface,
 
@@ -144,4 +133,4 @@ struct litest_test_device litest_wacom_cintiq_24hdt_pad_device = {
 	.events = events,
 	.absinfo = absinfo,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-wacom-ekr.c b/test/litest-device-wacom-ekr.c
index 20fe6efa..50afa856 100644
--- a/test/litest-device-wacom-ekr.c
+++ b/test/litest-device-wacom-ekr.c
@@ -26,13 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void
-litest_wacom_ekr_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_WACOM_EKR);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = -1, .code = -1 },
 };
@@ -116,11 +109,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"pad_end\"";
 
-struct litest_test_device litest_wacom_ekr_device = {
+TEST_DEVICE("wacom-ekr",
 	.type = LITEST_WACOM_EKR,
 	.features = LITEST_TABLET_PAD | LITEST_RING,
-	.shortname = "wacom-ekr",
-	.setup = litest_wacom_ekr_setup,
 	.interface = &interface,
 
 	.name = "Wacom Express Key Remote Pad",
@@ -128,4 +119,4 @@ struct litest_test_device litest_wacom_ekr_device = {
 	.events = events,
 	.absinfo = absinfo,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-wacom-hid4800-pen.c b/test/litest-device-wacom-hid4800-pen.c
index 9a6f4481..3dbe7681 100644
--- a/test/litest-device-wacom-hid4800-pen.c
+++ b/test/litest-device-wacom-hid4800-pen.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_wacom_hid4800_tablet_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_WACOM_HID4800_PEN);
-	litest_set_current_device(d);
-}
-
 static struct input_event proximity_in[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -104,15 +98,13 @@ static int events[] = {
 	-1, -1,
 };
 
-struct litest_test_device litest_wacom_hid4800_tablet_device = {
+TEST_DEVICE("wacom-hid4800-tablet",
 	.type = LITEST_WACOM_HID4800_PEN,
 	.features = LITEST_TABLET,
-	.shortname = "wacom-hid4800-tablet",
-	.setup = litest_wacom_hid4800_tablet_setup,
 	.interface = &interface,
 
 	.name = "Wacom HID 4800 Pen",
 	.id = &input_id,
 	.events = events,
 	.absinfo = absinfo,
-};
+)
diff --git a/test/litest-device-wacom-intuos3-pad.c b/test/litest-device-wacom-intuos3-pad.c
index d971c1b1..5e3569fa 100644
--- a/test/litest-device-wacom-intuos3-pad.c
+++ b/test/litest-device-wacom-intuos3-pad.c
@@ -26,13 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void
-litest_wacom_intuos3_pad_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_WACOM_INTUOS3_PAD);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = -1, .code = -1 },
 };
@@ -101,11 +94,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"pad_end\"";
 
-struct litest_test_device litest_wacom_intuos3_pad_device = {
+TEST_DEVICE("wacom-intuos3-pad",
 	.type = LITEST_WACOM_INTUOS3_PAD,
 	.features = LITEST_TABLET_PAD | LITEST_STRIP,
-	.shortname = "wacom-intuos3-pad",
-	.setup = litest_wacom_intuos3_pad_setup,
 	.interface = &interface,
 
 	.name = "Wacom Intuos3 4x6 Pad",
@@ -113,4 +104,4 @@ struct litest_test_device litest_wacom_intuos3_pad_device = {
 	.events = events,
 	.absinfo = absinfo,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-wacom-intuos5-finger.c b/test/litest-device-wacom-intuos5-finger.c
index 5e237e46..7431b8d3 100644
--- a/test/litest-device-wacom-intuos5-finger.c
+++ b/test/litest-device-wacom-intuos5-finger.c
@@ -26,13 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void
-litest_wacom_finger_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_WACOM_FINGER);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -97,11 +90,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"rule_end\"";
 
-struct litest_test_device litest_wacom_finger_device = {
+TEST_DEVICE("wacom-finger",
 	.type = LITEST_WACOM_FINGER,
 	.features = LITEST_TOUCHPAD,
-	.shortname = "wacom-finger",
-	.setup = litest_wacom_finger_setup,
 	.interface = &interface,
 
 	.name = "Wacom Intuos5 touch M Finger",
@@ -109,4 +100,4 @@ struct litest_test_device litest_wacom_finger_device = {
 	.events = events,
 	.absinfo = absinfo,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-wacom-intuos5-pad.c b/test/litest-device-wacom-intuos5-pad.c
index 0349dbe1..4711409e 100644
--- a/test/litest-device-wacom-intuos5-pad.c
+++ b/test/litest-device-wacom-intuos5-pad.c
@@ -26,13 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void
-litest_wacom_intuos5_pad_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_WACOM_INTUOS5_PAD);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = -1, .code = -1 },
 };
@@ -107,11 +100,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"pad_end\"";
 
-struct litest_test_device litest_wacom_intuos5_pad_device = {
+TEST_DEVICE("wacom-pad",
 	.type = LITEST_WACOM_INTUOS5_PAD,
 	.features = LITEST_TABLET_PAD | LITEST_RING,
-	.shortname = "wacom-pad",
-	.setup = litest_wacom_intuos5_pad_setup,
 	.interface = &interface,
 
 	.name = "Wacom Intuos5 touch M Pad",
@@ -119,4 +110,4 @@ struct litest_test_device litest_wacom_intuos5_pad_device = {
 	.events = events,
 	.absinfo = absinfo,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-wacom-intuos5-pen.c b/test/litest-device-wacom-intuos5-pen.c
index c1d01c33..3d834322 100644
--- a/test/litest-device-wacom-intuos5-pen.c
+++ b/test/litest-device-wacom-intuos5-pen.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_wacom_intuos_tablet_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_WACOM_INTUOS);
-	litest_set_current_device(d);
-}
-
 static struct input_event proximity_in[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -157,11 +151,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"rule_end\"";
 
-struct litest_test_device litest_wacom_intuos_tablet_device = {
+TEST_DEVICE("wacom-intuos-tablet",
 	.type = LITEST_WACOM_INTUOS,
 	.features = LITEST_TABLET | LITEST_DISTANCE | LITEST_TOOL_SERIAL | LITEST_TILT,
-	.shortname = "wacom-intuos-tablet",
-	.setup = litest_wacom_intuos_tablet_setup,
 	.interface = &interface,
 
 	.name = "Wacom Intuos5 touch M Pen",
@@ -169,4 +161,4 @@ struct litest_test_device litest_wacom_intuos_tablet_device = {
 	.events = events,
 	.absinfo = absinfo,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-wacom-isdv4-e6-finger.c b/test/litest-device-wacom-isdv4-e6-finger.c
index fc16c619..68cd1fe9 100644
--- a/test/litest-device-wacom-isdv4-e6-finger.c
+++ b/test/litest-device-wacom-isdv4-e6-finger.c
@@ -26,13 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void
-litest_wacom_touch_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_WACOM_TOUCH);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -83,15 +76,13 @@ static int events[] = {
 	-1, -1,
 };
 
-struct litest_test_device litest_wacom_touch_device = {
+TEST_DEVICE("wacom-touch",
 	.type = LITEST_WACOM_TOUCH,
 	.features = LITEST_TOUCH,
-	.shortname = "wacom-touch",
-	.setup = litest_wacom_touch_setup,
 	.interface = &interface,
 
 	.name = "Wacom ISDv4 E6 Finger",
 	.id = &input_id,
 	.events = events,
 	.absinfo = absinfo,
-};
+)
diff --git a/test/litest-device-wacom-isdv4-e6-pen.c b/test/litest-device-wacom-isdv4-e6-pen.c
index cc3fe4e2..cfa40c32 100644
--- a/test/litest-device-wacom-isdv4-e6-pen.c
+++ b/test/litest-device-wacom-isdv4-e6-pen.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_wacom_isdv4_tablet_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_WACOM_ISDV4);
-	litest_set_current_device(d);
-}
-
 static struct input_event proximity_in[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -97,15 +91,13 @@ static int events[] = {
 	-1, -1,
 };
 
-struct litest_test_device litest_wacom_isdv4_tablet_device = {
+TEST_DEVICE("wacom-isdv4-tablet",
 	.type = LITEST_WACOM_ISDV4,
 	.features = LITEST_TABLET,
-	.shortname = "wacom-isdv4-tablet",
-	.setup = litest_wacom_isdv4_tablet_setup,
 	.interface = &interface,
 
 	.name = "Wacom ISDv4 E6 Pen",
 	.id = &input_id,
 	.events = events,
 	.absinfo = absinfo,
-};
+)
diff --git a/test/litest-device-wacom-mobilestudio-pro-pad.c b/test/litest-device-wacom-mobilestudio-pro-pad.c
index 3b594256..2571e7d9 100644
--- a/test/litest-device-wacom-mobilestudio-pro-pad.c
+++ b/test/litest-device-wacom-mobilestudio-pro-pad.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_wacom_mobilestudio_pad_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_WACOM_MOBILESTUDIO_PRO_16_PAD);
-	litest_set_current_device(d);
-}
-
 static struct input_event down[] = {
 	{ .type = -1, .code = -1 },
 };
@@ -111,11 +105,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"pad_end\"";
 
-struct litest_test_device litest_wacom_mobilestudio_13hdt_pad_device = {
+TEST_DEVICE("wacom-mobilestudio-pro16-pad",
 	.type = LITEST_WACOM_MOBILESTUDIO_PRO_16_PAD,
 	.features = LITEST_TABLET_PAD | LITEST_RING,
-	.shortname = "wacom-mobilestudio-pro16-pad",
-	.setup = litest_wacom_mobilestudio_pad_setup,
 	.interface = &interface,
 
 	.name = "Wacom MobileStudio Pro 16 Pad",
@@ -123,4 +115,4 @@ struct litest_test_device litest_wacom_mobilestudio_13hdt_pad_device = {
 	.events = events,
 	.absinfo = absinfo,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-waltop-tablet.c b/test/litest-device-waltop-tablet.c
index a3d85edd..96052e27 100644
--- a/test/litest-device-waltop-tablet.c
+++ b/test/litest-device-waltop-tablet.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_waltop_tablet_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_WALTOP);
-	litest_set_current_device(d);
-}
-
 static struct input_event proximity_in[] = {
 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
@@ -236,11 +230,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"waltop_end\"";
 
-struct litest_test_device litest_waltop_tablet_device = {
+TEST_DEVICE("waltop-tablet",
 	.type = LITEST_WALTOP,
 	.features = LITEST_TABLET | LITEST_WHEEL | LITEST_TILT,
-	.shortname = "waltop-tablet",
-	.setup = litest_waltop_tablet_setup,
 	.interface = &interface,
 
 	.name = "         WALTOP     Batteryless Tablet ", /* sic */
@@ -248,4 +240,4 @@ struct litest_test_device litest_waltop_tablet_device = {
 	.events = events,
 	.absinfo = absinfo,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-wheel-only.c b/test/litest-device-wheel-only.c
index fe6ca89c..574b4856 100644
--- a/test/litest-device-wheel-only.c
+++ b/test/litest-device-wheel-only.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_wheel_only_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_WHEEL_ONLY);
-	litest_set_current_device(d);
-}
-
 static struct input_id input_id = {
 	.bustype = 0x3,
 	.vendor = 0x1,
@@ -52,11 +46,9 @@ static const char udev_rule[] =
 "\n"
 "LABEL=\"wheel_only_end\"";
 
-struct litest_test_device litest_wheel_only_device = {
+TEST_DEVICE("wheel-only",
 	.type = LITEST_WHEEL_ONLY,
 	.features = LITEST_WHEEL,
-	.shortname = "wheel only",
-	.setup = litest_wheel_only_setup,
 	.interface = NULL,
 
 	.name = "wheel only device",
@@ -64,4 +56,4 @@ struct litest_test_device litest_wheel_only_device = {
 	.absinfo = NULL,
 	.events = events,
 	.udev_rule = udev_rule,
-};
+)
diff --git a/test/litest-device-xen-virtual-pointer.c b/test/litest-device-xen-virtual-pointer.c
index a4c20445..44d30131 100644
--- a/test/litest-device-xen-virtual-pointer.c
+++ b/test/litest-device-xen-virtual-pointer.c
@@ -27,13 +27,6 @@
 #include "litest-int.h"
 #include <assert.h>
 
-static void
-litest_xen_virtual_pointer_touch_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_XEN_VIRTUAL_POINTER);
-	litest_set_current_device(d);
-}
-
 static void touch_down(struct litest_device *d, unsigned int slot,
 		       double x, double y)
 {
@@ -91,15 +84,13 @@ static int events[] = {
 	-1, -1,
 };
 
-struct litest_test_device litest_xen_virtual_pointer_device = {
+TEST_DEVICE("xen-pointer",
 	.type = LITEST_XEN_VIRTUAL_POINTER,
 	.features = LITEST_WHEEL | LITEST_BUTTON | LITEST_ABSOLUTE,
-	.shortname = "xen pointer",
-	.setup = litest_xen_virtual_pointer_touch_setup,
 	.interface = &interface,
 
 	.name = "Xen Virtual Pointer",
 	.id = &input_id,
 	.events = events,
 	.absinfo = absinfo,
-};
+)
diff --git a/test/litest-device-yubikey.c b/test/litest-device-yubikey.c
index 08e47b89..78b22790 100644
--- a/test/litest-device-yubikey.c
+++ b/test/litest-device-yubikey.c
@@ -26,12 +26,6 @@
 #include "litest.h"
 #include "litest-int.h"
 
-static void litest_yubikey_setup(void)
-{
-	struct litest_device *d = litest_create_device(LITEST_YUBIKEY);
-	litest_set_current_device(d);
-}
-
 static struct input_id input_id = {
 	.bustype = 0x3,
 	.vendor = 0x1050,
@@ -153,15 +147,13 @@ static int events[] = {
 	-1, -1,
 };
 
-struct litest_test_device litest_yubikey_device = {
+TEST_DEVICE("yubikey",
 	.type = LITEST_YUBIKEY,
 	.features = LITEST_KEYS,
-	.shortname = "yubikey",
-	.setup = litest_yubikey_setup,
 	.interface = NULL,
 
 	.name = "Yubico Yubico Yubikey II",
 	.id = &input_id,
 	.events = events,
 	.absinfo = NULL,
-};
+)
diff --git a/test/litest.c b/test/litest.c
index 479b3d6a..be8a37c1 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -351,146 +351,7 @@ void litest_generic_device_teardown(void)
 	current_device = NULL;
 }
 
-extern struct litest_test_device litest_keyboard_device;
-extern struct litest_test_device litest_synaptics_clickpad_device;
-extern struct litest_test_device litest_synaptics_touchpad_device;
-extern struct litest_test_device litest_synaptics_t440_device;
-extern struct litest_test_device litest_trackpoint_device;
-extern struct litest_test_device litest_bcm5974_device;
-extern struct litest_test_device litest_mouse_device;
-extern struct litest_test_device litest_wacom_touch_device;
-extern struct litest_test_device litest_wacom_bamboo_tablet_device;
-extern struct litest_test_device litest_wacom_cintiq_tablet_device;
-extern struct litest_test_device litest_wacom_intuos_tablet_device;
-extern struct litest_test_device litest_wacom_isdv4_tablet_device;
-extern struct litest_test_device litest_alps_device;
-extern struct litest_test_device litest_generic_singletouch_device;
-extern struct litest_test_device litest_qemu_tablet_device;
-extern struct litest_test_device litest_xen_virtual_pointer_device;
-extern struct litest_test_device litest_vmware_virtmouse_device;
-extern struct litest_test_device litest_synaptics_hover_device;
-extern struct litest_test_device litest_synaptics_carbon3rd_device;
-extern struct litest_test_device litest_protocol_a_screen;
-extern struct litest_test_device litest_wacom_finger_device;
-extern struct litest_test_device litest_keyboard_blackwidow_device;
-extern struct litest_test_device litest_wheel_only_device;
-extern struct litest_test_device litest_mouse_roccat_device;
-extern struct litest_test_device litest_ms_surface_cover_device;
-extern struct litest_test_device litest_logitech_trackball_device;
-extern struct litest_test_device litest_atmel_hover_device;
-extern struct litest_test_device litest_alps_dualpoint_device;
-extern struct litest_test_device litest_mouse_low_dpi_device;
-extern struct litest_test_device litest_generic_multitouch_screen_device;
-extern struct litest_test_device litest_nexus4_device;
-extern struct litest_test_device litest_magicpad_device;
-extern struct litest_test_device litest_elantech_touchpad_device;
-extern struct litest_test_device litest_mouse_gladius_device;
-extern struct litest_test_device litest_mouse_wheel_click_angle_device;
-extern struct litest_test_device litest_apple_keyboard_device;
-extern struct litest_test_device litest_anker_mouse_kbd_device;
-extern struct litest_test_device litest_waltop_tablet_device;
-extern struct litest_test_device litest_huion_tablet_device;
-extern struct litest_test_device litest_cyborg_rat_device;
-extern struct litest_test_device litest_yubikey_device;
-extern struct litest_test_device litest_synaptics_i2c_device;
-extern struct litest_test_device litest_wacom_cintiq_24hd_device;
-extern struct litest_test_device litest_multitouch_fuzz_screen_device;
-extern struct litest_test_device litest_wacom_intuos3_pad_device;
-extern struct litest_test_device litest_wacom_intuos5_pad_device;
-extern struct litest_test_device litest_keyboard_all_codes_device;
-extern struct litest_test_device litest_magicmouse_device;
-extern struct litest_test_device litest_wacom_ekr_device;
-extern struct litest_test_device litest_wacom_cintiq_24hdt_pad_device;
-extern struct litest_test_device litest_wacom_cintiq_13hdt_finger_device;
-extern struct litest_test_device litest_wacom_cintiq_13hdt_pen_device;
-extern struct litest_test_device litest_wacom_cintiq_13hdt_pad_device;
-extern struct litest_test_device litest_wacom_hid4800_tablet_device;
-extern struct litest_test_device litest_mouse_wheel_click_count_device;
-extern struct litest_test_device litest_calibrated_touchscreen_device;
-extern struct litest_test_device litest_acer_hawaii_keyboard_device;
-extern struct litest_test_device litest_acer_hawaii_touchpad_device;
-extern struct litest_test_device litest_synaptics_rmi4_device;
-extern struct litest_test_device litest_mouse_wheel_tilt_device;
-extern struct litest_test_device litest_lid_switch_device;
-extern struct litest_test_device litest_lid_switch_surface3_device;
-extern struct litest_test_device litest_appletouch_device;
-extern struct litest_test_device litest_gpio_keys_device;
-extern struct litest_test_device litest_ignored_mouse_device;
-extern struct litest_test_device litest_wacom_mobilestudio_13hdt_pad_device;
-extern struct litest_test_device litest_thinkpad_extrabuttons_device;
-extern struct litest_test_device litest_uclogic_tablet_device;
-
-struct litest_test_device* devices[] = {
-	&litest_synaptics_clickpad_device,
-	&litest_synaptics_touchpad_device,
-	&litest_synaptics_t440_device,
-	&litest_keyboard_device,
-	&litest_trackpoint_device,
-	&litest_bcm5974_device,
-	&litest_mouse_device,
-	&litest_wacom_touch_device,
-	&litest_wacom_bamboo_tablet_device,
-	&litest_wacom_cintiq_tablet_device,
-	&litest_wacom_intuos_tablet_device,
-	&litest_wacom_isdv4_tablet_device,
-	&litest_alps_device,
-	&litest_generic_singletouch_device,
-	&litest_qemu_tablet_device,
-	&litest_xen_virtual_pointer_device,
-	&litest_vmware_virtmouse_device,
-	&litest_synaptics_hover_device,
-	&litest_synaptics_carbon3rd_device,
-	&litest_protocol_a_screen,
-	&litest_wacom_finger_device,
-	&litest_keyboard_blackwidow_device,
-	&litest_wheel_only_device,
-	&litest_mouse_roccat_device,
-	&litest_ms_surface_cover_device,
-	&litest_logitech_trackball_device,
-	&litest_atmel_hover_device,
-	&litest_alps_dualpoint_device,
-	&litest_mouse_low_dpi_device,
-	&litest_generic_multitouch_screen_device,
-	&litest_nexus4_device,
-	&litest_magicpad_device,
-	&litest_elantech_touchpad_device,
-	&litest_mouse_gladius_device,
-	&litest_mouse_wheel_click_angle_device,
-	&litest_apple_keyboard_device,
-	&litest_anker_mouse_kbd_device,
-	&litest_waltop_tablet_device,
-	&litest_huion_tablet_device,
-	&litest_cyborg_rat_device,
-	&litest_yubikey_device,
-	&litest_synaptics_i2c_device,
-	&litest_wacom_cintiq_24hd_device,
-	&litest_multitouch_fuzz_screen_device,
-	&litest_wacom_intuos3_pad_device,
-	&litest_wacom_intuos5_pad_device,
-	&litest_keyboard_all_codes_device,
-	&litest_magicmouse_device,
-	&litest_wacom_ekr_device,
-	&litest_wacom_cintiq_24hdt_pad_device,
-	&litest_wacom_cintiq_13hdt_finger_device,
-	&litest_wacom_cintiq_13hdt_pen_device,
-	&litest_wacom_cintiq_13hdt_pad_device,
-	&litest_wacom_hid4800_tablet_device,
-	&litest_mouse_wheel_click_count_device,
-	&litest_calibrated_touchscreen_device,
-	&litest_acer_hawaii_keyboard_device,
-	&litest_acer_hawaii_touchpad_device,
-	&litest_synaptics_rmi4_device,
-	&litest_mouse_wheel_tilt_device,
-	&litest_lid_switch_device,
-	&litest_lid_switch_surface3_device,
-	&litest_appletouch_device,
-	&litest_gpio_keys_device,
-	&litest_ignored_mouse_device,
-	&litest_wacom_mobilestudio_13hdt_pad_device,
-	&litest_thinkpad_extrabuttons_device,
-	&litest_uclogic_tablet_device,
-	NULL,
-};
+struct litest_test_device** devices;
 
 static struct list all_tests;
 
@@ -3663,12 +3524,39 @@ litest_list_tests(struct list *tests)
 	}
 }
 
+extern const struct test_device __start_test_section, __stop_test_section;
+
+static void
+litest_init_test_devices(void)
+{
+	const struct test_device *t;
+	size_t ndevices = 0;
+
+	for (ndevices = 1,
+	     t = &__start_test_section;
+	     t < &__stop_test_section;
+	     ndevices++, t++)
+		; /* loopdeeloop */
+
+	ndevices++;
+	devices = zalloc(ndevices * sizeof(*devices));
+
+	for (ndevices = 0,
+	     t = &__start_test_section;
+	     t < &__stop_test_section;
+	     t++, ndevices++) {
+		devices[ndevices] = t->device;
+	}
+}
+
 int
 main(int argc, char **argv)
 {
 	const struct rlimit corelimit = { 0, 0 };
 	enum litest_mode mode;
 
+	litest_init_test_devices();
+
 	list_init(&all_tests);
 
 	setenv("CK_DEFAULT_TIMEOUT", "30", 0);
diff --git a/test/litest.h b/test/litest.h
index 0d133f35..d25a9a58 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -35,6 +35,30 @@
 
 #include "libinput-util.h"
 
+struct test_device {
+	const char *name;
+	struct litest_test_device *device;
+} __attribute__((aligned(16)));
+
+#define TEST_DEVICE(name, ...) \
+	static struct litest_test_device _device; \
+	\
+	static void _setup(void) { \
+		struct litest_device *d = litest_create_device(_device.type); \
+		litest_set_current_device(d); \
+	} \
+	\
+	static const struct test_device _test_device \
+		__attribute__ ((used)) \
+		__attribute__ ((section ("test_section"))) = { \
+		name, &_device \
+	}; \
+	static struct litest_test_device _device = { \
+		.setup = _setup, \
+		.shortname = name, \
+		__VA_ARGS__ \
+	};
+
 extern void litest_setup_tests_udev(void);
 extern void litest_setup_tests_path(void);
 extern void litest_setup_tests_pointer(void);
-- 
2.13.5



More information about the wayland-devel mailing list