test/compose.c


Log

Author Commit Date CI Message
Pierre Le Marre 4d605b70 2025-04-29T11:18:36 tests: Ensure random generator use an explicit seed This enable debugging with the exact same seed.
Ran Benita e120807b 2025-01-29T15:35:22 Update license notices to SDPX short identifiers + update LICENSE Fix #628. Signed-off-by: Ran Benita <ran@unusedvar.com>
Ran Benita 307ce5a7 2025-01-29T00:25:23 test/compose: reduce quickcheck iterations They're a *bit* too slow for interactive test runs when running in debug+sanitizers. Signed-off-by: Ran Benita <ran@unusedvar.com>
Pierre Le Marre 948f7a59 2024-10-09T08:34:27 symbols: Skip interprets only for groups with explicit actions Previously setting explicit actions for a group in symbols files made the parser skip compatibility interpretations for the corresponding *whole* key, so the other groups with *no* explicit actions could result broken on some levels. In the following example, `<RALT>` would have an action on group 2, because it is explicit, but none on group 1 because interpretation are also skipped there as a side effect: ```c key <RALT> { symbols[1]= [ ISO_Level3_Shift ], symbols[2]= [ ISO_Level3_Shift ], actions[2]= [ SetMods(modifiers=LevelThree) ] }; ``` Fixed by skipping interpretations *only* for groups with explicit actions. We still set `key->explicit |= EXPLICIT_INTERP` if at least one group has explicit actions. In such case, when dumping a keymap, we will write explicit actions for *all* groups, in order to ensure that X11 and previous versions of libxkbcommon can parse the keymap as intended. One side effect is that no interpretation will be run on this key anymore, so we may have to set some extra fields explicitly: repeat, virtualMods. Thus the previous example would be bumped as: ```c key <RALT> { repeat= No, symbols[1]= [ ISO_Level3_Shift ], actions[1]= [ SetMods(modifiers=LevelThree,clearLocks) ], symbols[2]= [ ISO_Level3_Shift ], actions[2]= [ SetMods(modifiers=LevelThree) ] }; ```
Pierre Le Marre 3ed763c3 2024-10-09T07:11:13 test: Add strip_lines and uncomment to text utils These allow us to store comments in files (especially keymaps), that can then be removed (e.g. to compare with output) or uncommented (e.g. to activate an optional line).
Pierre Le Marre 4100bdd2 2024-09-01T10:57:40 compose: Add roundtrip test parse/dump
Pierre Le Marre d4deb755 2024-09-01T09:07:00 compose: Add quickcheck test for traversal Test against the `foreach` reference implementation: - Suffle compose file lines randomly; - Compare traversal entry by entry. The `foreach` Compose traversal implementation is based on Ran’s work: https://github.com/bluetech/libxkbcommon/commit/f7f3c3c385fdc9ae91135f95e4b10f072603b812
Pierre Le Marre 652b03cc 2024-09-01T08:32:21 compose: Add Compose table dump internal API - Move `print_compose_table_entry` to own file and add a `file` argument to select output. - Add `xkb_compose_table_dump` to dump a Compose table. This change is needed in order to share the feature “dump a Compose table” between tests and tools.
Peter Hutterer c15ca444 2024-07-16T10:44:55 test/compose: reset the utf8 buffer to a "random" sequence This ensures that our string termination is handled by utf32_to_utf8() as opposed to false positives due to previously set null terminators. Fixes: ../../../test/compose.c:912:34: warning: The left operand of '==' is a garbage value [core.UndefinedBinaryOperatorResult] 912 | assert_printf(buf[c] == '\0', "NULL-terminated string\n");
Peter Hutterer f129b21b 2024-07-16T10:26:19 test/compose: only setenv if our top_srcdir is not NULL ../../../test/compose.c:968:5: warning: Null pointer passed to 2nd parameter expecting 'nonnull' [core.NonNullParamChecker]
Peter Hutterer 89d318da 2024-07-16T10:17:02 test: explicitly cast time() to int for the seed (hopefully) silences an analyzer warning: test/compose.c:955:16: store_truncates_time_t: A "time_t" value is stored in an integer with too few bits to accommodate it. The expression "time(NULL)" is cast to "int".
Pierre Le Marre e325e65e 2024-02-20T08:13:37 Add test_unit to all tests Currently it only ensure we do not buffer `stdout`.
Pierre Le Marre 1731c6b3 2024-02-05T11:55:39 compose: Ensure we mmap only regular files Currently we do not check that the Compose files we try successively are *regular* files. This may result in an error, while we should just really just skip the corresponding path. Fixed by adding the new utily function `open_file`.
Pierre Le Marre 43c9752d 2024-01-16T11:04:59 compose: Fix iterator for empty tables The current `xkb_compose_table_iterator_next` segfaults when used with an empty table. Indeed, in this case we initialize cursors in `xkb_compose_table_iterator_new` with the dummy node and the direction `NODE_LEFT`, but the dummy node is a leaf! Fixed by initializing with no cursors when the table is has no non-dummy nodes.
Pierre Le Marre 8cca3a7b 2023-12-05T17:39:59 compose: Add XKB_COMPOSE_MAX_STRING_SIZE Define the maximum size of a compose sequence result string explicit as a constant and use it everywhere to improve the code readability.
Pierre Le Marre 0074baf4 2023-12-19T07:28:52 keysyms: Add XKB_KEYSYM_NAME_MAX_SIZE for internal use Currently there is no indication of the maximum length of keysym names. This is statically known, so add the new *internal* following API: `XKB_KEYSYM_NAME_MAX_SIZE`.
Pierre Le Marre 0a577a09 2023-11-07T12:58:41 xkbcli-compile-compose: Fix string result escaping Currently the result string is not escaped and may produce invalid results. Fixed by introducing an ad-hoc escape function and relative tests.
Pierre Le Marre a2da57ab 2023-10-30T14:50:00 Compose: early detection of invalid encoding Also move “unrecognized token” error message before skiping the line, in order to fix token position.
Pierre Le Marre 59886e41 2023-10-29T07:20:29 Compose: skip heading UTF-8 encoded BOM (U+FEFF) Leading BOM is legal and is used as a signature — an indication that an otherwise unmarked text file is in UTF-8. See: https://www.unicode.org/faq/utf_bom.html#bom5 for further details.
Pierre Le Marre 0038c866 2023-09-26T17:05:14 Prevent overflow of octal escape sequences 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.
Pierre Le Marre ca7aa69c 2023-09-26T17:05:05 Disallow producing NULL character with escape sequences 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.
Ran Benita a1770132 2023-09-25T11:41:48 Compose: add iterator API 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>
Pierre Le Marre fc25e0f0 2023-06-26T12:19:49 Test(compose): fix assumption on environment variables 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.
Weng Xuetian b064b609 2022-05-14T01:11:32 Do not clear sibling entries when override. 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>
Ran Benita 98f07da8 2021-05-22T20:07:06 test/compose: add tests for xkb_compose_table_new_from_locale lookup Signed-off-by: Ran Benita <ran@unusedvar.com>
Ran Benita 5b1b2f75 2021-05-22T20:00:24 test/compose: clean up after a setenv Signed-off-by: Ran Benita <ran@unusedvar.com>
Ran Benita e2465c2a 2021-05-22T19:55:04 tests/data: add files needed to fully test compose Signed-off-by: Ran Benita <ran@unusedvar.com>
Peter Hutterer 41a7c975 2020-07-10T14:57:57 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>
Ran Benita da4a90c1 2019-12-28T13:49:40 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>
Ran Benita 40aab05e 2019-12-27T13:03:20 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>
Ran Benita 8e1fed6c 2015-03-24T16:40:29 compose: correctly parse modifier syntax As described in: http://cgit.freedesktop.org/xorg/lib/libX11/commit/?id=ddf3b09bb262d01b56fbaade421ac85b0e60a69f Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita c42b8646 2014-10-14T11:47:25 test/compose: test include statement Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 3f489730 2014-10-14T10:53:38 test/compose: test modifier syntax Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 10a7a2bd 2013-10-27T20:37:27 test/compose: add new test Some results from the benchmark (compilation of en_US.UTF-8/Compose): $ grep 'model name' /proc/cpuinfo model name : Intel(R) Core(TM)2 Duo CPU E8400 @ 3.00GHz model name : Intel(R) Core(TM)2 Duo CPU E8400 @ 3.00GHz $ uname -a Linux ran 3.16.1-1-ARCH #1 SMP PREEMPT Thu Aug 14 07:40:19 CEST 2014 x86_64 GNU/Linux $ ./test/compose bench compiled 1000 compose tables in 7.776488331s So according to the above benchmark and valgrind --tool=massif, an xkb_compose_table adds an overhead of about ~8ms time and ~130KB resident memory. For contrast, a plain US keymap adds an overhead of ~3ms time and 90KB resident memory. Signed-off-by: Ran Benita <ran234@gmail.com>