static void
litest_add_tcase_for_device(struct suite *suite,
void *func,
- const struct litest_test_device *dev)
+ const struct litest_test_device *dev,
+ const struct range *range)
{
struct test *t;
const char *test_name = dev->shortname;
if (strcmp(t->name, test_name) != 0)
continue;
- tcase_add_test(t->tc, func);
+ if (range)
+ tcase_add_loop_test(t->tc,
+ func,
+ range->lower,
+ range->upper);
+ else
+ tcase_add_test(t->tc, func);
return;
}
}
static void
-litest_add_tcase_no_device(struct suite *suite, void *func)
+litest_add_tcase_no_device(struct suite *suite,
+ void *func,
+ const struct range *range)
{
struct test *t;
const char *test_name = "no device";
if (strcmp(t->name, test_name) != 0)
continue;
- tcase_add_test(t->tc, func);
+ if (range)
+ tcase_add_loop_test(t->tc, func, range->lower, range->upper);
+ else
+ tcase_add_test(t->tc, func);
return;
}
static void
litest_add_tcase(struct suite *suite, void *func,
enum litest_device_feature required,
- enum litest_device_feature excluded)
+ enum litest_device_feature excluded,
+ const struct range *range)
{
struct litest_test_device **dev = devices;
if (required == LITEST_DISABLE_DEVICE &&
excluded == LITEST_DISABLE_DEVICE) {
- litest_add_tcase_no_device(suite, func);
+ litest_add_tcase_no_device(suite, func, range);
} else if (required != LITEST_ANY || excluded != LITEST_ANY) {
while (*dev) {
if (((*dev)->features & required) == required &&
((*dev)->features & excluded) == 0)
- litest_add_tcase_for_device(suite, func, *dev);
+ litest_add_tcase_for_device(suite, func, *dev, range);
dev++;
}
} else {
while (*dev) {
- litest_add_tcase_for_device(suite, func, *dev);
+ litest_add_tcase_for_device(suite, func, *dev, range);
dev++;
}
}
litest_add(name, func, LITEST_DISABLE_DEVICE, LITEST_DISABLE_DEVICE);
}
+void
+litest_add_ranged_no_device(const char *name,
+ void *func,
+ const struct range *range)
+{
+ litest_add_ranged(name,
+ func,
+ LITEST_DISABLE_DEVICE,
+ LITEST_DISABLE_DEVICE,
+ range);
+}
+
static struct suite *
get_suite(const char *name)
{
enum litest_device_feature required,
enum litest_device_feature excluded)
{
- litest_add_tcase(get_suite(name), func, required, excluded);
+ litest_add_ranged(name, func, required, excluded, NULL);
+}
+
+void
+litest_add_ranged(const char *name,
+ void *func,
+ enum litest_device_feature required,
+ enum litest_device_feature excluded,
+ const struct range *range)
+{
+ litest_add_tcase(get_suite(name), func, required, excluded, range);
}
void
litest_add_for_device(const char *name,
void *func,
enum litest_device_type type)
+{
+ litest_add_ranged_for_device(name, func, type, NULL);
+}
+
+void
+litest_add_ranged_for_device(const char *name,
+ void *func,
+ enum litest_device_type type,
+ const struct range *range)
{
struct suite *s;
struct litest_test_device **dev = devices;
s = get_suite(name);
while (*dev) {
if ((*dev)->type == type) {
- litest_add_tcase_for_device(s, func, *dev);
+ litest_add_tcase_for_device(s, func, *dev, range);
return;
}
dev++;
char *udev_rule_file;
};
+/* A loop range, resolves to:
+ for (i = lower; i < upper; i++)
+ */
+struct range {
+ int lower; /* inclusive */
+ int upper; /* exclusive */
+};
+
struct libinput *litest_create_context(void);
void litest_disable_log_handler(struct libinput *libinput);
void litest_restore_log_handler(struct libinput *libinput);
void litest_add(const char *name, void *func,
enum litest_device_feature required_feature,
enum litest_device_feature excluded_feature);
+void litest_add_ranged(const char *name,
+ void *func,
+ enum litest_device_feature required,
+ enum litest_device_feature excluded,
+ const struct range *range);
void
litest_add_for_device(const char *name,
void *func,
enum litest_device_type type);
+void litest_add_ranged_for_device(const char *name,
+ void *func,
+ enum litest_device_type type,
+ const struct range *range);
void litest_add_no_device(const char *name, void *func);
+void litest_add_ranged_no_device(const char *name,
+ void *func,
+ const struct range *range);
int litest_run(int argc, char **argv);
struct litest_device * litest_create_device(enum litest_device_type which);