summaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)AuthorFilesLines
2012-10-10Change filedescriptor API to be thread safeKristian Høgsberg2-88/+25
The update callback for the file descriptors was always a bit awkward and un-intuitive. The idea was that whenever the protocol code needed to write data to the fd it would call the 'update' function. This function would adjust the mainloop so that it polls for POLLOUT on the fd so we can eventually flush the data to the socket. The problem is that in multi-threaded applications, any thread can issue a request, which writes data to the output buffer and thus triggers the update callback. Thus, we'll be calling out with the display mutex held and may call from any thread. The solution is to eliminate the udpate callback and just require that the application or server flushes all connection buffers before blocking. This turns out to be a simpler API, although we now require clients to deal with EAGAIN and non-blocking writes. It also saves a few syscalls, since the socket will be writable most of the time and most writes will complete, so we avoid changing epoll to poll for POLLOUT, then write and then change it back for each write.
2012-08-29tests: Quiet warningKristian Høgsberg1-1/+2
2012-08-29tests: ensure sanity leak check tests pass when leak checks are disabled.U. Artie Eoff2-1/+13
This finalizes Robert Bradfords patch to allow NO_ASSERT_LEAK_CHECK environment variable to disable leak checks in unit tests. Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2012-08-29tests: Allow disabling leak checking assertions by envRob Bradford1-2/+4
Some code coverage tools trigger these assertions when run against the test suite since they don't free all their memory.
2012-08-14socket-test: don't try to be clever, fail if no XDG_RUNTIME_DIR is setPhilipp Brüschweiler1-11/+10
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-07-23More consistent ID printingDaniel Stone1-1/+1
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-23tests: Wrap calloc by just returning NULL if we're called too earlyKristian Høgsberg1-0/+13
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-23test-runner: Wrap realloc() tooDaniel Stone1-1/+11
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-02protocol: Add explicit nullable typesChristopher James Halse Rogers1-4/+83
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-06-30tests: test that path names longer than 108 bytes are rejectedDylan Noblesmith2-1/+86
These would either overflow the struct sockaddr_un, or be truncated and leave a non-null-terminated string.
2012-06-30tests: fix make check for out-of-tree buildsDylan Noblesmith11-12/+13
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-30tests: sort list of testsDylan Noblesmith1-9/+9
2012-06-15tests: Update test cases to new closure allocate conventionKristian Høgsberg2-38/+36
2012-05-29tests: update gitignorePekka Paalanen1-0/+2
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-05-15tests: add noop to fixed-benchmarkPekka Paalanen1-0/+16
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-14Optimize wl_fixed_t to/from double conversion functionsKristian Høgsberg3-1/+186
2012-05-08Add support for signed 24.8 decimal numbersDaniel Stone1-0/+26
'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-08tests: prefix event loop tests with event_loop_Kristian Høgsberg1-2/+2
2012-05-08tests: assert that mask is zero is post_dispatch callbackKristian Høgsberg1-0/+1
2012-05-08tests: Add timerfd testKristian Høgsberg1-1/+31
2012-05-08tests: Add signal test caseKristian Høgsberg1-0/+28
Doesn't necessarily catch the signalfd bug just fixed, since that only triggers when an uninitialized int is negative.
2012-05-02tests: Fix out-of-tree buildsDaniel Stone1-1/+1
Make sure we include any generated headers from src/ as well, like wayland-version.h. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-04-26tests: Just list tests under the TESTS variableKristian Høgsberg1-4/+2
2012-04-25os: wrap accept4(SOCK_CLOEXEC)Pekka Paalanen1-0/+2
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-25os: wrap epoll_createPekka Paalanen1-0/+51
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-25os: wrap recvmsg(MSG_CMSG_CLOEXEC)Pekka Paalanen1-0/+175
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-25tests: silence warnings from pipe()Pekka Paalanen1-3/+5
warning: ignoring return value of ‘pipe’, declared with attribute warn_unused_result Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-25os: wrap F_DUPFD_CLOEXECPekka Paalanen1-3/+67
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-25os: define SOCK_CLOEXEC on LinuxPekka Paalanen1-7/+1
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-22tests: Test invoking closures built with wl_closure_vmarshal()Kristian Høgsberg1-0/+38
2012-04-22connection: Move closure object out of wl_connectionKristian Høgsberg2-23/+23
2012-04-20tests: add .gitignorePekka Paalanen1-0/+10
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-20os: wrap socket(SOCK_CLOEXEC) callsPekka Paalanen2-1/+107
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-20tests: support testing fd inheritance over execPekka Paalanen5-4/+124
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-20tests: plug fd leaks in free_source_with_dataPekka Paalanen1-0/+5
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-20tests: detect fd leaksPekka Paalanen5-1/+68
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-19tests: Add more sanity test to make sure we catch different failure modesKristian Høgsberg1-0/+33
2012-04-19tests: Make sure unused malloc() doesn't get optimized awayKristian Høgsberg1-0/+2
2012-04-19tests: add sanity-testPekka Paalanen2-0/+54
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-19tests: add support for tests expected to failPekka Paalanen2-3/+17
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-19tests: stylish test-runner.cPekka Paalanen1-6/+16
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-19tests: fail build if NDEBUG is definedPekka Paalanen1-0/+4
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-19tests: put common test source files in a variablePekka Paalanen1-6/+8
Makes all test targets have the same common make dependencies. Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-13tests: Make leak check work again by setting default visibility for malloc/freeKristian Høgsberg1-2/+4
We compile the test cases with -fvisibility=hidden which makes our malloc/free wrappers fail to override system malloc/free.
2012-04-13tests: Fix warning in memory leak assertKristian Høgsberg1-1/+1
2012-04-13tests: Fix signedness warningsKristian Høgsberg3-8/+8
2012-04-13server: Add client destroy signalKristian Høgsberg2-1/+95
2012-03-24Add simple memory leak check to all tests.U. Artie Eoff5-1/+37
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-24connection-test: Add test case to stress connection buffersKristian Høgsberg1-0/+22
This catches the bug fixed in cab70c9e5d8c38260a07bb1ddb7618826a120465.
2012-03-24connection-test: Test fd transportKristian Høgsberg1-0/+24