Commit Graph

50 Commits

Author SHA1 Message Date
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
Kristian Høgsberg
f67f6395b1 tests: Use different connections for read and write tests
The connection tests so far only use one connection at a time, but this
prepares for tests that use a connection on both sides of the socket.
2012-03-23 11:32:17 -04:00
Kristian Høgsberg
7746a80e2a tests: Remove debug printf 2012-03-21 10:32:06 -04:00
Kristian Høgsberg
f48bd0714a tests: Add test case for freeing source with pending data 2012-03-21 10:30:19 -04:00
Ander Conselvan de Oliveira
707623f0cb test: add a unit test for the event loop post dispatch check 2012-03-20 15:49:27 -04:00
Kristian Høgsberg
46df9232fa test-runner.c: Consolidate test running code 2012-03-05 22:29:53 -05:00
Kristian Høgsberg
4bc5a0ab2c tests: Add demarshal tests 2012-03-05 22:26:17 -05:00
Kristian Høgsberg
b2afde6f18 tests: Add more marshal tests 2012-03-05 21:53:38 -05:00
Kristian Høgsberg
d86718fc33 tests: Simplify connection tests a bit 2012-03-05 21:40:01 -05:00
Kristian Høgsberg
efab74e956 tests: Add wl_list tests 2012-03-05 21:38:25 -05:00
Kristian Høgsberg
b4351bc08e tests: More wl_map tests 2012-03-05 21:14:57 -05:00
Gaetan Nadon
c1804b5735 tests: makefile error: missing test-runner.h
Detected by running distcheck

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2012-03-05 10:57:57 -05:00
Gaetan Nadon
bb4b05bc8d check: connection-test fails to link to ffi
This prevents distcheck from completing.
Moving the -lffi at the end of the command fixes the problem.

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2012-03-04 15:03:03 -05:00
Kristian Høgsberg
8e2cac7ae4 Add wl_array_for_each 2012-03-04 13:40:49 -05:00
Kristian Høgsberg
87a1e59992 tests: Add connection marshalling tests 2012-03-03 00:29:21 -05:00
Kristian Høgsberg
22834deca7 tests: Add connection tests 2012-03-02 23:59:50 -05:00
Kristian Høgsberg
d2067508c1 test-runner: Fix warnings 2012-03-02 23:42:07 -05:00
Kristian Høgsberg
e655059256 tests: Print test status after running test
This way assert output will be a line by itself, which is easier to read
and lets editors such as emacs step through failed assertions.
2012-03-02 22:45:28 -05:00
Kristian Høgsberg
62d2569954 tests: Add Unit tests for wl_map and wl_array data structures
We use a simple test-runner helper that runs each test in a separate
process and reports the pass/fail rate at the end.
2012-03-02 18:05:33 -05:00