Commit graph

11 commits

Author SHA1 Message Date
Peter Hutterer
cfd8e6c76c Fix a few coverity complaints
All minor:
- execdir does not need initialization, it's not used until written to
- 'newest' could be NULL
- zalloc(-1) confuses coverity
- 't' is never used in that test

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-11-10 14:27:22 +10:00
Peter Hutterer
61553432b0 test: disable coredumps for the selftest
Because on my XPS coredumps take away all the CPU, leading to a test timeout.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-26 21:07:21 +10:00
Peter Hutterer
2185a9d6bd test: return 77 for skip when we're not running a test
This isn't technically needed since those tests aren't in the valgrind test
suite anymore. But let's have it here anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-05-07 04:48:00 +00:00
Peter Hutterer
01efe9de4f test: replace the USING_VALGRIND env with the valgrind.h header
This header is intended to be included in the project, so let's do that and
have proper runtime detection of the valgrind environment.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-05-07 04:48:00 +00:00
Peter Hutterer
ee0f44d438 test: fix zalloc max size tests
Missing from 9873d68bf1

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-06-21 15:02:20 +10:00
Peter Hutterer
793c8d51e8 util: abort if we try to allocate more than a MB
The ssize_t cast upsets coverity for some reason but we can be a lot more
restrictive here anyway. Quick analysis of the zalloc calls in the test suite
show the largest allocation is 9204 bytes.

Let's put a cap on for one MB, anything above that is likely some memory
corruption and should be caught early.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Matheus Santana <embs@cin.ufpe.br>
2018-06-20 11:41:48 +10:00
Peter Hutterer
8865d4a29d util: abort for a negative zalloc() size
Nothing in libinput needs large buffers, so if we ever get something that
large, we probably passed a negative number to zalloc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-06-11 13:43:40 +10:00
Peter Hutterer
82335b0ab9 test: fix compiler warning
litest-selftest.c: In function ‘litest_ptr_eq_notrigger’:
litest-selftest.c:172:10: warning: initialization makes integer from pointer
without a cast [-Wint-conversion]
  int c = NULL;
          ^
litest-selftest.c:173:10: warning: initialization makes integer from pointer
without a cast [-Wint-conversion]
  int d = NULL;
          ^

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-01-20 12:56:35 +10:00
Andreas Pokorny
1309718c00 litest: floating point comparison macros
Adds the macros ck_assert_double_{eq,ne,lt,gt,le,ge} to compare double
values using a fixed tolerance value. The tolerance value is
picked based on the range of values to be expected by the libinput API.

Signed-off-by: Andreas Pokorny <andreas.pokorny@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-07-07 17:49:17 +10:00
Peter Hutterer
dc3dbc4dfc test: add pointer comparison macros
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-18 20:55:48 +10:00
Peter Hutterer
84e6321f51 test: add a backtrace facility to litest
The check unit test framework isn't particularly suited to having ck_assert*
calls in helper functions. A failed assertion in a helper function or the
litest framework merely gives us a the failed line in litest.c.
which doesn't tell us which test actually failed.

Add a backtracing facility with litest_backtrace(). And since this requires
wrapping all ck_assert macros with litest_assert() this patch ended up
replacing/duplicating a bunch of ck_assert_* bits. So rather than
ck_assert_int_eq() we now use litest_assert_int_eq(), etc. in the litest
framework itself.

The int comparison macros are more type-safe than ck_assert()'s macros which
just cast all the ints to intmax_t.

Backtrace is spewed to stderr, which is good enough for debugging. Example
backtrace:

	FAILED COMPARISON: status != expected
	Resolved to: 0 != 0
	in disable_button_scrolling() (pointer.c:115)

	Backtrace:
	0: ./test/test-pointer (litest_fail_comparison_int+0xab) [0x40973b]
	1: ./test/test-pointer (disable_button_scrolling+0x174) [0x40421b]
	2: ./test/test-pointer (middlebutton_middleclick+0x40) [0x40829c]
	3: /lib64/libcheck.so.0 (srunner_run+0x7f5) [0x7f0e8a277025]
	4: ./test/test-pointer (litest_run+0x107) [0x40a42b]
	5: ./test/test-pointer (main+0x2fa) [0x4090e7]
	6: /lib64/libc.so.6 (__libc_start_main+0xf0) [0x7f0e88f5e790]
	7: ./test/test-pointer (_start+0x29) [0x403ce9]
	8: ? (?+0x29) [0x29]

litest_backtrace() itself is copied from xserver/os/backtrace.c which git
blame attributes to Marcin.

CC:  Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-18 20:55:48 +10:00