Commit Graph

68 Commits

Author SHA1 Message Date
Rob Bradford
c95c2dffb0 tests: Allow disabling leak checking assertions by env
Some code coverage tools trigger these assertions when run against the test
suite since they don't free all their memory.
2012-08-29 14:10:20 -04:00
Philipp Brüschweiler
0a633704e6 socket-test: don't try to be clever, fail if no XDG_RUNTIME_DIR is set
Not only setenv(), also putenv() allocates memory on my system
(glibc 2.16.0). Just fail with a clear message if XDG_RUNTIME_DIR is
not set.

https://bugs.freedesktop.org/show_bug.cgi?id=52618
2012-08-14 10:10:47 -04:00
Daniel Stone
3ec40512c7 More consistent ID printing
Use unsigned rather than signed for IDs, so they match up with what we
see in other prints.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-23 20:17:10 -04:00
Kristian Høgsberg
a2c79b14a1 tests: Wrap calloc by just returning NULL if we're called too early
Since glibc dlsym() calls calloc, we get a call to our calloc wrapper as
we try to look up the real calloc implementation.  dlsym() will fall back
to a static buffer in case calloc returns NULL, so that's what we'll do.

This is all highly glibc dependent, of course, but the entire malloc
weak symbol wrapper mechanism is, so there's no loss of generality here.
2012-07-23 20:14:33 -04:00
Daniel Stone
61e9196f56 test-runner: Wrap realloc() too
So all our tests don't start failing just because we had the temerity to
use realloc() rather than malloc().

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-23 16:40:58 -04:00
Christopher James Halse Rogers
161c690b55 protocol: Add explicit nullable types
Most of the time it does not make sense to pass a NULL object, string, or array
to a protocol request. This commit adds an explicit “allow-null” attribute
to mark the request arguments where NULL makes sense.

Passing a NULL object, string, or array to a protocol request which is not
marked as allow-null is now an error. An implementation will never receive
a NULL value for these arguments from a client.

Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
2012-07-02 13:53:02 -04:00
Dylan Noblesmith
d2bcffc470 tests: test that path names longer than 108 bytes are rejected
These would either overflow the struct sockaddr_un, or
be truncated and leave a non-null-terminated string.
2012-06-30 20:01:20 +00:00
Dylan Noblesmith
b486e3aba5 tests: fix make check for out-of-tree builds
It was failing with missing include files.

While here, destroy the ugly "../src/..." include
paths used in the tests that was just hacking around
this problem in the Makefile:

sed -i s/..\\/src\\/// tests/*.c
2012-06-30 19:58:37 +00:00
Dylan Noblesmith
c394b75958 tests: sort list of tests 2012-06-30 19:58:37 +00:00
Kristian Høgsberg
b576443a0e tests: Update test cases to new closure allocate convention 2012-06-15 16:09:39 -04:00
Pekka Paalanen
b858a1b87b tests: update gitignore
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-05-29 10:10:07 -04:00
Pekka Paalanen
32ec041333 tests: add noop to fixed-benchmark
I was just curious of how much the looping takes time without
conversion, so I added this.

My results on Intel(R) Core(TM) i5-2410M CPU @ 2.30GHz:

benchmarked noop:	1.876349827s
benchmarked magic:	2.245844470s
benchmarked div:	12.709085309s
benchmarked mul:	7.504838141s

Mul seems to take 15x the time magic does, cool!

Btw. the simple default cast of int32_t to double is slower than magic
for me, hence the use of union.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-05-15 11:00:19 -04:00
Kristian Høgsberg
f5df38959b Optimize wl_fixed_t to/from double conversion functions 2012-05-14 09:36:38 -04:00
Daniel Stone
c5aba11acc Add support for signed 24.8 decimal numbers
'fixed' is a signed decimal type which offers a sign bit, 23 bits of
integer precision, and 8 bits of decimal precision.  This is exposed as
an opaque struct with conversion helpers to and from double and int on
the C API side.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-08 14:40:39 -04:00
Kristian Høgsberg
f42d763cd0 tests: prefix event loop tests with event_loop_ 2012-05-08 09:58:01 -04:00
Kristian Høgsberg
d8dda50d27 tests: assert that mask is zero is post_dispatch callback 2012-05-08 09:57:17 -04:00
Kristian Høgsberg
550e8f3861 tests: Add timerfd test 2012-05-08 09:55:55 -04:00
Kristian Høgsberg
d56af2787e tests: Add signal test case
Doesn't necessarily catch the signalfd bug just fixed, since that only
triggers when an uninitialized int is negative.
2012-05-08 09:41:37 -04:00
Daniel Stone
0a828e098c tests: Fix out-of-tree builds
Make sure we include any generated headers from src/ as well, like
wayland-version.h.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-02 16:01:04 -04:00
Kristian Høgsberg
bf1c2f3257 tests: Just list tests under the TESTS variable 2012-04-26 08:06:43 -04:00
Pekka Paalanen
ff50f6bfc4 os: wrap accept4(SOCK_CLOEXEC)
Some system C libraries do not have SOCK_CLOEXEC, and completely miss
accept4(), too. Provide a fallback for this case.

This changes the behaviour: no error messages are printed now for
failing to set CLOEXEC but the file descriptor is closed.

The unit test for this wrapper is NOT included.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-25 09:37:42 +03:00
Pekka Paalanen
b2eaf870cf os: wrap epoll_create
Some system C libraries do not have epoll_create1() nor EPOLL_CLOEXEC,
provide a fallback.

Add tests for the wrapper.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-25 09:37:42 +03:00
Pekka Paalanen
35d5053c62 os: wrap recvmsg(MSG_CMSG_CLOEXEC)
Some system C libraries do not have MSG_CMSG_CLOEXEC. This flag would
automatically set O_CLOEXEC flag on any received file descriptors.

Provide a fallback that does it manually. If setting CLOEXEC fails, the
file descriptor is closed immediately, which will lead to failures but
avoid leaks. However, setting CLOEXEC is not really expected to fail
occasionally.

Add tests for the wrapper. The setup is copied from connection-test.c.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-25 09:37:42 +03:00
Pekka Paalanen
2ccaf918ab tests: silence warnings from pipe()
warning: ignoring return value of ‘pipe’, declared with attribute
warn_unused_result

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-25 09:32:58 +03:00
Pekka Paalanen
1463a41f89 os: wrap F_DUPFD_CLOEXEC
Some system C libraries do not have F_DUPFD_CLOEXEC. Provide a fallback.

Add tests for the new wl_os_dupfd_cloexec() wrapper.

Add per-wrapper call counters in os_wrappers-test.c. Makes it easier to
determine the minimum required number of wrapped calls.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-25 09:32:58 +03:00
Pekka Paalanen
3b29783dc8 os: define SOCK_CLOEXEC on Linux
If it's not already defined, and we are on Linux, #define it. This gets
rid of a load of #ifdefs. This should also allow to use it when the
kernel supports it, but the libc does not define it.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-25 09:32:57 +03:00
Kristian Høgsberg
e7dd32710f tests: Test invoking closures built with wl_closure_vmarshal() 2012-04-22 14:17:27 -04:00
Kristian Høgsberg
1901d66ffc connection: Move closure object out of wl_connection 2012-04-22 13:49:35 -04:00
Pekka Paalanen
f52a901f88 tests: add .gitignore
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-20 16:28:15 +03:00
Pekka Paalanen
7134a439c1 os: wrap socket(SOCK_CLOEXEC) calls
Some system C libraries do not offer SOCK_CLOEXEC flag.

Add a new header for OS compatibility wrappers. Wrap socket() calls into
wl_os_socket_cloexec() which makes sure the O_CLOEXEC flag gets set on
the file descriptor.

On systems having SOCK_CLOEXEC this uses the old socket() call, and
falls back if it fails due to the flag (kernel not supporting it).

wayland-os.h is private and not exported.

Add close-on-exec tests for both normal and forced fallback paths.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-20 16:26:37 +03:00
Pekka Paalanen
da6b1a8e47 tests: support testing fd inheritance over exec
Add facility for testing how (many) file descriptors survive an exec.
This allows implementing O_CLOEXEC tests.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-20 15:06:27 +03:00
Pekka Paalanen
7c0aa1a4a3 tests: plug fd leaks in free_source_with_data
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-20 14:58:31 +03:00
Pekka Paalanen
e0561ac68d tests: detect fd leaks
Detect file descriptor leaks in tests.

Add a sanity test to verify that we catch the leaks.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-20 14:58:31 +03:00
Kristian Høgsberg
d44074900d tests: Add more sanity test to make sure we catch different failure modes 2012-04-19 12:37:40 -04:00
Kristian Høgsberg
41570a5ed9 tests: Make sure unused malloc() doesn't get optimized away 2012-04-19 12:07:20 -04:00
Pekka Paalanen
55489883c4 tests: add sanity-test
Test the testing framework itself, so that it catches the errors we
expect it to.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-19 14:46:52 +03:00
Pekka Paalanen
bb74adbc4d tests: add support for tests expected to fail
Add a new macro FAIL_TEST that can be used to define tests that are
supposed to fail. To distinguish the supposed outcome of a test, add a
field to 'struct test'.

However, simply adding a field to 'struct test' will make all tests past
the first one in an executable to be garbage. Apparently, the variables
of type 'struct test' have different alignment when put into a special
section than otherwise, and the compiler will get the skip from one
'struct test' to the next wrong.

Explicitly specify the alingment of 'struct test' to be 16 bytes, which
is what it seems to be in the special section on x86_64.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-19 14:26:51 +03:00
Pekka Paalanen
56426d8a4a tests: stylish test-runner.c
Fix a typo, add a comment, change the print format, and add a variable
that will ease implementing tests that are expected to fail.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-19 14:06:08 +03:00
Pekka Paalanen
b1d4eb24c6 tests: fail build if NDEBUG is defined
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-19 12:14:19 +03:00
Pekka Paalanen
84464a3e9b tests: put common test source files in a variable
Makes all test targets have the same common make dependencies.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-19 12:12:13 +03:00
Kristian Høgsberg
b68b5e9e0c tests: Make leak check work again by setting default visibility for malloc/free
We compile the test cases with -fvisibility=hidden which makes
our malloc/free wrappers fail to override system malloc/free.
2012-04-13 10:13:49 -04:00
Kristian Høgsberg
d8b66a00f4 tests: Fix warning in memory leak assert 2012-04-13 10:13:21 -04:00
Kristian Høgsberg
ac06144cc9 tests: Fix signedness warnings 2012-04-13 10:11:11 -04:00
Kristian Høgsberg
fa5f7b1191 server: Add client destroy signal 2012-04-13 09:53:15 -04:00
U. Artie Eoff
a0e590a0f3 Add simple memory leak check to all tests.
Wrap all tests with a memory balance check to detect potential
memory leaks.
Fixed a few tests that had memory leaks contained in the tests
themselves.

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2012-03-24 14:37:42 -04:00
Kristian Høgsberg
9086b60d81 connection-test: Add test case to stress connection buffers
This catches the bug fixed in cab70c9e5d.
2012-03-24 14:35:53 -04:00
Kristian Høgsberg
b01ae07727 connection-test: Test fd transport 2012-03-24 14:27:30 -04:00
Kristian Høgsberg
fa4769cadd connection-test: Add more test cases 2012-03-23 16:57:34 -04:00
Kristian Høgsberg
33ad8a3315 connection-test: Store expected result in struct marshal_data 2012-03-23 16:56:19 -04:00
Kristian Høgsberg
0ca52cce98 tests: Add marshal+demarshal connection test 2012-03-23 11:41:34 -04:00