aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test-runner.c
Commit message (Collapse)AuthorAgeFilesLines
* build: fix build and provide compat for OpenBSDSébastien Marie2024-02-211-0/+7
| | | | | | | | | | - wayland-egl-abi-check: try to use llvm-nm first instead of BSD nm (incompatible options) - avoid forcing _POSIX_C_SOURCE=200809L (SOCK_CLOEXEC become available) - epoll(7) is provided by a userspace wrapper around kqueue(2) as FreeBSD - when using SO_PEERCRED, the struct to use is `struct sockpeercred` instead of `struct ucred` on OpenBSD - provide a compatibility layer for count_open_fds() using sysctl(2) as FreeBSD Signed-off-by: Sebastien Marie <semarie@online.fr>
* compat: prefer waitpid() over waitid()Sébastien Marie2024-02-211-13/+8
| | | | | | while both are defined by POSIX, waitpid() is more common than waitid(). Signed-off-by: Sebastien Marie <semarie@online.fr>
* Check that XDG base directories paths are absoluteAntonin Décimo2022-06-091-2/+2
| | | | | | | | | | | | | | | | | | | The [spec][1] reads: > All paths set in these environment variables must be absolute. If an > implementation encounters a relative path in any of these variables it should > consider the path invalid and ignore it. and > If $XDG_DATA_HOME is either not set or empty, a default equal to > $HOME/.local/share should be used. Testing that the path is absolute also entails that is is non-empty. [1]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html Signed-off-by: Antonin Décimo <antonin.decimo@gmail.com>
* test-runner: Implement is_debugger_attached() for FreeBSDAlex Richardson2021-09-101-0/+22
| | | | | | FreeBSD provides a PROC_TRACE_STATUS procctl(2) to detect this directly. Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
* log: remove "%m" from format strings by using strerror(errno)Antonio Borneo2019-05-021-1/+2
| | | | | | | | | | | | | | | | | The printf() format specifier "%m" is a glibc extension to print the string returned by strerror(errno). While supported by other libraries (e.g. uClibc and musl), it is not widely portable. In Wayland code the format string is often passed to a logging function that calls other syscalls before the conversion of "%m" takes place. If one of such syscall modifies the value in errno, the conversion of "%m" will incorrectly report the error string corresponding to the new value of errno. Remove all the occurrences of the specifier "%m" in Wayland code by using directly the string returned by strerror(errno). Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
* tests: Remove memory leak checking infrastructureDaniel Stone2018-08-291-69/+10
| | | | | | | | | | | | | There are far better ways to detect memory leaks, such as either valgrind or ASan. Having Meson makes it really easy to use these tools in our tests, and we can do that in CI as well. Having these local wrappers actually completely broke ASan usage, so remove them in favour of using the more powerful options. Signed-off-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
* tests: Use unique XDG_RUNTIME_DIRDaniel Stone2016-11-101-1/+2
| | | | | | | | | | | | Rather than using a hardcoded 'wayland-tests' directory under the existing XDG_RUNTIME_DIR to use as the new runtime dir, use mkdtemp to guarantee uniqueness. This fixes make -jN check, as well as just happening to run 'make check' twice from the same session. Signed-off-by: Daniel Stone <daniels@collabora.com> Reported-by: Pekka Paalanen <pekka.paalanen@collabora.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Tested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* tests: fix typoEric Engestrom2016-05-021-1/+1
| | | | | | Signed-off-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Armin Krezović <krezovic.armin@gmail.com> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
* tests: Update boilerplate from MIT X11 license to MIT Expat licenseBryce Harrington2015-06-121-16/+19
| | | | | Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* tests: Fix FAIL in sanity-test (*timeout*) when Yama LSM enabledBryce Harrington2015-02-061-11/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a regression in the testsuite since c3653f7f, where four of the timeout tests fail with "Timeouts suppressed" messages. The timeouts are being suppressed because the testsuite is erroneously detecting that a debugger is attached. This detection mechanism (adopted from libinput) uses ptrace to test if there is a debugger parent process that can be attached. Unfortunately, this is an unreliable test: Kernel security policies exist to restrict the scope of ptrace to prevent processes from snooping on one another.[1] This security policy is set as the default on Ubuntu, and potentially other Linux distributions.[2] The Yama documentation suggests, "For software that has defined application-specific relationships between a debugging process and its inferior (crash handlers, etc), prctl(PR_SET_PTRACER, pid, ...) can be used. An inferior can declare which other process (and its descendents) are allowed to call PTRACE_ATTACH against it." This prctl call has no effect if Yama LSM is not loaded. The child needs to be synchronized to the client to prevent a race condition where the child might try to operate before the parent has finished its prctl call. This synchronization is done via pipes. This patch can be tested by running sanity-test with /proc/sys/kernel/yama/ptrace_scope set to 0 or 1; the test must pass for either value. 1: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=2d514487faf188938a4ee4fb3464eeecfbdcf8eb 2: https://wiki.ubuntu.com/SecurityTeam/Roadmap/KernelHardening#ptrace_Protection Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Derek Foreman <derekf@osg.samsung.com> v4: Allow parent to communicate error state to child to prevent leaving child in zombie state if parent hits an error. v5: Check errno instead of rc for error. Don't waitpid on ppid. Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
* test-runner: wait for concrete pidMarek Chalupa2015-02-041-1/+1
| | | | | | | | | | | | | After running a test in fork, we were waiting for any child to terminate. It is OK unless the child forks again. If the child calls fork, the waitid can catch the child's child termination, stop block and run another test while the former test is still running. This is racy i. e. when adding socket. Since we have test compositor which uses fork, this situation can occur pretty frequently. Signed-off-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com> Reviewed-by: Daniel Stone <daniels@collabora.com>
* tests: add possibility to disable leak check for single testMarek Chalupa2015-01-281-0/+2
| | | | | | | | | | In tests that are using external libraries (i. e. pthread) we can get failure because of leaks in the external library. Until we have some better solution (if ever), let these (and only these) tests to disable leak checks. Signed-off-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Daniel Stone <daniels@collabora.com>
* test-runner: move leak checking into functionMarek Chalupa2015-01-281-19/+35
| | | | | | | | 1) now we can use it in the test-compositor 2) it looks better Signed-off-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Daniel Stone <daniels@collabora.com>
* tests: Correct return code handlingBryce Harrington2015-01-261-2/+2
| | | | | Reviewed-by: Marek Chalupa <mchqwerty@gmail.com> Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
* tests: Fix typo "evnironment"Bryce Harrington2015-01-261-1/+1
| | | | | Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>
* tests: detect if debugger is attachedMarek Chalupa2014-12-011-3/+41
| | | | | | | | | | | | | Copy function from libinput/test/litest.c is_debugger_detached() and use it in our test-runner. If debugger is attached, turn off leak checks and timeouts automatically. Revision of libinput: 028513a0a723e97941c39c4aeb17433198723913 v2. rebased to master Signed-off-by: Marek Chalupa <mchqwerty@gmail.com> Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* tests: use color when printing on terminalMarek Chalupa2014-11-281-7/+45
| | | | | | | Colorize output of the tests when prinitng on terminal. Signed-off-by: Marek Chalupa <mchqwerty@gmail.com> Tested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* test-runner: print separator line after each test-caseMarek Chalupa2014-11-281-0/+3
| | | | | | Who can read the output when it is a single piece of text? Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
* tests: rename env vars for testsMarek Chalupa2014-11-281-3/+6
| | | | | | | | | | | | | | Rename WAYLAND_TESTS_NO_TIMEOUTS to WAYLAND_TEST_NO_TIMEOUTS. Further rename NO_ASSERT_LEAK_CHECK to WAYLAND_TEST_NO_LEAK_CHECK. Now the naming is consistent not only here, in Wayland, but even with naming of weston env varibles related to testing. This is version 2 of the patch. The first version just renamed NO_ASSERT_LEAK_CHECK to WAYLAND_TEST_NO_LEAK_CHECK. Signed-off-by: Marek Chalupa <mchqwerty@gmail.com> Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Acked-by: Bryce Harrington <b.harrington@samsung.com>
* tests: don't print '\0' characterMarek Chalupa2014-11-191-2/+2
| | | | | | | print "" (which results in no output) instead of printing '\0' (which is not visible, but is there) Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
* tests: add timeoutMarek Chalupa2014-11-171-0/+47
| | | | | | | | | | | | | | | | Add test_set_timeout() function that allows the test to set timeout for its completition. Any other call to the function re-sets the timeout to the new value. The timeouts can be turned off (usefull when debugging) by setting evironment variable WAYLAND_TESTS_NO_TIMEOUTS. v2: rename NO_TIMEOUTS to WAYLAND_TESTS_NO_TIMEOUTS use unsigned int as argument of test_set_timeout() improve printing of the message about timeout Signed-off-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* tests: use our own XDG_RUNTIME_DIR for testsMarek Chalupa2014-11-101-0/+52
| | | | | | | | | | Use $XDG_RUNTIME_DIR/wayland-tests for tests. This way we won't be messing XDG_RUNTIME_DIR and it also fixes a bug, when socket-test failed when another compositor was running. Signed-off-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* tests: extended message when leak in test is detectedMarek Ch2013-09-211-3/+14
| | | | | When memory or fd leak is detected, print how many blocks of memory were allocated and not freed, respectively how many files were opened/unclosed.
* tests: Add a help message for the test runnerKristian Høgsberg2013-02-111-1/+22
| | | | | In case we forget the name of the test case or typo it, the test runner will now list the test cases in the test binary.
* tests: ensure sanity leak check tests pass when leak checks are disabled.U. Artie Eoff2012-08-291-1/+5
| | | | | | | 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>
* tests: Allow disabling leak checking assertions by envRob Bradford2012-08-291-2/+4
| | | | | Some code coverage tools trigger these assertions when run against the test suite since they don't free all their memory.
* tests: Wrap calloc by just returning NULL if we're called too earlyKristian Høgsberg2012-07-231-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.
* test-runner: Wrap realloc() tooDaniel Stone2012-07-231-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>
* tests: detect fd leaksPekka Paalanen2012-04-201-0/+4
| | | | | | | | 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>
* tests: add support for tests expected to failPekka Paalanen2012-04-191-0/+3
| | | | | | | | | | | | | | | | | 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>
* tests: stylish test-runner.cPekka Paalanen2012-04-191-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>
* tests: Make leak check work again by setting default visibility for malloc/freeKristian Høgsberg2012-04-131-2/+4
| | | | | We compile the test cases with -fvisibility=hidden which makes our malloc/free wrappers fail to override system malloc/free.
* tests: Fix warning in memory leak assertKristian Høgsberg2012-04-131-1/+1
|
* Add simple memory leak check to all tests.U. Artie Eoff2012-03-241-0/+27
| | | | | | | | | 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>
* test-runner.c: Consolidate test running codeKristian Høgsberg2012-03-051-16/+23
|
* test-runner: Fix warningsKristian Høgsberg2012-03-021-1/+2
|
* tests: Print test status after running testKristian Høgsberg2012-03-021-1/+1
| | | | | 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.
* tests: Add Unit tests for wl_map and wl_array data structuresKristian Høgsberg2012-03-021-0/+92
We use a simple test-runner helper that runs each test in a separate process and reports the pass/fail rate at the end.