Commit graph

13 commits

Author SHA1 Message Date
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