Hook up list-quirks --validate for the test suite

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@who-t.net>
This commit is contained in:
Peter Hutterer 2018-06-06 14:39:39 +10:00
parent b926497cc6
commit d0fa740ad9
3 changed files with 40 additions and 12 deletions

View file

@ -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',

View file

@ -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)) {

View file

@ -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