summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
...
* tools: install our tools as xkbcli subcommandsPeter Hutterer2020-07-251-1/+2
| | | | | | | The xkbcli tool usage help is ifdef'd out where the tool isn't built but the man page always includes all tools. Easier that way. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: make the symbols-leak-test executablePeter Hutterer2020-07-251-0/+0
| | | | | | | | | | | | Python leaks like crazy when run under valgrind. But if we make the script executable **and** it has uses the env invocation (i.e. #!/usr/bin/env python3), the leaks disappear. This is not the case for a shebang of /usr/bin/python3. Why exactly this is the case I'm not sure but executables we plan to run should have the exec bit set. So this is a janitor patch with the nice side effect of fixing our valgrind runs. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* PACKAING: remove bashRan Benita2020-07-221-1/+0
| | | | | | Converted to Python. Signed-off-by: Ran Benita <ran@unusedvar.com>
* test: fix Windows CI by rewriting symbols-leak-test from bash to pythonRan Benita2020-07-222-19/+63
| | | | | | | | | | | | | | | | The CI started installing some wrapper instead of a real bash which is what gets found. See: https://github.com/actions/virtual-environments/pull/1081 Given meson is written in python, it should always be available hopefully. Disabled valgrind wrapper for now because it now also applies to the python interpreter which leaks like a sieve. Signed-off-by: Ran Benita <ran@unusedvar.com>
* Add asprintf_safe helper functionPeter Hutterer2020-07-134-14/+11
| | | | | | | We only ever care about whether we error out or not, so let's wrap this into something more sane. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Add libxkbregistry to query available RMLVOPeter Hutterer2020-07-061-0/+843
| | | | | | | | | | | | | | | | | | | | | This library is the replacement for clients parsing evdev.xml directly. Instead, they should use the API here so that in the future we may even be able to swap evdev.xml for a more suitable data format. The library parses through evdev.xml (using libxml2) and - if requested - through evdev.extras.xml as well. The merge approach is optimised for the default case where we have a system-installed rules XML and another file in $XDG_CONFIG_DIR that adds a few entries. We load the system file first, then append any custom ones to that. It's not possible to overwrite the MLVO list provided by the system files - if you want to do that, get the change upstream. XML validation is handled through the DTD itself which means we only need to check for a nonempty name, everything else the DTD validation should complain about. The logging system is effectively identical to xkbcommon. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* utils: add streq_null() for streq that allows NULL valuesPeter Hutterer2020-07-061-0/+6
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Add a snprintf_safe() helper functionPeter Hutterer2020-07-061-0/+50
| | | | | | | Returns true on success or false on error _or_ truncation. Since truncation is almost always an error anyway, we might as well make this easier to check. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: fix the xkeyboard-config test for the prefixed tool namePeter Hutterer2020-07-011-1/+1
| | | | | | Regression introduced in 362130debb5d90d77f0d4f7549880b5f9699f647 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: drop some now-obsolete functionsPeter Hutterer2020-06-252-137/+0
| | | | | | | These were moved to tools/tools-common.c and now that all tools are switched over, they're no longer needed. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* tools: move the remaining tools from test to herePeter Hutterer2020-06-253-1627/+0
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: disentangle interactive-wayland from the test headersPeter Hutterer2020-06-251-6/+6
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: untangle interactive-x11 from the test headersPeter Hutterer2020-06-251-6/+6
| | | | | | Use the new tools headers and create a custom internal lib for the x11 tool. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: untangle interactive-evdev from the test headersPeter Hutterer2020-06-253-39/+32
| | | | | | | | | Move (sometimes duplicate) the required bits into new shared files tools-common.(c|h) that are compiled into the internal tools library. Rename the test_foo() functions to tools_foo() and in one case just copy the code of the keymap compile function to the tool. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: simplify error handling in interactive-evdevPeter Hutterer2020-06-251-31/+20
| | | | | | | | | Passing -errno around and having separate labels depending on failure types is superfluous here. All the unref calls can handle NULL and nothing cares about errno once we're out of the immediate scope. So let's simplify this and deal with 0 and 1 only. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Move the various tools to a tools/ directoryPeter Hutterer2020-06-254-538/+0
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: how-to-type: prefer local headers over system onesPeter Hutterer2020-06-251-1/+1
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: untangle rmlvo-to-kccgst from the test headersPeter Hutterer2020-06-251-2/+1
| | | | | | | | | | | Using test helpers to init the context gives it fairly specific behavior; unless the user sets the right environment variables and/or calls it from the right PWD, it may or may not include the test data. Let's drop this behavior, make it a default tool to compile a keymap. If there is a specific need to modify the include paths, we can add this later. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: untangle print-compiled-keymap from the test headersPeter Hutterer2020-06-251-3/+15
| | | | | | | | | | | | | | Commit 16c84cdd819db516fff089c76b99248fb7dd4e8c removed the getopt handling for RMLVO arguments, so now this tool only takes a keymap file and compiles it. Using test helpers to init the context gives it fairly specific behavior; unless the user sets the right environment variables and/or calls it from the right PWD, it may or may not include the test data. Let's drop this behavior, make it a default tool to compile a keymap. If there is a specific need to modify the include paths, we can add this later. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: simplify an exit pathPeter Hutterer2020-06-251-8/+6
| | | | | | | The unref() functions take NULL as argument, so we don't need different labels for every possible exit path. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* keymap: don't forget about fallback mappings in ↵Ran Benita2020-04-181-1/+2
| | | | | | | | | | | | | | | | | | | | xkb_keymap_key_get_mods_for_level() If the active set of modifiers doesn't match any explicit entry of the key type, the resulting level is 0 (i.e. Level 1). Some key types don't explicitly map Level 1, taking advantage of this fallback. Previously, xkb_keymap_key_get_mods_for_level didn't consider this, and only reported masks for explicit mappings. But this causes some glaring omissions, like matching "a" in the "us" keymap returning not results. Since every mask which isn't explicitly mapped falls back to 0, we can't return the all. Almost always the best choice for this is the empty mask, so return that, when applicable. Fixes https://github.com/xkbcommon/libxkbcommon/issues/140. Reported-by: https://github.com/AliKet Signed-off-by: Ran Benita <ran@unusedvar.com>
* test: use flag instead of hardcoded value in examplesNils2020-03-253-3/+6
|
* test/how-to-type: some code fixes/improvementsRan Benita2020-03-211-14/+14
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* test: add "how to type" demo programRan Benita2020-03-201-0/+196
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The program takes a unicode codepoint and an RMLVO and prints out all key + modifier combinations that would result in that codepoint. The program was written to exercise the new xkb_keymap_key_get_mods_for_level() function. It's handy and can be extended in several ways, but enough for now. Example: $ ./build/how-to-type -l us,il,ru 0x41 | column -ts $'\t' keysym: A (0x41) KEYCODE KEY NAME LAYOUT# LAYOUT NAME LEVEL# MODIFIERS 38 AC01 1 English (US) 2 [ Shift ] 38 AC01 1 English (US) 2 [ Lock ] 38 AC01 2 Hebrew 2 [ Shift ] 38 AC01 2 Hebrew 2 [ Lock ] $ ./build/how-to-type -l de -v neo 0x3b6 | column -ts $'\t' keysym: Greek_zeta (0x7e6) KEYCODE KEY NAME LAYOUT# LAYOUT NAME LEVEL# MODIFIERS 56 AB05 1 German (Neo 2) 4 [ Shift Mod5 ] 56 AB05 1 German (Neo 2) 4 [ Shift Mod2 Mod3 Mod5 ] 56 AB05 1 German (Neo 2) 4 [ Shift Lock Mod5 ] 56 AB05 1 German (Neo 2) 4 [ Lock Mod2 Mod3 Mod5 ] Signed-off-by: Ran Benita <ran@unusedvar.com>
* API to query modifier set required to type a keysymJaroslaw Kubik2020-03-201-0/+42
| | | | | | | | | The new API is useful to implement features like auto-type and desktop automation. Since the inputs for these features is usually specified in terms of the symbols that need to be typed, the implementation needs to be able to invert the keycode->keysym transformation and produce a sequence of keycodes that can be used to type the requested character(s).
* Support translation Unicode codepoints to keysymsJaroslaw Kubik2020-02-241-0/+66
| | | | | | | | | In order to support features like auto-type and UI automation, the relevant tools need to be able to invert the keycode->keysym->text transformation. In order to facilitate that, a new API was added. It allows querying the keysyms that correspond to particular Unicode codepoints. For all practical purposes, it can be thought of as an inverse of xkb_keysym_to_utf32().
* MSVC: Provide implementations of [un]setenv()Adrian Perez de Castro2019-12-281-0/+5
| | | | | Reference: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/putenv-s-wputenv-s
* MSVC: Provide implementations of test_{dis,en}able_stdin_echoAdrian Perez de Castro2019-12-281-3/+24
| | | | | | This provides implementations of the test_enable_stdin_echo and test_disable_stdin_echo which do not require <termios.h>, which is not available on Windows.
* MSVC: Use <io.h> as an alternative for <unistd.h>Adrian Perez de Castro2019-12-282-1/+13
| | | | | | | | | Only the input/output functions from <unistd.h> options are used, so using <io.h> when building with MSVC should be enough. The inclusion of the header in context-priv.c does not seem to be needed (tested on GNU/Linux) and so it is removed. Signed-off-by: Ran Benita <ran@unusedvar.com>
* test/data: ensure files are checked out with LF, not CRLFRan Benita2019-12-281-0/+1
| | | | | | | The tests stringcomp and buffercomp do binary comparison on some files; if the files are changed to CRLF on checkout, the tests fail. Signed-off-by: Ran Benita <ran@unusedvar.com>
* test/atom: use correct format specifier for size_tRan Benita2019-12-281-6/+6
| | | | | | | | | | | | | | | | | | | From MSVC: test\atom.c(98): note: consider using '%zu' in the format string test\atom.c(98): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'size_t' test\atom.c(100): note: consider using '%zu' in the format string test\atom.c(100): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'size_t' test\atom.c(114): note: consider using '%zu' in the format string test\atom.c(114): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'size_t' test\atom.c(128): note: consider using '%zu' in the format string test\atom.c(128): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'size_t' test\atom.c(130): note: consider using '%zu' in the format string test\atom.c(130): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'size_t' test\atom.c(137): note: consider using '%zu' in the format string test\atom.c(137): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 2 has type 'size_t' Signed-off-by: Ran Benita <ran@unusedvar.com>
* Open files in binary modeRan Benita2019-12-283-4/+4
| | | | | | This turns off some misfeatures on Windows, and does nothing on POSIX. Signed-off-by: Ran Benita <ran@unusedvar.com>
* test/common: avoid double // in pathRan Benita2019-12-281-1/+2
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* test/common: simplify test_get_path()Ran Benita2019-12-281-12/+10
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* test/context: use a more portable directory-exists checkRan Benita2019-12-271-6/+7
| | | | | | MSVC doesn't have opendir/closedir. Signed-off-by: Ran Benita <ran@unusedvar.com>
* Only add GCC diagnostic pragmas when compiler is GCC compatibleRan Benita2019-12-271-0/+2
| | | | | | Avoid "unknown pragma" warnings on other compilers. Signed-off-by: Ran Benita <ran@unusedvar.com>
* build: include config.h manuallyRan Benita2019-12-2724-2/+49
| | | | | | | | | Previously we included it with an `-include` compiler directive. But that's not portable. And it's better to be explicit anyway. Every .c file should have `include "config.h"` first thing. Signed-off-by: Ran Benita <ran@unusedvar.com>
* rules: add include statements to rules filesPeter Hutterer2019-12-249-0/+228
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The majority use-case for extending XKB on a machine is to override one or a few keys with custom keycodes, not to define whole layouts. Previously, we relied on the rules file to be a single file, making it hard to extend. libxkbcommon parses $XDG_CONFIG_HOME/xkb/ but that only works as long as there is a rule that matches the user-specified RMLVO. This works for MLV but not for options which don't have a wildcard defined. Users have to copy the whole rules file and then work from there - not something easy to extend and maintain. This patch adds a new ! include directive to rules files that allows including another file. The file path must be without quotes and may not start with the literal "include". Two directives are supported, %H to $HOME and %S for the system-installed rules directory (usually /usr/share/X11/xkb/rules). A user would typically use a custom rules file like this: ! option = symbols custom:foo = +custom(foo) custom:bar = +custom(baz) ! include %S/evdev Where the above defines the two options and then includes the system-installed evdev rule. Since most current implementations default to loading the "evdev" ruleset, it's best to name this $XDG_CONFIG_HOME/xkb/rules/evdev, but any valid name is allowed. The include functionally replaces the line with the content of the included file which means the behavior of rules files is maintained. Specifically, custom options must be defined before including another file because the first match usually wins. In other words, the following ruleset will not assign my_model as one would expect: ! include %S/evdev ! model = symbols my_model = +custom(foo) The default evdev ruleset has wildcards for model and those match before the my_model is hit. The actual resolved components need only be in one of the XKB lookup directories, e.g. for the example above: $ cat $XDG_CONFIG_HOME/xkb/symbols/custom partial alphanumeric_keys xkb_symbols "foo" { key <TLDE> { [ VoidSymbol ] }; }; partial alphanumeric_keys xkb_symbols "baz" { key <AB01> { [ k, K ] }; }; This can then be loaded with the XKB option "custom:foo,custom:bar". The use of "custom" is just as an example, there are no naming requirements beyond avoiding already-used ones. Also note the bar/baz above - the option names don't have to match the component names. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: let rmlvo-to-kccgst take long options like rmlvo-to-keymapPeter Hutterer2019-11-181-3/+20
| | | | | | The short options were left for backwards compatibility. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* atom: combine atom_intern() and atom_lookup()Ran Benita2019-11-091-7/+7
| | | | | | Use an "add" bool parameter instead. This simplifies the code a bit. Signed-off-by: Ran Benita <ran@unusedvar.com>
* test/atom: increase iteration count and print random seed on failureRan Benita2019-11-081-2/+6
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* parser: get rid of "stealing" atomsRan Benita2019-11-081-4/+4
| | | | | | | | | This requires (well, at least implemented by) casting away `const` which is undefined behavior, and clang started to warn about it. The micro optimization didn't save too many allocations, anyway. Signed-off-by: Ran Benita <ran@unusedvar.com>
* test: remove a superfluous string-is-null checkPeter Hutterer2019-11-071-1/+1
| | | | | | | | | A few lines above we check path_rel[0], so any null pointer will blow up before we get here. Found by coverity Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: fix a potential memory leakPeter Hutterer2019-11-071-1/+3
| | | | | | Found by coverity Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: xkeyboard-config: bring back the progress barRan Benita2019-11-011-4/+2
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* test: xkeyboard-config: invoke the python3 command (#120)Peter Hutterer2019-11-011-1/+1
| | | | | | python3 is always python3, but python could be python2 in some cases. Or just missing (e.g. RHEL8). Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: xkeyboard-config: add missing variant testsPeter Hutterer2019-11-011-0/+3
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: xkeyboard-config: use universal_newlines instead of decodePeter Hutterer2019-11-011-7/+9
| | | | | | | This way stdin/stdout of the process are opened in text mode and we don't need manually decode. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: xkeyboard-config: flake8 fixesPeter Hutterer2019-11-011-2/+6
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: xkeyboard-config: handle keyboard interrupts correctlyPeter Hutterer2019-11-011-71/+80
| | | | | | | | | In python multiprocessing, each process needs to handle (and ignore) the KeyboardInterrupt to avoid exception logging. This is a separate patch for easier reviewing, the first hunks merely re-indent all of the xkbcommontool/xkbcomp functions into a try/except KeyboardInterrupt block. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>