Commit Graph

437 Commits (357c00b3a1c28afeb352887397ab9549740f1c85)

Author SHA1 Message Date
Peter Hutterer 6268ba1c77 test: catch unrecognized keysyms in the xkeyboard-config test
Prompted by
https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/-/merge_requests/127

We run the keymap tool with --verbose which will print the messages from the
compiler to the log file as well. And then we can search for the warning
regarding an unrecognized keysym and fail our test based on that.
2020-10-20 11:02:03 +10:00
Peter Hutterer afdc9ceee7 xkbcomp: where a keysym cannot be resolved, set it to NoSymbol
Where resolve_keysym fails we warn but use the otherwise uninitialized variable
as our keysym. That later ends up in the keymap as random garbage hex value.

Simplest test case, set this in the 'us' keymap:
    key <TLDE>               {      [        xyz ] };

And without this patch we get random garbage:
./build/xkbcli-compile-keymap --layout us | grep TLDE:
    key <TLDE>               {      [      0x018a5cf0 ] };

With this patch, we now get NoSymbol:
./build/xkbcli-compile-keymap --layout us | grep TLDE:
    key <TLDE>               {      [        NoSymbol ] };
2020-10-20 09:23:50 +10:00
Ran Benita 6178924f28 test/tool-option-parsing: skip testing of disabled tools
Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-09-08 09:45:34 +03:00
Ran Benita c621319e53 test/tool-option-parsing: switch from pytest to unittest
For me, installing pytest for libxkbcommon is a bit problematic, so I
end up skipping it which is not great.

Switch to unittest which is built in to Python. It's not as nice as
pytest but good enough in this case.

Note: I was too lazy to switch the plain asserts to unittest
assertions...

Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-09-08 09:45:34 +03:00
Ran Benita c8f309a2de test/tool-option-parsing: keep isolated by using our own test data
Make it possible to run the test on all machines.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-09-07 22:06:22 +03:00
Peter Hutterer 13745014c3 test: include unstd.h in the registry test to cut down the MacOS warnings
mkdtmp, rmdir and unlink are in unstd.h on MacOS. Since including that it
doesn't hurt us on Linux, let's do it without ifdefs.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-09-07 22:01:57 +03:00
Ran Benita 534e54f621 test/data: add rule registry files
Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-09-07 11:47:34 +03:00
Ran Benita 1c3521993d test/data: sync from xkeyboard-config 2.30
Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-09-07 11:36:49 +03:00
Ran Benita 461d727830 test/data: change quartz.xkb from CRLF to LF
Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-09-07 11:19:45 +03:00
Peter Hutterer 850ba7e636 test: fix the xkbcli --version test
Fixes https://github.com/xkbcommon/libxkbcommon/issues/185

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-09-07 11:15:08 +10:00
Peter Hutterer d7b39f6ffb Add /etc/xkb as extra lookup path for system data files
This completes the usual triplet of configuration locations available for most
processes:
- vendor-provided data files in /usr/share/X11/xkb
- system-specific data files in /etc/xkb
- user-specific data files in $XDG_CONFIG_HOME/xkb

The default lookup order user, system, vendor, just like everything else that
uses these conventions.

For include directives in rules files, the '%E' resolves to that path.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-30 21:49:41 +03:00
Peter Hutterer 9b9c5f2094 test: fix the xkeyboard-config test
'xkbcli compile-keymap' doesn't work unless we ninja install first. But for a
test that's to be run from the test directory, that's not a useful option so
let's call the binary directly. The script adds the meson builddir to the PATH
anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-29 08:33:26 +10:00
Peter Hutterer 03ecaa6b53 test: ignore the real XDG_CONFIG_HOME during tests
Let's not have our tests fail if the user has an incompatible
$XDG_CONFIG_HOME/xkb directory.

libxkbcommon has fallbacks when XDG_CONFIG_HOME isn't set so we need to override
this with a real directory instead of just unsetting it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-27 19:26:46 +10:00
Ran Benita fcc6b28f5f tools/interactive-evdev: fixup 64bff65
Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-07-27 11:59:21 +03:00
Ran Benita 0df23ea8d7 test/tool-option-parsing: remove --kccgst test, it's private for now
Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-07-25 16:38:43 +03:00
Ran Benita 608e9361e3 tools: run test-tool-option-parsing.py like a regular test
Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-07-25 16:37:57 +03:00
Peter Hutterer 29e80e7b76 tools: install our tools as xkbcli subcommands
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>
2020-07-25 11:05:14 +03:00
Peter Hutterer f0b1441f5e test: make the symbols-leak-test executable
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>
2020-07-25 10:59:32 +03:00
Ran Benita a4901662c3 PACKAING: remove bash
Converted to Python.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-07-22 20:04:10 +03:00
Ran Benita fa300b24d2 test: fix Windows CI by rewriting symbols-leak-test from bash to python
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>
2020-07-22 13:45:17 +03:00
Peter Hutterer 41a7c975f8 Add asprintf_safe helper function
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>
2020-07-13 18:41:00 +10:00
Peter Hutterer afb26e7df9 Add libxkbregistry to query available RMLVO
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>
2020-07-06 15:15:20 +10:00
Peter Hutterer fe88613382 utils: add streq_null() for streq that allows NULL values
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-06 15:15:20 +10:00
Peter Hutterer 9b1b0c5743 Add a snprintf_safe() helper function
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>
2020-07-06 15:15:20 +10:00
Peter Hutterer 43b9d09248 test: fix the xkeyboard-config test for the prefixed tool name
Regression introduced in 362130debb

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-01 08:19:40 +10:00
Peter Hutterer 314b6486b3 test: drop some now-obsolete functions
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>
2020-06-25 10:32:08 +10:00
Peter Hutterer 3adbe54eac tools: move the remaining tools from test to here
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-25 10:32:08 +10:00
Peter Hutterer f525f9f040 test: disentangle interactive-wayland from the test headers
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-25 10:32:08 +10:00
Peter Hutterer 1326d5add4 test: untangle interactive-x11 from the test headers
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>
2020-06-25 10:32:08 +10:00
Peter Hutterer c09bf36306 test: untangle interactive-evdev from the test headers
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>
2020-06-25 10:32:08 +10:00
Peter Hutterer 2eb5d2c81d test: simplify error handling in interactive-evdev
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>
2020-06-25 10:32:08 +10:00
Peter Hutterer ec2bbe599c Move the various tools to a tools/ directory
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-25 10:32:08 +10:00
Peter Hutterer 725a31986d test: how-to-type: prefer local headers over system ones
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-25 10:32:08 +10:00
Peter Hutterer 928771ede0 test: untangle rmlvo-to-kccgst from the test headers
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>
2020-06-25 10:32:08 +10:00
Peter Hutterer e5d4056e2f test: untangle print-compiled-keymap from the test headers
Commit 16c84cdd81 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>
2020-06-25 10:32:08 +10:00
Peter Hutterer 7d1aefddad test: simplify an exit path
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>
2020-06-25 10:32:08 +10:00
Ran Benita 860cfc039f keymap: don't forget about fallback mappings in 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>
2020-04-18 22:23:06 +03:00
Nils 0f1cae0cc4
test: use flag instead of hardcoded value in examples 2020-03-25 10:43:41 +02:00
Ran Benita 8a1709a411 test/how-to-type: some code fixes/improvements
Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-03-21 12:56:13 +02:00
Ran Benita 188a1c79f1 test: add "how to type" demo program
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>
2020-03-20 19:40:14 +02:00
Jaroslaw Kubik d92a248c48 API to query modifier set required to type a keysym
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).
2020-03-20 19:20:36 +02:00
Jaroslaw Kubik 0345aba082 Support translation Unicode codepoints to keysyms
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().
2020-02-24 09:54:09 +02:00
Adrian Perez de Castro f1186acfd4 MSVC: Provide implementations of [un]setenv()
Reference:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/putenv-s-wputenv-s
2019-12-28 16:12:15 +02:00
Adrian Perez de Castro abb2f9d978 MSVC: Provide implementations of test_{dis,en}able_stdin_echo
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.
2019-12-28 16:12:15 +02:00
Adrian Perez de Castro 5354dee2f7 MSVC: Use <io.h> as an alternative for <unistd.h>
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>
2019-12-28 16:12:15 +02:00
Ran Benita faac4ba7de test/data: ensure files are checked out with LF, not CRLF
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>
2019-12-28 15:59:47 +02:00
Ran Benita d1e39c111e test/atom: use correct format specifier for size_t
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>
2019-12-28 14:13:52 +02:00
Ran Benita da4a90c13e Open files in binary mode
This turns off some misfeatures on Windows, and does nothing on POSIX.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-28 13:49:40 +02:00
Ran Benita fe417d841e test/common: avoid double // in path
Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-28 13:40:38 +02:00
Ran Benita eb23982cab test/common: simplify test_get_path()
Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-28 13:39:33 +02:00
Ran Benita f967d46b65 test/context: use a more portable directory-exists check
MSVC doesn't have opendir/closedir.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27 15:47:49 +02:00
Ran Benita 670566f0d4 Only add GCC diagnostic pragmas when compiler is GCC compatible
Avoid "unknown pragma" warnings on other compilers.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27 15:20:25 +02:00
Ran Benita 40aab05e77 build: include config.h manually
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>
2019-12-27 13:09:11 +02:00
Peter Hutterer ca033a29d2 rules: add include statements to rules files
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>
2019-12-24 09:50:03 +02:00
Peter Hutterer 1de2f174c2 test: let rmlvo-to-kccgst take long options like rmlvo-to-keymap
The short options were left for backwards compatibility.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-11-18 15:32:35 +02:00
Ran Benita c79c80335b atom: combine atom_intern() and atom_lookup()
Use an "add" bool parameter instead. This simplifies the code a bit.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-11-09 21:28:43 +02:00
Ran Benita 2a6155936c test/atom: increase iteration count and print random seed on failure
Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-11-08 22:40:13 +02:00
Ran Benita 2af474e8d0 parser: get rid of "stealing" atoms
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>
2019-11-08 12:13:31 +02:00
Peter Hutterer 31e561fca9 test: remove a superfluous string-is-null check
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>
2019-11-07 11:10:00 +02:00
Peter Hutterer 96ef14ac94 test: fix a potential memory leak
Found by coverity

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-11-07 11:10:00 +02:00
Ran Benita 3515ba19a6 test: xkeyboard-config: bring back the progress bar
Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-11-01 10:45:43 +02:00
Peter Hutterer 8f93e22a37 test: xkeyboard-config: invoke the python3 command (#120)
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>
2019-11-01 10:41:16 +02:00
Peter Hutterer 0609073ce0 test: xkeyboard-config: add missing variant tests
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-11-01 10:24:03 +02:00
Peter Hutterer f4a0f73882 test: xkeyboard-config: use universal_newlines instead of decode
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>
2019-11-01 10:24:03 +02:00
Peter Hutterer 7832cc727c test: xkeyboard-config: flake8 fixes
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-11-01 10:24:03 +02:00
Peter Hutterer cd5a24aa38 test: xkeyboard-config: handle keyboard interrupts correctly
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>
2019-11-01 10:24:03 +02:00
Peter Hutterer 9fc0cb8777 test: xkeyboard-config: print to stderr on failure, stdout otherwise
This is a change in behavior and requires any automated callers to adjust
accordingly. Still, much easier to get the errors that way rather than it
being mixed into a thousands-of-lines output file.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-11-01 10:24:03 +02:00
Peter Hutterer f53838477d test: xkeyboard-config: add a multiprocessing.Pool() to speed up the test
Collect all options into a dictionary, then process that as async actions
through a process pool. This of course requires collecting the various print
statements to avoid mangled output.

This dropped the time to completion from around 14 min to 8 min on my local
machine (unscientific single run only for the original timing).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-11-01 10:24:03 +02:00
Peter Hutterer 1e13190685 test: xkeyboard-config: use argparse for the path and the tool selection
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-11-01 10:24:03 +02:00
Peter Hutterer 255200faa7 test: add test for the various default include paths
All tests create a temporary directory, set up the environment for that
directory and then check the include paths for the presence of that directory,
ideally in the right position of the list.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-10-31 19:29:30 +02:00
Ran Benita 45496c33f1 test: fix printf("%s", NULL) in error path
../test/common.c: In function ‘test_get_path’:
    ../test/common.c:171:9: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
      171 |         fprintf(stderr, "Failed to allocate path (%d chars) for %s\n",
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      172 |                 (int) path_len, path);
          |                 ~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-10-19 00:38:43 +03:00
Ran Benita 076047b21a keymap-dump: use consistent capitalization for "Group<N>"
It's used capitalized everywhere except a couple places.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-10-16 10:36:41 +03:00
Ran Benita a6ed0304f7 keymap-dump: fix invalid names used for levels above 8
xkbcomp only accepts the "Level" prefix for a level name for levels 1 to
8, but the keymap dumping code added it always, e.g. "Level15".

The plain integer, e.g. "8", "15" is always accepted, so just use that.

Fixes https://github.com/xkbcommon/libxkbcommon/issues/113

Signed-off-by: Ran Benita <ran@unusedvar.com>
Reported-by: progandy
2019-10-16 10:36:37 +03:00
Ran Benita ab4b4b7f12 travis: improve configuration and add macOS
Signed-off-by: Ran Benita <ran234@gmail.com>
2019-07-25 14:34:17 +03:00
Ran Benita 7407d311bf test/symbols-leak-test: fix sed regex on macOS
Signed-off-by: Ran Benita <ran234@gmail.com>
2019-07-25 14:18:42 +03:00
Ran Benita 97f41fe4ac test/symbols-leak-test: make it work with macOS diff
The <() stuff fails with an error:
    diff: extra operand `/dev/fd/61'

Signed-off-by: Ran Benita <ran234@gmail.com>
2019-07-25 13:24:00 +03:00
Ran Benita 6728ebca4a test/rmlvo-to-keymap: drop basename usage
It wants some libgen.h include which is POSIX only, let's just remove
it as it's hardly important.

Signed-off-by: Ran Benita <ran234@gmail.com>
2019-07-25 12:00:27 +03:00
worldofpeace 32d178b50f test/rmlvo-to-keymap.c: fix compilation on Darwin (#101)
program_invocation_short_name isn't portable.
2019-07-19 09:56:41 +03:00
Daniel Stone 909cc04d2c interactive-wayland: Port to stable xdg-shell (#100)
xdg_shell v6 was pretty close to the finalised stable version of
xdg-shell. We can now just use the stable version, which is supported
everywhere (Enlightenment, KWin, Mutter, Weston, wlroots).

This requires bumping the wayland-protocols dependency.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2019-07-02 15:48:32 +03:00
Peter Hutterer 878bc08559 test: allow for absolute paths to be resolved
This makes it possible to check a keymap sitting elsewhere than in the test
directory.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-21 11:31:10 +10:00
Peter Hutterer 16c84cdd81 test: drop the rmlvo ability from print-compiled-keymap
This is now handled by the rmlvo-to-keymap tool

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-21 11:31:07 +10:00
Peter Hutterer d1cb8ad409 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 <peter.hutterer@who-t.net>
2018-08-21 11:30:45 +10:00
Ran Benita 5cee660f69 keysym-utf: reject out-of-range Unicode codepoints in xkb_keysym_to_utf{8,32}
It used to be UTF-8 was defined for inputs > 0x10FFFF, but nowadays
that's the maximum and a codepoint is encoded up to 4 bytes, not 6.

Fixes: https://github.com/xkbcommon/libxkbcommon/issues/58
Fixes: https://github.com/xkbcommon/libxkbcommon/issues/59
Reported-by: @andrecbarros
Signed-off-by: Ran Benita <ran234@gmail.com>
2018-06-23 22:53:42 +03:00
Ran Benita afea3dd0cd test/interactive-wayland: replace tabs with spaces
Match the style of all other files.

Signed-off-by: Ran Benita <ran234@gmail.com>
2018-01-27 20:42:44 +02:00
Ran Benita 767fa86d42 Convert http:// -> https:// where possible
Signed-off-by: Ran Benita <ran234@gmail.com>
2017-12-21 14:18:07 +02:00
Ran Benita 29998c258c test/x11: properly clean up also when skipping test
To make valgrind happy.

Signed-off-by: Ran Benita <ran234@gmail.com>
2017-12-12 15:58:32 +02:00
Ran Benita 6456835f1c test/data: sync with xkeyboard-config 2.22
Some tweaks to the de(neo) keyseq tests were required. It seems to have
improved.

Signed-off-by: Ran Benita <ran234@gmail.com>
2017-12-03 13:07:21 +02:00
Ran Benita 14686cd1a8 test/interactive-wayland: avoid unused function warning due to configuration
test/interactive-wayland.c:95:1: warning: ‘set_cloexec_or_close’ defined but not used [-Wunused-function]

Signed-off-by: Ran Benita <ran234@gmail.com>
2017-08-16 20:24:27 +03:00
Ran Benita fbd86e44ad test/symbols-leak-test.bash: make it easier to read
Signed-off-by: Ran Benita <ran234@gmail.com>
2017-08-03 13:38:14 +03:00
Ran Benita 4309735de3 build: use top_srcdir consistently
Signed-off-by: Ran Benita <ran234@gmail.com>
2017-07-31 15:55:48 +03:00
Ran Benita d44ba481d7 build: remove unneeded preprocessor include flags
Better to avoid these unexpected include paths.

Signed-off-by: Ran Benita <ran234@gmail.com>
2017-07-31 15:55:48 +03:00
Ran Benita daebdb5e08 x11/keymap,test/interactive-evdev: fix a couple of clang-analyzer warnings
From my analysis these values cannot be null, but the analyzer cannot
see this. So assert it.

Signed-off-by: Ran Benita <ran234@gmail.com>
2017-07-31 15:55:48 +03:00
Ran Benita 2d9640651a test/x11comp: fix compiler warnings
Signed-off-by: Ran Benita <ran234@gmail.com>
2017-07-31 15:55:48 +03:00
Naman Dixit 4f17fc6005 Fixed a minor bug in error detection in Wayland test 2017-05-27 09:15:26 +00:00
Ran Benita c9832d4374 test/interactive-x11: handle NULL from xcb_wait_for_event
Can happen in cases like:
- There was an error between the error check and the call.
- The internal poll() fails.

Signed-off-by: Ran Benita <ran234@gmail.com>
2017-04-28 09:33:25 +03:00
Ran Benita 5d821aed9b test/x11comp: be a bit more careful with kill()
We did it correctly but better be safe and appease clang.

Signed-off-by: Ran Benita <ran234@gmail.com>
2017-04-11 21:01:41 +03:00
Ran Benita 9d94145808 test/interactive-wayland: mark a local function static
Signed-off-by: Ran Benita <ran234@gmail.com>
2017-04-11 21:01:41 +03:00
Ran Benita 03f4a03e71 test/interactive-wayland: handle unrecognized SHM format
The enum seems large, and we don't handle all of the values in it.
Previously if we got an unrecognized SHM format we would use an
uninitialized `stride`.

Signed-off-by: Ran Benita <ran234@gmail.com>
2017-04-11 21:01:41 +03:00
Ran Benita 0f43cfa225 test/interactive-wayland: fix uninitialized `ret` in error path
Signed-off-by: Ran Benita <ran234@gmail.com>
2017-04-11 21:01:41 +03:00
Daniel Stone 90bd9fdb01 interactive-wayland: Port to xdg-shell v6
Mutter only implements v6 now, and Weston also implements that. Port
interactive-wayland to this so people can keep on using it.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2017-04-11 15:09:50 +01:00