Commit graph

33 commits

Author SHA1 Message Date
Peter Hutterer a4bdf83e39 test: explicitly ignore the read() result from the timerfd/pidfd
We don't care about the actual read() being successful - it won't be on pidfd
and on timerfd it's just a timestamp we don't need.
2021-06-21 07:17:10 +00:00
Peter Hutterer f9985636de test: fail if we can't chdir to $TMPDIR
Otherwise our tests may have unpredictable behavior depending on leftover
files in $PWD.
2021-06-21 07:17:10 +00:00
Peter Hutterer 3c798ea413 test: force TMPDIR to /tmp if it is unset
This way we can rely on it everywhere without having multiple checks for it.
2021-06-21 07:17:10 +00:00
Peter Hutterer 00bc5f0e3b test: drop duplicate init of test->result
Set to the same value 5 lines above
2021-06-21 07:17:10 +00:00
Wim Taymans c46cb0645e test: fix test
There is now one more global item.
2021-06-17 11:14:20 +02:00
Peter Hutterer 62e98aa836 test: move some of the property tests to pwtest
Mostly 1:1 move of the test-properties.c file in src to the one in test, but a
few checks were merged into the existing functions.
2021-06-17 07:08:53 +00:00
Peter Hutterer 461ae02c50 test: shut up a compiler warning about an unused variable
gcc 9 complains about `v` being potentially uninitialized. This is a false
positive, we'd exit() on any error before using `v` but the compiler doesn't
seem to know that. Let's shut up the warning.
2021-06-10 20:39:58 +10:00
Peter Hutterer 7177d82c34 test: check for CAP_SYS_PTRACE before testing for an attached debugger
If we don't have the capability to ptrace, we are probably running inside a
container, not the debugger. Check this first so we don't disable forking
mode.

Make this conditional on libcap - where libcap is not available always assume
we *do not* have a debugger attached. This is easier than telling everyone who
runs the tests in a confined system to install libcap.

Fixes #1285
2021-06-10 09:36:12 +02:00
Peter Hutterer 14eb43ea86 meson.build: check for SYS_pidfd_open 2021-06-10 15:19:20 +10:00
Peter Hutterer 731f45ed50 test: add sigabbrev_np() for systems where it's not available
sigabbrev_np() was first added to glibc 2.32 (Aug 2020) which is too recent
for some of the distributions we support.
2021-06-10 15:13:57 +10:00
Peter Hutterer da339c286f meson.build: drop HAVE_CONFIG_H
This is an autotools leftover, with meson we're always guaranteed to have
the config.h file.
2021-06-10 09:04:16 +10:00
Peter Hutterer b2206e2530 test: change VERSION to HOOK_VERSION for the spa hooks test
VERSION is defined in config.h for the project version which will cause a
conflict here.
2021-06-10 09:04:16 +10:00
Wim Taymans 667fa18526 test: fix property test
The long key is now ignored instead of truncated.
2021-06-09 18:17:31 +02:00
Peter Hutterer d09df66aec test: drop the valgrind timeout multiplier to 3
30s * 100 as timeout for a single test is a bit too much.
2021-06-09 19:41:07 +10:00
Peter Hutterer 9a65d90e88 test: move the spa tests to pwtest
Move the spa tests to the pwtest framework. The pod tests have only been
wrapped in the function callers, they don't use the variuos pwtest helpers -
too much work for very little gain here. Can be done incrementally if needed.

Note that this removes the spa tests from the installed tests. Arguably,
installing those tests was unnecessary anyway since they are static binaries
and don't load anything. So having them installed runs the same tests as
having them run in the source tree.

Goal for the pwtest framework is to allow for installed tests, just not there
yet.
2021-06-09 18:00:59 +10:00
Peter Hutterer 008195924c test: add a test for the properties stack overflow
See #1249
2021-06-09 18:00:58 +10:00
Peter Hutterer 7240058bee test: add test for logger's ANSI escape sequences
Set up the logger with colors enabled but since our log file is not a tty,
this should not print any ansi sequences into the log.
2021-06-09 18:00:39 +10:00
Peter Hutterer 518ffde9ec test: add a test for the logger truncation
See c851349f17
2021-06-09 18:00:39 +10:00
Peter Hutterer dcfd6745d0 test: move the context tests to here 2021-06-09 18:00:39 +10:00
Peter Hutterer 53215a66b9 test: hook up a valgrind test run in meson
Use with:
	meson test -C builddir --setup=valgrind
2021-06-09 18:00:39 +10:00
Peter Hutterer 7909c99ead test: convert two spa tests to pwtest 2021-06-09 18:00:39 +10:00
Peter Hutterer 493f0724b5 test: move the array tests to pwtest
Add them to the existing pw_properties test binary and rename that to
pw-utils.

Same functionality as before for the pw_array tests.
2021-06-09 18:00:39 +10:00
Peter Hutterer 3865d8846e test: add a simple test for the library version 2021-06-09 18:00:39 +10:00
Peter Hutterer 44dcca0d99 test: add tests for pw_properties 2021-06-09 18:00:37 +10:00
Peter Hutterer 5911a629f3 test: add an example test for a failing daemon test
If we don't start a daemon from the test suite, we should fail connecting to
one even where a system daemon is running.
2021-06-09 18:00:06 +10:00
Peter Hutterer 28f74dc6b2 test: fall back to a timerfd if pidfd fails
Looks like we don't have pidfd in the CI runners, so let's fall back to a
timerfd that pings us every 20ms in case the test finished.
2021-06-09 18:00:06 +10:00
Peter Hutterer 9bc840efe2 test: detect if we're running through gdb and disable forking mode 2021-06-09 18:00:06 +10:00
Peter Hutterer dc5751b569 test: add a helper function for making tempfiles
Having a helper aids with the file being in the right directory and cleaned up
automatically on exit. Plus, failing the test with the sytem error status code
signals that it's not the actual test failing here.
2021-06-09 18:00:06 +10:00
Peter Hutterer dd3f14d9d6 test: add a function to load a SPA interface
Helper function to load a SPA interface. This enables a test to easily load a
specific interface and run tests against that interface without having to
instantiate a whole pipewire daemon.
2021-06-09 18:00:06 +10:00
Peter Hutterer 50180532a4 test: add errno check macros 2021-06-09 18:00:06 +10:00
Peter Hutterer 2073269f47 test: set PIPEWIRE_REMOTE to a garbage value if we didn't start a test daemon
Don't let tests connect to the system daemon which would happen if we don't
have PIPEWIRE_REMOTE set at all.
2021-06-09 18:00:06 +10:00
Peter Hutterer e01faf42a1 test: give each test its own XDG_RUNTIME_DIR and TMPDIR
On startup, create /tmp/pwtest-$TIME-$RANDOM/ and give each test an
XDG_RUNTIME_DIR and TMPDIR inside that (simply numerically numbered). This
avoids the tests interfering with the system like accidentally connecting to
the real pipewire instance or trying to create files where they shouldn't.
2021-06-09 18:00:06 +10:00
Peter Hutterer ed3f882fa9 test: add the pwtest test framework
Heavily inspired by libinput's litest framework (built around check), this is
a from-scratch framework that simplifies adding tests for various parts of
pipewire. See the pwtest.h documentation for details but the basics are:

- PW_TEST() and PWTEST_SUITE() specify the tests to be run
- Test are run in forked processes, any errors/signals are caught and printed
  to the log
- Tests have a custom pipewire daemon started on demand to talk to [1]. The
  daemon's log is available in the test output.
- Output is YAML to be processed into whatever format needed

[1] There are limits here, since we can't emulate devices yet there is only
so much we can rely on with the daemon.
2021-06-09 18:00:06 +10:00