Commit Graph

300 Commits (8db924b87df7fdd40023b55a3ee55558d6fd841e)

Author SHA1 Message Date
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
Ran Benita b5586a6c42 keysym: fix locale dependence in xkb_keysym_from_name()
We currently use strcasecmp, which is locale-dependent. In particular,
one well-known surprise even if restricted just ASCII input is found in
the tr_TR (Turkish) locale, see e.g.
https://msdn.microsoft.com/en-us/library/ms973919.aspx#stringsinnet20_topic5

We have known to avoid locale-dependent functions before, but in this
case, we forgot.

Fix it by implementing our own simple ASCII-only strcasecmp/strncasecmp.
Might have been possible to use strcasecmp_l() with the C locale, but
went the easy route.

Side advantage is that even this non-optimized version is faster than
the optimized libc one (__strcasecmp_l_sse42) since it doesn't need to
do the locale stuff. xkb_keysym_from_name(), which uses strcasecmp
heavily, becomes faster, and so for example Compose file parsing, which
uses xkb_keysym_from_name() heavily, becomes ~20% faster.

Resolves https://github.com/xkbcommon/libxkbcommon/issues/42
Signed-off-by: Ran Benita <ran234@gmail.com>
2016-12-02 23:46:56 +02:00
Ran Benita babc9e0c30 state: add GTK consumed modifiers mode
This is more or less what is implemented here:
https://git.gnome.org/browse/gtk+/tree/gdk/x11/gdkkeys-x11.c?h=3.19.10#n1131

The implementation here is more technically correct but should provide
the same results.

Try it out with ./test/interactive-evdev -g (modifiers prefixed with "-"
are consumed).

https://bugzilla.gnome.org/show_bug.cgi?id=754110
https://github.com/xkbcommon/libxkbcommon/issues/17

Signed-off-by: Ran Benita <ran234@gmail.com>
2016-10-31 12:52:28 +02:00
Ran Benita a0a41332cc state: allow different modes for calculating consumed modifiers
The current functions dealing with consumed modifiers use the
traditional XKB definition of consumed modifiers (see description in the
added documentation). However, for several users of the library (e.g.
GTK) this definition is unsuitable or too eager. This is exacerbated by
some less-than-ideal xkeyboard-config type definitions (CTRL+ALT seems
to cause most grief...).

So, because we
- want to enable alternative interpretations, but
- don't want to expose too much internal details, and
- want to keep things simple for all library users,
we add a high-level "mode" parameter which selects the desired
interpretation. New ones can be added as long as they make some sense.

All of the old consumed-modifiers functions keep using the traditional
("XKB") mode. I mark xkb_state_mod_mask_remove_consumed() and as
deprecated without adding a *2 variant because I don't it is very useful
(or used) in practice.

Alternative modes are added in subsequent commits (this commit only adds
a mode for the existing behavior).

https://github.com/xkbcommon/libxkbcommon/issues/17

Signed-off-by: Ran Benita <ran234@gmail.com>
2016-10-31 12:52:26 +02:00
Ran Benita 914c060a1d test/state: move wrongly-placed assert
Signed-off-by: Ran Benita <ran234@gmail.com>
2016-10-22 20:13:11 +03:00
Ran Benita 8978ec39ed test/interactive-wayland: fix control reaches end of non-void function
AFAICS there is nothing that can fail directly in this function, so
change it to void.

Signed-off-by: Ran Benita <ran234@gmail.com>
2016-06-09 17:23:55 +03:00
Ran Benita 81ee012af0 test/symbols-leak-test: use more portable shebang
Some BSDs don't want to give bash the honor of /bin and put it
elsewhere. So look it up in PATH instead.

Signed-off-by: Ran Benita <ran234@gmail.com>
2016-06-09 15:00:43 +03:00
Ran Benita 316c7e2479 test/interactive-wayland: don't ignore asprintf return value
Fixes warn_unused_result warning.

Signed-off-by: Ran Benita <ran234@gmail.com>
2016-05-05 15:43:59 +03:00
Ran Benita fc41d3d605 test: use termios instead of system() for disabling terminal echo
Takes care of GCC's annoyingly persistent warn_unused_result warnings.
But it's better to avoid system() I suppose.

Signed-off-by: Ran Benita <ran234@gmail.com>
2016-05-05 15:41:13 +03:00
Daniel Stone 48d5b44fd0 interactive-wayland: Valgrind-proofing
More meticulously free everything we create, including hooking up the
buffer-release callback so we actually free those when required. Make
sure seats are actually in the display's seat list.

The xkbcommon object-unref functions don't actually require
NULL-checking, so we can elide those.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2016-04-12 13:19:25 +01:00
Daniel Stone 7e123a10b6 test: Add interactive-wayland
interactive-wayland is very similar to x11/xev, and dumps out as much
state as possible.

It provides no titlebar and a completely random cursor, but such is
life.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2016-04-12 12:15:04 +01:00
Ran Benita 4c24f7faa8 test: assert/ignore some warn_unused_result's
Signed-off-by: Ran Benita <ran234@gmail.com>
2016-03-15 20:45:05 +02:00
Ran Benita 37ee8e652b test/x11comp: fix memory leak
Signed-off-by: Ran Benita <ran234@gmail.com>
2016-03-13 23:17:23 +02:00
Ran Benita fa1b454328 test: add a test that all symbol version file is updated
It is easy to forget to update these files when adding new symbols.

Stolen with slight changes from libinput (commit by Marek Chalupa):
https://cgit.freedesktop.org/wayland/libinput/commit/?id=a9f216ab47ea2f643f20ed741b741a2b5766eba3

Signed-off-by: Ran Benita <ran234@gmail.com>
2016-03-13 23:17:23 +02:00
Mike Blumenkrantz 0ce17ef3ea keymap: add xkb_keymap_key_by_name(), xkb_keymap_key_get_name(), tests
xkb_keymap_key_by_name() allows finding a keycode from a given keyname and
is useful for generating keyboard events to use in regression tests
during CI

xkb_keymap_key_get_name() is the inverse of xkb_keymap_key_by_name()

Signed-off-by: Mike Blumenkrantz <zmike@osg.samsung.com>
[ran: some stylistic tweaks + another test case]
Signed-off-by: Ran Benita <ran234@gmail.com>
2016-01-20 23:17:10 +02:00
Kazunobu Kuriyama 91a19905b3 test/x11comp: Fix contention between X11 and Xvfb on Mac OS X
- Abandon use of -displayfd.
 - Have x11comp itself look for an unused X11 display number instead.
2015-08-28 19:37:09 +09:00
Ran Benita 74f85d0540 test/x11comp: remove duplicate FOUR_LEVEL_KEYPAD from test keymap
The `test/data/keymaps/host.xkb` file contains a duplicate definition of
this type. On my computer (linux, xkbcomp 1.3.0, xserver 1.17.2), the
test passes as is, but if I remove the duplicate definition, the
roundtrip brings it back and the test fails. I can also reproduce it
without relation to the test, by loading `test/data/keymaps/host.xkb`
(without the duplicate) using

    xkbcomp -I $(pwd)/test/data/keymaps/host.xkb $DISPLAY

and downloading it again using

    xkbcomp $DISPLAY out.xkb

the duplicate is added. On Mac OS X however, the duplicate is removed
(correctly), so the test fails there.

xkbcommon itself, which was forked from xkbcomp, doesn't have this bug;
in fact, doing

    ./test/print-compiled-keymap -k keymaps/host.xkb

removes the duplicate if it is present.

This is (probably) a regression in xkbcomp or xserver compared to the
versions used in Mac OS X. Since getting a patch for any of these two is
hopeless from my experience, I did not try to investigate further.

I am not sure why, but if I also add a `PC_SUPER_LEVEL2` type, the
duplicate of `FOUR_LEVEL_KEYPAD` doesn't show up. Hopefully the test
will work on all platforms now.

https://github.com/xkbcommon/libxkbcommon/issues/26

Reported-by: @nuko8
Signed-off-by: Ran Benita <ran234@gmail.com>
2015-08-23 23:16:37 +03:00
Ran Benita bdf6880364 test/x11comp: small simplifications
xkbcomp doesn't need the search-path argument, since we pass an absolute
path. Keep the plain -I which clears the search path just to be sure.

Signed-off-by: Ran Benita <ran234@gmail.com>
2015-08-23 23:16:23 +03:00
Ran Benita 8e1fed6c68 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>
2015-03-24 16:49:47 +02:00
Ran Benita 74482de623 test/common: print keycode in decimal not hex
Keycodes are usually written in decimal, so hex is hard to compare.

Signed-off-by: Ran Benita <ran234@gmail.com>
2015-02-03 21:47:08 +02:00
Ran Benita a0d2b02976 test/keyseq: test 'map[None] = Level2;' scenario
See previous commit for an explanation.

Signed-off-by: Ran Benita <ran234@gmail.com>
2014-10-17 01:19:22 +03:00
Ran Benita 312182ce7d test/data: add files for model=applealu_ansi layout=us
Signed-off-by: Ran Benita <ran234@gmail.com>
2014-10-17 01:19:03 +03:00
Ran Benita c6ee6371b5 test/data: sync to xkeyboard-config 2.13
(Run ./test/data/sync.sh).

Signed-off-by: Ran Benita <ran234@gmail.com>
2014-10-17 01:19:03 +03:00
Ran Benita c42b864654 test/compose: test include statement
Signed-off-by: Ran Benita <ran234@gmail.com>
2014-10-14 11:47:25 +03:00
Ran Benita 3f489730d3 test/compose: test modifier syntax
Signed-off-by: Ran Benita <ran234@gmail.com>
2014-10-14 11:36:00 +03:00
Ran Benita 5cefa5c5d0 test/interactive-evdev: add compose support
To try, do e.g.:
sudo ./test/interactive-evdev -l us -v intl -o compose:ralt -d

Signed-off-by: Ran Benita <ran234@gmail.com>
2014-10-05 12:56:46 +03:00
Ran Benita 10a7a2bd69 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>
2014-10-05 12:56:46 +03:00
Ran Benita bc3b4c084a Move benchmarks from tests to their own files in bench/
The tests only contain tests, and the benchmarks are more visible.

Signed-off-by: Ran Benita <ran234@gmail.com>
2014-10-02 22:03:28 +03:00
Ran Benita 68962aa1f9 keymap-dump: combine modifier_map's with the same modifier
A bit less efficient, but makes for shorter, nicer output.

Signed-off-by: Ran Benita <ran234@gmail.com>
2014-09-22 00:05:38 +03:00
Ran Benita 24846080db test/keyseq: add test
Signed-off-by: Ran Benita <ran234@gmail.com>
2014-09-11 14:08:12 +03:00
Ran Benita a931740cc7 keycodes: fix keymap compilation with no aliases and malloc(0)==NULL
If the keymap doesn't have any key-aliases (which is certainly
possible), the calloc(num_key_aliases, ...) is allowed to return NULL
according to the C standard, but this is not an error.

Signed-off-by: Ran Benita <ran234@gmail.com>
2014-09-10 13:44:33 +03:00
Ran Benita ba98562909 test: make most tests portable by copying linux/input.h locally
There is really no reason to deny these tests from different platforms
only for a few #defines.

The only linux-only test (or test program, it is not run by make check)
is interactive-evdev, which actually uses evdev.

Signed-off-by: Ran Benita <ran234@gmail.com>
2014-09-06 11:29:15 +03:00
Pino Toscano e95fb475eb Remove <linux/input.h> include from test/x11comp.c
libxkbcommon 0.4.3 introduces a new test, x11comp, which does not build
on non-Linux OSes because of the unconditional <linux/input.h> include.

This seems not needed even on Linux, so attached there is a simple patch
to remove it.

https://bugs.freedesktop.org/show_bug.cgi?id=83551

Signed-off-by: Ran Benita <ran234@gmail.com>
2014-09-06 11:11:13 +03:00
Ran Benita fc95057c5f test/x11comp: don't hang if Xvfb is not available
If Xvfb is not present, posix_spawn still forks, but the child fails.
In that case, since we left the write fd of the pipe open in the parent,
we just kept waiting on the read() without noticing that the other side
is dead.

Signed-off-by: Ran Benita <ran234@gmail.com>
2014-09-01 17:20:40 +03:00
Ran Benita f3597f1b62 test/state: add test_update_mask() test
Signed-off-by: Ran Benita <ran234@gmail.com>
2014-08-18 21:51:57 +03:00
Ran Benita a95c4e83e4 test/x11comp: server writes \n to displayfd
Signed-off-by: Ran Benita <ran234@gmail.com>
2014-08-18 19:47:10 +03:00
Ran Benita 4df720b464 test/x11-keyseq: new test
It is like test/stringcomp, only instead of using
xkb_keymap_new_from_string(), it uses xkbcomp to upload the keymap to a
dummy Xvfb X server and then xkb_x11_keymap_new_from_device().

If any of these components are not present or fails, the test is shown
as skipped.

The test is messy, fragile, limited and depends on external tools, but I
will improve on that later -- it's better to have a test.

Signed-off-by: Ran Benita <ran234@gmail.com>
2014-08-09 22:57:24 +03:00
Ran Benita 5058620c88 interactive-evdev: don't use sysexits.h
Signed-off-by: Ran Benita <ran234@gmail.com>
2014-07-27 16:36:11 +03:00