From d1cb8ad409e0da86f1656a070b6b64bf4ad77487 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 14 Aug 2018 11:16:30 +1000 Subject: [PATCH] test: add a tool to test-compile all LVO combinations from xkeyboard-config This test contains of two parts: - a simple program to convert RMLVO commandline arguments into a keymap (and print that keymap if requested). - a python script that runs through rules/evdev.xml, and tries to compile a keymap for sort-of every layout/variant/option combination. Sort-of, because we can have multiple options and it really only does one per layout(variant) combination. Same thing can be done using xkbcomp, but right now it doesn't take that as argument, it's hard-coded. This takes quite a while, installing python-tqdm is recommended to see fancy progress bars instead of just miles of dumps. Signed-off-by: Peter Hutterer --- Makefile.am | 2 + meson.build | 10 +++ test/.gitignore | 1 + test/rmlvo-to-keymap.c | 141 +++++++++++++++++++++++++++++++++++++++ test/xkeyboard-config-test.py.in | 129 +++++++++++++++++++++++++++++++++++ 5 files changed, 283 insertions(+) create mode 100644 test/rmlvo-to-keymap.c create mode 100755 test/xkeyboard-config-test.py.in diff --git a/Makefile.am b/Makefile.am index a7492d0..3f53b03 100644 --- a/Makefile.am +++ b/Makefile.am @@ -219,6 +219,7 @@ build_run_tests = \ test/compose build_only_tests = \ test/rmlvo-to-kccgst \ + test/rmlvo-to-keymap \ test/print-compiled-keymap run_only_tests = \ test/symbols-leak-test.bash @@ -240,6 +241,7 @@ test_state_LDADD = $(TESTS_LDADD) test_keyseq_LDADD = $(TESTS_LDADD) test_rulescomp_LDADD = $(TESTS_LDADD) test_rmlvo_to_kccgst_LDADD = $(TESTS_LDADD) +test_rmlvo_to_keymap_LDADD = $(TESTS_LDADD) test_print_compiled_keymap_LDADD = $(TESTS_LDADD) test_compose_LDADD = $(TESTS_LDADD) $(RT_LIBS) diff --git a/meson.build b/meson.build index 9effe29..587f3d3 100644 --- a/meson.build +++ b/meson.build @@ -390,6 +390,7 @@ executable('fuzz-compose', 'fuzz/compose/target.c', dependencies: test_dep) # Demo programs. executable('rmlvo-to-kccgst', 'test/rmlvo-to-kccgst.c', dependencies: test_dep) +executable('rmlvo-to-keymap', 'test/rmlvo-to-keymap.c', dependencies: test_dep) executable('print-compiled-keymap', 'test/print-compiled-keymap.c', dependencies: test_dep) if cc.has_header('linux/input.h') executable('interactive-evdev', 'test/interactive-evdev.c', dependencies: test_dep) @@ -426,6 +427,15 @@ You can disable the Wayland demo programs with -Denable-wayland=false.''') executable('interactive-wayland', 'test/interactive-wayland.c', xdg_shell_sources, dependencies: [test_dep, wayland_client_dep]) endif +# xkeyboard-config "verifier" +xkct_config = configuration_data() +xkct_config.set('MESON_BUILD_ROOT', meson.build_root()) +xkct_config.set('XKB_CONFIG_ROOT', XKBCONFIGROOT) +configure_file(input: 'test/xkeyboard-config-test.py.in', + output: 'xkeyboard-config-test', + configuration: xkct_config, + install: false) + # Benchmarks. libxkbcommon_bench_internal = static_library( diff --git a/test/.gitignore b/test/.gitignore index 1be56ad..def76f0 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -13,6 +13,7 @@ keyseq log interactive-evdev rmlvo-to-kccgst +rmlvo-to-keymap print-compiled-keymap atom x11 diff --git a/test/rmlvo-to-keymap.c b/test/rmlvo-to-keymap.c new file mode 100644 index 0000000..ed48e49 --- /dev/null +++ b/test/rmlvo-to-keymap.c @@ -0,0 +1,141 @@ +/* + * Copyright © 2018 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + + +#include +#include +#include +#include +#include +#include +#include "xkbcommon/xkbcommon.h" + +static bool print = false; + +static void +usage(void) +{ + printf("Usage: %s [--print] [--rules ] [--layout ] [--variant ] [--options