Commit Graph

90 Commits

Author SHA1 Message Date
Alan Coopersmith
2df83bb122 Add request length checking test cases for some Xinput 2.x requests
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-08 18:09:49 -08:00
Alan Coopersmith
da887726ee Use unique display name for each xi2 test program [v3]
make -j 8 check was sporadically failing in different xi2 tests.
After adding the asserts in the previous commit to catch xkb failure
it became easier to catch the failures and see that multiple tests
were running at once trying to write to /tmp/server-(null).xkm and
then delete it, and interfering with each other.

Putting a unique string into the display variable let them each write
to their own file and not interfere with others.

v2: Fix Linux bits:

  Add #include <errno.h> to get a declaration of
  program_invocation_name on Linux.

  Use only the last portion of the pathname so that the resulting
  display name doesn't contain any slashes.

v3: use program_invocation_short_name on Linux

  This is the same as program_invocation_name, except is has
  stripped off any path prefix.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-10-09 14:15:45 +02:00
Alan Coopersmith
cccba52d15 Abort xi2 tests if ActivateDevice() fails
I was getting segfaults in xi2 tests from trying to copy XKB keyboard
state to NULL pointers with a stack of:
    key=key@entry=0) at xkbActions.c:1189
    sendevent=sendevent@entry=0 '\000') at devices.c:420
    at protocol-xiquerydevice.c:338

which turned out to be due to xkbcomp failure, which was logged in the
test logs as:
XKB: Failed to compile keymap
Keyboard initialization failed. This could be a missing or incorrect setup of xkeyboard-config.

but which was overlooked because the ActivateDevice() return code wasn't
checked and the tests went forward assuming the structures were all
correctly initialized.   This catches the failure closer to the point of
failure, to save debugging time.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-10-02 16:35:58 -07:00
Peter Hutterer
76b3be75b6 Xi: fix modifier offset in XIPassiveGrab swapping function
The request is followed by mask_len 4-byte units, then followed by the actual
modifiers.

Also fix up the swapping test, which had the same issue.

Reported-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2014-01-25 18:54:16 +10:00
Keith Packard
7104f0f338 test/xi2: Clean up -Wshadow warnings
protocol-common declares a bunch of pretty generic names; fix shadows
of these names.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2014-01-22 19:56:32 -08:00
Keith Packard
60014a4a98 Replace 'pointer' type with 'void *'
This lets us stop using the 'pointer' typedef in Xdefs.h as 'pointer'
is used throughout the X server for other things, and having duplicate
names generates compiler warnings.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2014-01-12 10:24:11 -08:00
Keith Packard
fecc7eb1cf xi: More warning cleanup for input
Lots more const char stuff.

Remove duplicate defs of CoreKeyboardProc and CorePointerProc from
test/xi2/protocol-common.c

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-01-12 10:14:50 -08:00
Peter Hutterer
bbef8e46f2 Replace INCLUDES with AM_CPPFLAGS
newer automake gets quite noisy about this.
hw/xfree86/ddc/Makefile.am:7: warning:
'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
and many more of these.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-08-06 13:08:13 +10:00
Maarten Lankhorst
b6e5c4669e test/xi2: fix protocol-xiqueryversion test
The old code was broken and allowed setting client version >= XIVersion,
this was fixed in the previous patch, but updating the value for XIVersion
broke the tests, so fix the tests too.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-08-01 14:56:54 +10:00
Peter Hutterer
8f4820be7a test/xi2: fix compiler warning
protocol-xiwarppointer.c: In function ‘ScreenSetCursorPosition’:
protocol-xiwarppointer.c:71:53: warning: declaration of ‘screen’ shadows a
global declaration [-Wshadow]

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-12-21 13:04:09 +10:00
Keith Packard
0eb1559eb2 Merge remote-tracking branch 'yselkowitz/master'
I checked this patch with diff -w to check that it only affected
whitespace.
2012-12-19 12:22:03 -08:00
Keith Packard
014a5c8a9d Merge remote-tracking branch 'whot/barriers'
Conflicts:
	Xi/xichangehierarchy.c

Small conflict with the patch from

	Xi: don't use devices after removing them

Was easily resolved by hand.

Signed-off-by: Keith Packard <keithp@keithp.com>
2012-12-19 12:09:31 -08:00
Peter Hutterer
d4065493b2 tests/xi2: at protocol conversion test for barrier events
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
2012-12-17 15:03:53 +10:00
Peter Hutterer
a7c97d737e dix: split xi2_mask_isset into a per-device function
For touch selection conflicts, we need to check not only if the mask is set
for the device, but if it is set for only that specific device (regardless
of XIAll*Devices)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-12-12 17:25:16 +10:00
Yaakov Selkowitz
ea1d76d1b6 Fix formatting of address operators
The formatter confused address operators preceded by casts with
bitwise-and expressions, placing spaces on either side of both.
That syntax isn't used by ordinary address operators, however,
so fix them for consistency.

Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-12-05 18:09:48 -06:00
Peter Hutterer
fd214aabf7 input: drop FP1616 macro
The double_to_f1616() functions do the same thing, and they're tested.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2012-11-19 12:12:23 +10:00
Peter Hutterer
7100118c8d AC_SUBST the GLX_SYS_LIBS
libxservertest needs -lpthread from glxapi.c's pthread_once() call. Usually
this would be pulled in by the XORG_LIBS but not when building without Xorg.

This commit has no visible effect on the current tree, preparation for test
cleanups.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2012-06-22 10:49:06 +10:00
Peter Hutterer
43754803c1 test: don't shadow parameter 'len'
protocol-xiquerydevice.c:226:25: warning: declaration of ‘len’ shadows a
parameter [-Wshadow]

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-05-16 10:59:39 +10:00
Peter Hutterer
1bafc9f26b test: fix redundant declaration of "BadDevice"
In file included from protocol-common.c:36:0:
protocol-common.h:36:12: warning: redundant redeclaration of ‘BadDevice’
[-Wredundant-decls]
In file included from protocol-common.c:30:0:
../../Xi/exglobals.h:41:12: note: previous declaration of ‘BadDevice’ was
here

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-05-16 10:59:39 +10:00
Peter Hutterer
47e1d0ea43 test: fix "userdata shadows global declaration" warnings
protocol-xiquerypointer.c:124:72: warning: declaration of
‘userdata’ shadows a global declaration [-Wshadow]

and similar

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-05-16 10:59:39 +10:00
Peter Hutterer
e6da635826 test: fix "redundant declaration of devices" warning
In file included from protocol-xiwarppointer.c:41:0:
protocol-common.h:91:23: warning: redundant redeclaration of ‘devices’
[-Wredundant-decls]
protocol-common.h:86:3: note: previous declaration of ‘devices’ was here

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-05-16 10:59:39 +10:00
Peter Hutterer
ea51e9b287 Xi: return BadValue on XIQueryVersion if the version is less than first call
Clients that use plugin systems may require multiple calls to
XIQueryVersion from different plugins. The current error handling requires
client-side synchronisation of version numbers.

The first call to XIQueryVersion defines the server behaviour. Once cached,
always return that version number to any clients. Unless a client requests a
version lower than the first defined one, then a BadValue must be returned
to be protocol-compatible.

Introduced in 2c23ef83b0

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2012-05-01 11:36:30 +10:00
Peter Hutterer
641a1b9363 test: reset the client before checking the swapped version
As of 2c23ef83b0, the server returns BadValue
for the same client with multiple versions. Avoid this by resetting the
client before we issue the same request as a fake swap client.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Tested-by: Jeremy Huddleston <jeremyhu@apple.com>
2012-03-29 08:14:54 +10:00
Peter Hutterer
17f33ca0e5 test: init the sync extensions for tests to pass again
Introduced in d645edd11e

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Tested-by: Jeremy Huddleston <jeremyhu@apple.com>
2012-03-29 08:14:31 +10:00
Keith Packard
9838b7032e Introduce a consistent coding style
This is strictly the application of the script 'x-indent-all.sh'
from util/modular. Compared to the patch that Daniel posted in
January, I've added a few indent flags:

	-bap
	-psl
	-T PrivatePtr
	-T pmWait
	-T _XFUNCPROTOBEGIN
	-T _XFUNCPROTOEND
	-T _X_EXPORT

The typedefs were needed to make the output of sdksyms.sh match the
previous output, otherwise, the code is formatted badly enough that
sdksyms.sh generates incorrect output.

The generated code was compared with the previous version and found to
be essentially identical -- "assert" line numbers and BUILD_TIME were
the only differences found.

The comparison was done with this script:

dir1=$1
dir2=$2

for dir in $dir1 $dir2; do
	(cd $dir && find . -name '*.o' | while read file; do
		dir=`dirname $file`
		base=`basename $file .o`
		dump=$dir/$base.dump
		objdump -d $file > $dump
	done)
done

find $dir1 -name '*.dump' | while read dump; do
	otherdump=`echo $dump | sed "s;$dir1;$dir2;"`
	diff -u $dump $otherdump
done

Signed-off-by: Keith Packard <keithp@keithp.com>
Acked-by: Daniel Stone <daniel@fooishbar.org>
Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2012-03-21 13:54:42 -07:00
Gaetan Nadon
e08ed0b757 test: add new test cases to .gitignore
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-03-04 20:01:29 -08:00
Chase Douglas
a28ff2cf92 test/xi2: Really fix infinite loop in test_convert_XITouchOwnershipEvent
long i;
for (i = 1; ; i <<= 1)
  if (i == (1 << 31))
    break;

(1 << 31) is compiled as an int, and thus is equal to -2147483648. We
are trying to compare it against a long, which on 64-bit machines is
2147483648. This results in an infinite loop.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2011-12-23 13:18:10 -08:00
Keith Packard
e7df42ab68 test/xi2: Fix infinite loop in test_convert_XITouchOwnershipEvent
The touchid test was using a loop like:

	for(i = 1; i < 0xffffffff; i <<= 1)

When 'i' is a 32-bit variable, this infinite loops as it goes from
0x80000000 to 0. 'i' is declared as 'long', which is 32-bit in 32-bit mode.

Signed-off-by: Keith Packard <keithp@keithp.com>
2011-12-22 09:35:51 -08:00
Peter Hutterer
4551510f75 test: add a basic test for ownership event values
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-21 14:16:37 +10:00
Peter Hutterer
0c661dc478 test: drop printfs from protocol-eventconvert.c
The test outputs are noisy enough, no need having these here too.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-21 14:16:37 +10:00
Peter Hutterer
92c6c0c1d2 tests: update for touch support
Touch event mask must be set for all three event types.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-16 11:18:47 +10:00
Peter Hutterer
218752bdc5 input: replace GRABTYPE_* with the InputLevel enums
They achieve the same thing, re-use the more generic InputLevel so we can
convert to/fro easier.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-13 13:24:08 +10:00
Peter Hutterer
e5aa00989c Change GetXI2/XI/CoreType to just take a type argument
Avoids the dummy-event dance if we have an event type and need to get the
matching XI2 type.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-10 17:54:34 +10:00
Peter Hutterer
b8b90cd161 Add a new XI2Mask struct and a few helper functions.
The current XI2 mask handling is handy for copying (fixed size arrays) but a
pain to deal with otherwise. Add a struct for XI2 masks and the required
accessors.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-09 14:56:23 +10:00
Alan Coopersmith
e47aa94750 Enable memory checking during unit testing
If configure is generated with xorg-macros 1.16.0 or newer, and
an appropriate memory checking library is found for the platform,
use it when running unit tests.   If not, then no harm is done.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-11-23 12:15:05 -08:00
Alan Coopersmith
36670065bd Don't require ld -wrap for tests that don't need it
If configure is generated with xorg-macros 1.16 or later, this allows
builders to --enable-unit-test and run the tests other than the xi2
tests which require ld -wrap (and are still wrapped in if HAVE_LD_WRAP
in tests/xi2/Makefile).  If an older xorg-macros is used, the existing
behaviour is preserved of requiring ld -wrap for all unit tests, but
no side effects occur, so the minimum xorg-macros version is not raised.

If unit testing is enabled without ld -wrap, then we create a bogus
"xi2-tests" script just to report that we're skipping them.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-11-23 12:15:05 -08:00
Dave Airlie
005ab41986 test: fix two more failing FP3232 tests
And put a comment in to explain why we're testing for a frac between .3 and
.6. We can't directly compare the frac since the floating/fixed point
conversion loses precision.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-10-27 08:41:08 +10:00
Peter Hutterer
7500d841f4 test: fix test with new double -> fp3232 conversion functions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2011-10-25 14:06:41 +10:00
Peter Hutterer
8473e441b0 dix: add ScrollInfo to DeviceChangedEvents
3304bbff9b added smooth scrolling support for
pointer events and for XIQueryDevice but didn't add the matching parts to
XIDeviceChangedEvents.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-10-25 14:06:41 +10:00
Peter Hutterer
3304bbff9b Input: Add smooth-scrolling support to GetPointerEvents
For scroll wheel support, we used to send buttons 4/5 and 6/7 for
horizontal/vertical positive/negative scroll events.  For touchpads, we
really want more fine-grained scroll values.  GetPointerEvents now
accepts both old-school scroll button presses, and new-style scroll axis
events, while emitting both types of events to support both old and new
clients.

This works with the new XIScrollClass to mark axes as scrolling axes.
Drivers mark any valuators that send scroll events with SetScrollValuator.
(Currently missing: the XIDeviceChangeEvent being sent when a driver changes
a scroll axis at run-time. This can be added later.)

Note: the SCROLL_TYPE enums are intentionally different values to the XI2
proto values to avoid copy/overlapping range bugs.

Co-authored-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-09-30 09:24:18 +10:00
Daniel Stone
5ac1f885f5 Input: Add POINTER_EMULATED flag to GetPointerEvents
POINTER_EMULATED merely sets XIPointerEmulated in the generated
DeviceEvent.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-09-29 12:26:43 +10:00
Daniel Stone
2d9beeb217 Input: Make DeviceEvent use doubles internally
Change the DeviceEvent InternalEvent to use doubles for its valuators,
instead of data and data_frac.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-09-29 12:24:34 +10:00
Daniel Stone
626f487b97 Input: Make RawDeviceEvent use doubles internally
Change RawDeviceEvent to use doubles for valuators internally, rather
than data(_raw) and data(_raw)_frac.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-09-29 12:24:34 +10:00
Daniel Stone
60a766a96f Input: Add flags to RawDeviceEvent
Add a flags member which will be copied wholesale into the resultant
xXIRawEvent.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2011-09-29 12:23:51 +10:00
Matt Turner
2c7c520cfe Use internal temp variable for swap macros
Also, fix whitespace, mainly around
	swaps(&rep.sequenceNumber)

Reviewed-by: Peter Harris <pharris@opentext.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
2011-09-21 17:12:04 -04:00
Daniel Stone
9444e40d77 Test: Input: Only ever set up to MAX_VALUATORS valuators
Previously, the input tests were working up to sizeof(mask) * 8, which
could be more than the arrays; the latter only being sized as
MAX_VALUATORS.

Hypothetically, if you were switching the stored valuator values to
double instead of uint32_t, and you attempted to set the 39th member of
a MAX_VALUATORS-sized (36) array, you'd probably end up smashing
ev->key_repeat into oblivion and then tripping the check for invalid
flags because you haven't yet put XIPointerEmulated into the valid flags
for XI_Motion.  Probably.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-07-01 08:46:28 +10:00
Gaetan Nadon
6326b0f074 Update .gitignore as new tests have been added
Refactor to follow the pattern one Makefile, one .gitignore
where needed.

Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
Signed-off-by: Keith Packard <keithp@keithp.com>
2011-06-22 10:45:25 -07:00
Peter Hutterer
d9bda34d0d test: fix memset size for WindowRec (#37801)
X.Org Bug 37801 <http://bugs.freedesktop.org/show_bug.cgi?id=37801>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Cyril Brulebois <kibi@debian.org>
Signed-off-by: Keith Packard <keithp@keithp.com>
2011-06-02 23:21:26 -07:00
Nicolas Kaiser
79b3a7f83d test/xi2: remove duplicated include
Remove duplicated include.

Signed-off-by: Nicolas Kaiser <nikai@nikai.net>
Reviewed-by: Matthieu Herrb <matthieu.herrb@laas.fr>
2011-04-25 10:45:34 -07:00
Peter Hutterer
196d679bed test: remove glib dependency
The few features from the glib test suite we used can be replaced with
assert and printf. This patch is a simple replacement for these two
    g_assert → assert
    g_test_message → printf

g_test_init is removed and so is g_test_bug_base. g_test_run replaced with a
simple return 0.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Acked-by: Gaetan Nadon <memsize@videotron.ca>
2011-04-21 13:43:43 +10:00