summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* Do not interpret nor emit invalid Unicode encoding formsPierre Le Marre2023-05-132-0/+6
| | | | | | Surrogates are invalid in both UTF-32 and UTF-8. See https://www.unicode.org/versions/Unicode15.0.0/ch03.pdf#G28875 and https://www.unicode.org/versions/Unicode15.0.0/ch03.pdf#G31703
* scanner: allow for a zero terminated string as keymapPeter Hutterer2023-05-051-18/+22
| | | | | | | | | | | As the documentation for xkb_keymap_new_from_buffer() states, the "input string does not have to be zero-terminated". The actual implementation however failed with "unrecognized token/syntax error" when it encountered a null byte. Fix this by allowing a null byte at the last position of the buffer. Anything else is likely a client error anyway. Fixes #307
* Add support for modmap None (#291)Wismill2023-05-013-0/+309
| | | | | | | | | | | | | | | | | | | Unlike current xkbcommon, X11’s xkbcomp allows to remove entries in the modifiers’ map using “modifier_map None { … }”. “None” is translated to the special value “XkbNoModifier” defined in “X11/extensions/XKB.h”. Then it relies on the fact that in "CopyModMapDef", the following code: 1U << entry->modifier ends up being zero when “entry->modifier” is “XkbNoModifier” (i.e. 0xFF). Indeed, it relies on the overflow behaviour of the left shift, which in practice resolves to use only the 5 low bits of the shift amount, i.e. 0x1F here. Then the result of “1U << 0xFF” is cast to “char”, i.e. 0. This is a good trick but too magical, so in libxkbcommon we will use an explicit test against our new constant XKB_MOD_NONE.
* Possible fix for non-MSVC windows compilersRan Benita2023-04-112-4/+4
| | | | | | | | `_MSC_VER` is specific to MSVC, but there can be other compilers targeting windows. Hopefully they do define `_WIN32`, so let's use that. Refs: https://github.com/xkbcommon/libxkbcommon/issues/305 Signed-off-by: Ran Benita <ran@unusedvar.com>
* test: move mkdir & mkdtemp calls to common place and fix them on MSVCRan Benita2022-09-244-23/+62
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* utils: move some MSVC compat stuff to common placeRan Benita2022-09-241-9/+0
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* Remove bogus euro sign entry from keysymtabSam Lantinga2022-05-151-0/+1
| | | | | | | | | | | | Not sure what it's doing here, but converting "€" to a keysym doesn't work with this entry. 0x13a4 doesn't appear in xkbcommon-keysyms.h. 0x20ac is the keysym documented in the header (and it's the last entry in the table). It's been in the table since it was introduced in e0524296d2e0 ("Add API for getting unicode representation of a keysym"). Co-authored-by: Simon Ser <contact@emersion.fr>
* Do not clear sibling entries when override.Weng Xuetian2022-05-151-0/+21
| | | | | | | | | | lokid and hikid actually stores the sibling to current node, which should not be cleared when override. This would break the sequence with a common prefix when override another. Fix #286 Signed-off-by: Weng Xuetian <wengxt@gmail.com>
* test: add test for variant inheritance of ISO 639/3166 codesPeter Hutterer2022-02-041-0/+20
| | | | See efa99624320f54e6e1ff24e4c4b1fcecdfba43d5
* Variants should inherit iso639, iso3166 and brief from parent layout if ↵M Hickford2022-01-241-0/+6
| | | | omitted (#266)
* registry: skip over invalid ISO639 or ISO3166 entriesPeter Hutterer2022-01-241-7/+147
| | | | If the XML file is somehow off, don't load entries that are against the spec.
* test: show the tool exit status on failurePeter Hutterer2022-01-241-1/+1
| | | | | We already do so for the non-successful cases, let's do this here too so we know whether it was a signal or a normal exit.
* test/tool-option-parsing: don't depend on build prefixRan Benita2021-05-221-0/+4
| | | | | Fixes: https://github.com/xkbcommon/libxkbcommon/issues/244 Signed-off-by: Ran Benita <ran@unusedvar.com>
* test/compose: add tests for xkb_compose_table_new_from_locale lookupRan Benita2021-05-221-0/+44
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* test/compose: clean up after a setenvRan Benita2021-05-221-0/+2
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* tests/data: add files needed to fully test composeRan Benita2021-05-226-4/+4389
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* ignore: remove no longer relevant gitignore filesRan Benita2021-05-221-24/+0
| | | | | | These were relevant for the autoconf build but now we're meson only. Signed-off-by: Ran Benita <ran@unusedvar.com>
* keysym: fix underflow in binary searchesIsaac Freund2021-04-251-0/+3
| | | | | | | | | | This is hit when passing an empty string and XKB_KEYSYM_CASE_INSENSITIVE to xkb_keysym_from_name currently if `(lo + hi) / 2` is 0 and `cmp < 0`, causing mid to underflow and the the array access into name_to_keysym on the next iteration of the loop to be out of bounds . We *would* use ssize_t here as it is the appropriate type, but windows unfortunately does not define it.
* test: allow skipping errors in certain conditionsPeter Hutterer2021-04-221-2/+11
| | | | | | | | | | Add a skipError test function that can analyse rc, stdout, stderr to skip a test even when we expect an error. We use that to skip if we couldn't find a keyboard in the interactive-evdev test. Fixes #235 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: add extra info to the layout-tester --help outputPeter Hutterer2021-04-201-1/+6
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: print the layout-tester progress bar to stdout by defaultPeter Hutterer2021-04-201-2/+2
| | | | | | | | tqdm prints to stderr by default but we're using that for failed keymap compiles (which are the ones that really matter). Plus, whether we're using tqdm is dependent on isatty(sys.stdout) anyway. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: add an LVO argument to the XKB layout testerPeter Hutterer2021-04-201-1/+15
| | | | | | Slightly easier to debug if we can have it only parse one single layout. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: print the compiled keymaps to a given directoryPeter Hutterer2021-04-201-2/+35
| | | | | | | | | | | With --keymap-output-dir, the given directory will contain a list of files named after the layout + variant ('us', 'us(euro)', ...) that contain the keymaps for each variant + option combination compiled. This is still a lot, but better to sift through hundreds of keymaps than tens of thousands. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: rework the output for the xkeyboard-config layout testerPeter Hutterer2021-04-201-74/+111
| | | | | | | | | | | | | | | | | | | | | | | | The previous output is largely unusable. The result in the CI test runs is a 6GB file with every compiled keymap in it and while we can grep for ERROR, it's not particularly useful. Let's change this and print out YAML instead - that can be machine-processed. This patch adds a new parent class that prints itself in YAML format, the tool invocations are child classes of that class. The result looks like this: Example output: - rmlvo: ["evdev", "pc105", "us", "haw", "grp:rwin_switch"] cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant haw --options grp:rwin_switch" status: 0 - rmlvo: ["evdev", "pc105", "us", "foo", ""] cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant foo" status: 1 error: "failed to compile keymap" Special status codes are: 99 for "unrecognized keysym" and 90 for "Cannot open display" in the setxkbmap case. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: add proper --verbose handling to the xkeyboard-config testerPeter Hutterer2021-04-201-11/+22
| | | | | | | Instead of defaulting to verbose on/off depending on isatty, make it an argument instead. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* keysym: avoid strtoul in xkb_keysym_from_nameRan Benita2021-04-011-0/+11
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* keysym: properly handle overflow in 0x keysym namesRan Benita2021-03-301-0/+4
| | | | | | | | Relatedly, strtoul allows a lot of unwanted stuff (spaces, +/- sign, thousand seperators), we really ought not use it. But that's for another time. Signed-off-by: Ran Benita <ran@unusedvar.com>
* test: move an assert up to before the strlen() usePeter Hutterer2021-03-301-1/+2
| | | | | | | | ../../../test/keysym.c:80:24: warning: Null pointer passed to 1st parameter expecting 'nonnull' [core.NonNullParamChecker] (unsigned) strlen(expected)); Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: fix missing va_end in case of test failuresPeter Hutterer2021-03-191-6/+15
| | | | | | Found by coverity Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: add a keysym testerPeter Hutterer2021-02-221-0/+71
| | | | | | | | | | | A simple script that creates a new layout with the given keysym replacing TLDE. Then we compile a keymap and search for the keysym being assigned to TLDE and bail if that fails. The list of keysyms is manually maintained but we only need to add one or two to spot-check whenever the xorgproto is updated. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: fix interactive evdev test invocationPeter Hutterer2021-01-231-1/+1
| | | | | | | | | rmlvos is the parent list which then fails during a list join because, well, it's a list of lists. Fixes #206 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: fill in srcdir/builddir when not set in the environmentPeter Hutterer2021-01-231-2/+13
| | | | | | | Makes this test easier to run from the commandline. Where either of top_srcdir or top_builddir isn't set, fill them in from the CWD or fail otherwise. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* keymap-dump: follow xkbcomp in printing affect=both in pointer actionsRan Benita2020-11-232-8/+8
| | | | | | It is equivalent to nothing but good to match up. Signed-off-by: Ran Benita <ran@unusedvar.com>
* test/data: update host.xkb to match keymap-dump styleRan Benita2020-11-231-311/+311
| | | | | | This is needed for fixing the x11comp test. Signed-off-by: Ran Benita <ran@unusedvar.com>
* test: catch unrecognized keysyms in the xkeyboard-config testPeter Hutterer2020-10-201-0/+7
| | | | | | | | | 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.
* xkbcomp: where a keysym cannot be resolved, set it to NoSymbolPeter Hutterer2020-10-202-2/+68
| | | | | | | | | | | | | | | | 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 ] };
* test/tool-option-parsing: skip testing of disabled toolsRan Benita2020-09-081-28/+24
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* test/tool-option-parsing: switch from pytest to unittestRan Benita2020-09-081-196/+173
| | | | | | | | | | | | | 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>
* test/tool-option-parsing: keep isolated by using our own test dataRan Benita2020-09-071-1/+6
| | | | | | Make it possible to run the test on all machines. Signed-off-by: Ran Benita <ran@unusedvar.com>
* test: include unstd.h in the registry test to cut down the MacOS warningsPeter Hutterer2020-09-071-0/+3
| | | | | | | 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>
* test/data: add rule registry filesRan Benita2020-09-075-0/+18176
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* test/data: sync from xkeyboard-config 2.30Ran Benita2020-09-0728-863/+1635
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* test/data: change quartz.xkb from CRLF to LFRan Benita2020-09-071-1139/+1139
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* test: fix the xkbcli --version testPeter Hutterer2020-09-071-1/+1
| | | | | | Fixes https://github.com/xkbcommon/libxkbcommon/issues/185 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Add /etc/xkb as extra lookup path for system data filesPeter Hutterer2020-08-301-0/+2
| | | | | | | | | | | | | | | 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>
* test: fix the xkeyboard-config testPeter Hutterer2020-07-291-2/+1
| | | | | | | | | '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>
* test: ignore the real XDG_CONFIG_HOME during testsPeter Hutterer2020-07-271-1/+8
| | | | | | | | | | 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>
* tools/interactive-evdev: fixup 64bff65Ran Benita2020-07-271-0/+1
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* test/tool-option-parsing: remove --kccgst test, it's private for nowRan Benita2020-07-251-2/+2
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* tools: run test-tool-option-parsing.py like a regular testRan Benita2020-07-251-0/+302
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>