summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2019-03-22 15:44:32 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2019-03-22 16:23:17 +1000
commit11adaadd51eb384e2931cba4768030f7020df935 (patch)
tree88221c0c79df722b56cc4a46a4722777c67b628b
parent5a041de7a6a720d78fd877d5ffd31e6b7e413a77 (diff)
test: let the device custom create method return a bool
This is so we can tell litest to create the device anyway, useful for when all we have to do in the custom create is allocate some memory. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--test/litest-device-keyboard-all-codes.c5
-rw-r--r--test/litest-int.h5
-rw-r--r--test/litest.c15
3 files changed, 16 insertions, 9 deletions
diff --git a/test/litest-device-keyboard-all-codes.c b/test/litest-device-keyboard-all-codes.c
index 268cff79..3f5d0d4a 100644
--- a/test/litest-device-keyboard-all-codes.c
+++ b/test/litest-device-keyboard-all-codes.c
@@ -28,7 +28,7 @@
#define NAME "All event codes keyboard"
-static void all_codes_create(struct litest_device *d);
+static bool all_codes_create(struct litest_device *d);
static struct input_id input_id = {
.bustype = 0x11,
@@ -48,7 +48,7 @@ TEST_DEVICE("keyboard-all-codes",
.absinfo = NULL,
)
-static void
+static bool
all_codes_create(struct litest_device *d)
{
int events[KEY_MAX * 2 + 2];
@@ -70,4 +70,5 @@ all_codes_create(struct litest_device *d)
&input_id,
NULL,
events);
+ return false;
}
diff --git a/test/litest-int.h b/test/litest-int.h
index 4de4b21f..a0f92431 100644
--- a/test/litest-int.h
+++ b/test/litest-int.h
@@ -44,8 +44,11 @@ struct litest_test_device {
* For such devices, no overrides are possible. If create is NULL,
* the information in name, id, events, absinfo is used to
* create the device instead.
+ *
+ * @return true if the device needs to be created by litest, false if
+ * the device creates itself
*/
- void (*create)(struct litest_device *d);
+ bool (*create)(struct litest_device *d);
/**
* The device name. Only used when create is NULL.
diff --git a/test/litest.c b/test/litest.c
index 06c1cbfc..6b44d45f 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -1395,6 +1395,7 @@ litest_create(enum litest_device_type which,
const char *path;
int fd, rc;
bool found = false;
+ bool create_device = true;
list_for_each(dev, &devices, node) {
if (dev->type == which) {
@@ -1411,16 +1412,18 @@ litest_create(enum litest_device_type which,
/* device has custom create method */
if (dev->create) {
- dev->create(d);
+ create_device = dev->create(d);
if (abs_override || events_override) {
litest_abort_msg("Custom create cannot be overridden");
}
- } else {
- abs = merge_absinfo(dev->absinfo, abs_override);
- events = merge_events(dev->events, events_override);
- name = name_override ? name_override : dev->name;
- id = id_override ? id_override : dev->id;
+ }
+
+ abs = merge_absinfo(dev->absinfo, abs_override);
+ events = merge_events(dev->events, events_override);
+ name = name_override ? name_override : dev->name;
+ id = id_override ? id_override : dev->id;
+ if (create_device) {
d->uinput = litest_create_uinput_device_from_description(name,
id,
abs,