summaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)AuthorFilesLines
2024-02-19Fix issues detected by static analysis toolaccepted/tizen/unified/x/20240220.150017accepted/tizen/unified/toolchain/20240311.070033accepted/tizen/unified/dev/20240620.010903accepted/tizen/unified/20240219.160452accepted/tizen_unified_devJihoon Kim1-1/+1
Change-Id: I1dc356839dd3af7141df7dc727d58aa782b69da0 Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
2024-01-03compose.c: fix untrusted source issuetizen_work_20231222Jihoon Kim1-1/+1
Change-Id: Id9a599f66bb08aac580c6a25612f7016dac89f2f Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
2024-01-03Fix issue detected by static analysis toolJihoon Kim1-1/+2
Change-Id: Iaebabbf2a7ee68693cf87c617ca698b8f54bf247 Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
2023-12-22Fix issue detected by static analysis toolduna.oh1-6/+5
Use of pseudorandom number generator 'rand' at key-proc.c:45 & atom.c:50 It's bad to use this function for crypto purposes. Change-Id: I553401a0c341a547dfe779a270b51da8d6aa3d80
2023-12-22Fix issue detected by static analysis toolInhong Han1-0/+2
Change-Id: I67e4520bcac592600ad83e6060e2499620d20359
2023-12-22Apply directory macros and install license file to the proper directorySung-Jin Park1-2/+6
Change-Id: Icf6d15c1ad958177ee19e479e3368465261cee44
2023-09-29Fix trailing whitespaces in XKB filesPierre Le Marre18-96/+94
2023-09-29Python: make ruff & black happyPierre Le Marre4-200/+279
2023-09-28Keysyms: Fix failing testsPierre Le Marre2-11/+11
- Update keymap to use reference keysym names. - Fix x11comp test by handling old x11proto. We need xkbcomp to be compiled with at least x11proto-dev 2023.2. So we replace the unsupported keysyms with supported ones not already in the keymap. This is kind of ugly, but it works. If we ever want to restore the original keysyms with their supported names, the substitute keysyms will be easy to spot.
2023-09-26Prevent overflow of octal escape sequencesPierre Le Marre2-2/+8
The octal parser accepts the range `\1..\777`. The result is cast to `char` which will silently overflow. This commit prevents overlow and will treat `\400..\777` as invalid escape sequences.
2023-09-26Disallow producing NULL character with escape sequencesPierre Le Marre3-0/+22
NULL usually terminates the strings; allowing to produce it via escape sequences may lead to undefined behaviour. - Make NULL escape sequences (e.g. `\0` and `\x0`) invalid. - Add corresponding test. - Introduce the new message: XKB_WARNING_INVALID_ESCAPE_SEQUENCE.
2023-09-26Compose: add iterator APIRan Benita1-0/+105
Allow users to iterate the entries in a compose table. This is useful for other projects which want programmable access to the sequences, without having to write their own parser. - New API: - `xkb_compose_table_entry_sequence`; - `xkb_compose_table_entry_keysym`; - `xkb_compose_table_entry_utf8`; - `xkb_compose_table_iterator_new`; - `xkb_compose_table_iterator_free`; - `xkb_compose_table_iterator_next`. - Add tests in `test/compose.c`. - Add benchmark for compose traversal. - `tools/compose.c`: - Print entries instead of just validating them. - Add `--file` option. - TODO: make this tool part of the xkbcli commands. Co-authored-by: Pierre Le Marre <dev@wismill.eu> Co-authored-by: Ran Benita <ran@unusedvar.com> Signed-off-by: Ran Benita <ran@unusedvar.com>
2023-09-24Messages: merge macros with and without message codePierre Le Marre1-14/+14
Previously we had two types of macros for logging: with and without message code. They were intended to be merged afterwards. The idea is to use a special code – `XKB_LOG_MESSAGE_NO_ID = 0` – that should *not* be displayed. But we would like to avoid checking this special code at run time. This is achieved using macro tricks; they are detailed in the code (see: `PREPEND_MESSAGE_ID`). Now it is also easier to spot the remaining undocumented log entries: just search `XKB_LOG_MESSAGE_NO_ID`.
2023-09-24Messages: add new messages to registryPierre Le Marre1-4/+5
This commit is another step to identify and document the maximum number of logging messages. Bulk changes: - Rename `conflicting-key-type` to `conflicting-key-type-merging-groups`. Giving more context in the name allow us to introduce `conflicting-key-type-definitions` later. - Add conflicting-key-type-definitions - Add conflicting-key-type-map-entry - Add undeclared-modifiers-in-key-type Also improve the log messages. - Add conflicting-key-type-preserve-entries - Use XKB_ERROR_UNSUPPORTED_MODIFIER_MASK - Add illegal-key-type-preserve-result - Add conflicting-key-type-level-names - Add duplicate-entry - Add unsupported-symbols-field - Add missing-symbols-group-name-index - Use XKB_ERROR_WRONG_FIELD_TYPE - Add conflicting-key-name - Use XKB_WARNING_UNDEFINED_KEYCODE - Add illegal-keycode-alias - Add unsupported-geometry-section - Add missing-default-section - Add XKB_LOG_MESSAGE_NO_ID - Rename log_vrb_with_code to log_vrb - Use ERROR_WRONG_FIELD_TYPE & ERROR_INVALID_SYNTAX - Add unknown-identifier - Add invalid-expression-type - Add invalid-operation + fixes - Add unknown-operator - Rename ERROR_UNKNOWN_IDENTIFIER to ERROR_INVALID_IDENTIFIER - Add undeclared-virtual-modifier - Add expected-array-entry - Add invalid-include-statement - Add included-file-not-found - Add allocation-error - Add invalid-included-file - Process symbols.c - Add invalid-value - Add invalid-real-modifier - Add unknown-field - Add wrong-scope - Add invalid-modmap-entry - Add wrong-statement-type - Add conflicting-key-symbols-entry - Add invalid-set-default-statement
2023-09-19Add xkb-check-messages toolPierre Le Marre1-0/+63
This tool checks whether messages codes are supported. This is useful e.g. for CI, where one may want to grep for some XKB error codes and ensure that these are still supported.
2023-09-19Use warning code in xkeyboard-config testPierre Le Marre1-2/+4
2023-09-18Test: Enable x11comp and use the xvfb wrapperPierre Le Marre1-59/+10
This test was previously disabled in 914e84e0188b5fbd67855f38f4499bb1412f4516. Note that it requires a recent version of xkeyboard-config to succeed.
2023-09-18Test: Catch SIGUSR1 from Xvfb for X11 testsPierre Le Marre1-2/+38
Based on the work done by Peter Hutterer. Original commit message: If SIGUSR1 is set to SIG_IGN, X servers (all of them, including Xvfb) will send that signal to the parent process when they're ready to accept connections. We can use that instead of a hardcoded sleep which brings the wait down to ~37ms on my box.
2023-09-18Test: Use a xvfb wrapper for x11 testPierre Le Marre3-3/+179
The x11 test is currently silently skipped in CI, because it requires a running X server. Create a xvfb wrapper to run the test. We do not use `xvfb-run`, because it is a shell script and it causes valgrind to detect unrelated memory issues in the shell (dash, bash). Improve wrapper using a special ELF section TODO: The wrapper is intended to be used with the x11comp test as well.
2023-07-14Improved tests related to keysymsPierre Le Marre3-17/+159
- Add a keymap test with decimal and hexadecimal keysyms. - Reorganize code in `test/keysym.c` by parsing type: name, Unicode and hexadecimal. - Add more tests for edge cases. In particular: - test decimal format (currently not supported); - test the Unicode and hexadecimal ranges more thoroughly; - test with wrong case without the XKB_KEYSYM_CASE_INSENSITIVE flag; - test surrounding spaces. - Document the tests.
2023-07-04Replace keycode numeric offset with EVDEV_OFFSETPierre Le Marre1-41/+41
Add a constant `EVDEV_OFFSET` to make the semantic of the offset clearer.
2023-06-28Test(compose): fix assumption on environment variablesPierre Le Marre1-0/+16
The test `test_from_locale` fails when there is a user-defined compose file, e.g. ~/.XCompose. Indeed, the function `xkb_compose_table_new_from_locale` use various environment variables to determine the location of the compose file. Ensure no environment variables but the required ones are set, in order to have robust tests.
2023-05-13Do not interpret nor emit invalid Unicode encoding formsPierre Le Marre2-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
2023-05-05scanner: allow for a zero terminated string as keymapPeter Hutterer1-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
2023-05-01Add support for modmap None (#291)Wismill3-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.
2023-04-11Possible fix for non-MSVC windows compilersRan Benita2-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>
2022-09-24test: move mkdir & mkdtemp calls to common place and fix them on MSVCRan Benita4-23/+62
Signed-off-by: Ran Benita <ran@unusedvar.com>
2022-09-24utils: move some MSVC compat stuff to common placeRan Benita1-9/+0
Signed-off-by: Ran Benita <ran@unusedvar.com>
2022-05-15Remove bogus euro sign entry from keysymtabSam Lantinga1-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>
2022-05-15Do not clear sibling entries when override.Weng Xuetian1-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>
2022-02-04test: add test for variant inheritance of ISO 639/3166 codesPeter Hutterer1-0/+20
See efa99624320f54e6e1ff24e4c4b1fcecdfba43d5
2022-01-24Variants should inherit iso639, iso3166 and brief from parent layout if ↵M Hickford1-0/+6
omitted (#266)
2022-01-24registry: skip over invalid ISO639 or ISO3166 entriesPeter Hutterer1-7/+147
If the XML file is somehow off, don't load entries that are against the spec.
2022-01-24test: show the tool exit status on failurePeter Hutterer1-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.
2021-05-22test/tool-option-parsing: don't depend on build prefixRan Benita1-0/+4
Fixes: https://github.com/xkbcommon/libxkbcommon/issues/244 Signed-off-by: Ran Benita <ran@unusedvar.com>
2021-05-22test/compose: add tests for xkb_compose_table_new_from_locale lookupRan Benita1-0/+44
Signed-off-by: Ran Benita <ran@unusedvar.com>
2021-05-22test/compose: clean up after a setenvRan Benita1-0/+2
Signed-off-by: Ran Benita <ran@unusedvar.com>
2021-05-22tests/data: add files needed to fully test composeRan Benita6-4/+4389
Signed-off-by: Ran Benita <ran@unusedvar.com>
2021-05-22ignore: remove no longer relevant gitignore filesRan Benita1-24/+0
These were relevant for the autoconf build but now we're meson only. Signed-off-by: Ran Benita <ran@unusedvar.com>
2021-04-25keysym: fix underflow in binary searchesIsaac Freund1-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.
2021-04-22test: allow skipping errors in certain conditionsPeter Hutterer1-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>
2021-04-20test: add extra info to the layout-tester --help outputPeter Hutterer1-1/+6
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-20test: print the layout-tester progress bar to stdout by defaultPeter Hutterer1-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>
2021-04-20test: add an LVO argument to the XKB layout testerPeter Hutterer1-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>
2021-04-20test: print the compiled keymaps to a given directoryPeter Hutterer1-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>
2021-04-20test: rework the output for the xkeyboard-config layout testerPeter Hutterer1-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>
2021-04-20test: add proper --verbose handling to the xkeyboard-config testerPeter Hutterer1-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>
2021-04-01keysym: avoid strtoul in xkb_keysym_from_nameRan Benita1-0/+11
Signed-off-by: Ran Benita <ran@unusedvar.com>
2021-03-30keysym: properly handle overflow in 0x keysym namesRan Benita1-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>
2021-03-30test: move an assert up to before the strlen() usePeter Hutterer1-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>