[PATCH v2 libinput 14/14] Hook up list-quirks --validate for the test suite
Peter Hutterer
peter.hutterer at who-t.net
Fri Jun 8 06:00:21 UTC 2018
All the tests fill fail anyway if the validation fails but this is a quick way
to fail everything early.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
meson.build | 18 +++++++++++-------
tools/libinput-list-quirks.c | 24 ++++++++++++++++++++----
tools/libinput-list-quirks.man | 10 +++++++++-
3 files changed, 40 insertions(+), 12 deletions(-)
diff --git a/meson.build b/meson.build
index 5e4db287..8ac75cc7 100644
--- a/meson.build
+++ b/meson.build
@@ -489,13 +489,17 @@ configure_file(input : 'tools/libinput-debug-events.man',
)
libinput_list_quirks_sources = [ 'tools/libinput-list-quirks.c' ]
-executable('libinput-list-quirks',
- libinput_list_quirks_sources,
- dependencies : [dep_libquirks, dep_libinput],
- include_directories : [includes_src, includes_include],
- install_dir : libinput_tool_path,
- install : true
- )
+libinput_list_quirks = executable('libinput-list-quirks',
+ libinput_list_quirks_sources,
+ dependencies : [dep_libquirks, dep_libinput],
+ include_directories : [includes_src, includes_include],
+ install_dir : libinput_tool_path,
+ install : true
+ )
+test('validate-quirks',
+ libinput_list_quirks,
+ args: ['--validate-only', '--data-dir=@0@'.format(join_paths(meson.source_root(), 'data'))]
+ )
configure_file(input : 'tools/libinput-list-quirks.man',
output : 'libinput-list-quirks.1',
diff --git a/tools/libinput-list-quirks.c b/tools/libinput-list-quirks.c
index 73e84895..009f7d64 100644
--- a/tools/libinput-list-quirks.c
+++ b/tools/libinput-list-quirks.c
@@ -136,21 +136,27 @@ list_device_quirks(struct quirks_context *ctx, struct udev_device *device)
static void
usage(void)
{
- printf("Usage: %s [--data-dir /path/to/data/dir] /dev/input/event0\n",
+ printf("Usage:\n"
+ " %s [--data-dir /path/to/data/dir] /dev/input/event0\n"
+ " Print the quirks for the given device\n"
+ "\n",
+ program_invocation_short_name);
+ printf(" %s [--data-dir /path/to/data/dir] --validate-only\n"
+ " Validate the database\n",
program_invocation_short_name);
- printf("Note: this tool also takes a syspath\n");
}
int
main(int argc, char **argv)
{
- struct udev *udev;
+ struct udev *udev = NULL;
struct udev_device *device = NULL;
const char *path;
const char *data_path = NULL,
*override_file = NULL;
int rc = 1;
struct quirks_context *quirks;
+ bool validate = false;
while (1) {
int c;
@@ -158,11 +164,13 @@ main(int argc, char **argv)
enum {
OPT_VERBOSE,
OPT_DATADIR,
+ OPT_VALIDATE,
};
static struct option opts[] = {
{ "help", no_argument, 0, 'h' },
{ "verbose", no_argument, 0, OPT_VERBOSE },
{ "data-dir", required_argument, 0, OPT_DATADIR },
+ { "validate-only", no_argument, 0, OPT_VALIDATE },
{ 0, 0, 0, 0}
};
@@ -184,13 +192,16 @@ main(int argc, char **argv)
case OPT_DATADIR:
data_path = optarg;
break;
+ case OPT_VALIDATE:
+ validate = true;
+ break;
default:
usage();
return 1;
}
}
- if (optind >= argc) {
+ if (optind >= argc && !validate) {
usage();
return 1;
}
@@ -214,6 +225,11 @@ main(int argc, char **argv)
return 1;
}
+ if (validate) {
+ rc = 0;
+ goto out;
+ }
+
udev = udev_new();
path = argv[optind];
if (strneq(path, "/sys/", 5)) {
diff --git a/tools/libinput-list-quirks.man b/tools/libinput-list-quirks.man
index 9d90847e..e18495f3 100644
--- a/tools/libinput-list-quirks.man
+++ b/tools/libinput-list-quirks.man
@@ -2,7 +2,11 @@
.SH NAME
libinput\-list\-quirks \- quirk debug helper for libinput
.SH SYNOPSIS
-.B libinput list\-quirks [\-\-help] [\-\-data\-dir /path/to/dir] [\-\-verbose\fB] \fI/dev/input/event0\fB
+.B libinput list\-quirks [\-\-data\-dir /path/to/dir] [\-\-verbose\fB] \fI/dev/input/event0\fB
+.br
+.B libinput list\-quirks [\-\-data\-dir /path/to/dir] [\-\-verbose\fB] \-\-validate\-only
+.br
+.B libinput list\-quirks [\-\-help]
.SH DESCRIPTION
.PP
The
@@ -20,6 +24,10 @@ Use the given directory as data directory for quirks files.
.B \-\-help
Print help
.TP 8
+.B \-\-validate\-only
+Only validate that the quirks files can be parsed. When this option is
+given, no device file should be supplied.
+.TP 8
.B \-\-verbose
Use verbose output, useful for debugging.
.SH LIBINPUT
--
2.14.4
More information about the wayland-devel
mailing list