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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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.
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>
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>
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>
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>