Commit graph

6654 commits

Author SHA1 Message Date
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
2d238f1d33 meson.build: drop config.h.meson
This seems to be a leftover from the autotools conversion but it
does not provide huge benefits. Meson's default behavior is to generate a
header like this, the main advantage of a config.h.meson header is to *filter*
things that should show up in the config.h file. That comes at the cost of
having to #mesondefine every single variable we want.

In most cases, it's easier with meson to just use different configuration_data
objects instead - which we do for most of the code.

The new header file is identical to the old one, discounting comments, sort
order and the following #defines that didn't end up in the config.h before:
  HAVE_STRNDUPA
  HAVE_STDDEF_H
2021-06-10 09:31:47 +02:00
Peter Hutterer
0cd0d6e826 meson.build: split the version data into a separate config
Use this for the version.h file so we enforce that being used everywhere
instead of accidentaly relying on whatever ends up in config.h.

The generated version.h file is identical.
2021-06-10 09:30:56 +02:00
Peter Hutterer
b5e98027b7 meson.build: drop VERSION, use PACKAGE_VERSION in the C sources
Slightly better namespaced since it's not usually used anywhere else, VERSION
is too generic.
2021-06-10 09:30:56 +02:00
Peter Hutterer
c4e3efbcf8 meson.build: drop PIPEWIRE_PACKAGE_ORIGIN and PIPEWIRE_LICENSE defines
These seems to be a copy/paste from GST_* but was never actually used anywhere
in our tree.
2021-06-10 09:30:56 +02:00
Peter Hutterer
66abafaa3d meson.build: drop the PIPEWIRE_PACKAGE_NAME define
The only user of this was the dbus protocol, dropped in 7cbdaeb3b6
2021-06-10 09:30:56 +02:00
Peter Hutterer
d1e2ab1eac config.h.meson: remove hack for MacOS 10.5
https://lists.gnu.org/r/bug-autoconf/2020-02/msg00004.html

MacOS 10.6 no longer requires that hack and it predates our initial commit by
6 years (2009 vs 2015), so let's conservatively assume this hack is not needed
here.
2021-06-10 09:30:56 +02:00
Peter Hutterer
478e1cc516 meson.build: define WORDS_BIGENDIAN if need be
Drop the Apple-specific defines from config.h.meson - this was never true in
the meson build anyway as nothing set the AC_APPLE_UNIVERSAL_BUILD and the
else condition only undef'd WORDS_BIGENDIAN if... it was not defined.

Drop this and replace it with a meson endian check. There is only one source
file that checks for this #define in spa/plugins/alsa/acp/compat.h, let's hope
nothing breaks here.
2021-06-10 09:30:56 +02:00
Peter Hutterer
14eb43ea86 meson.build: check for SYS_pidfd_open 2021-06-10 15:19:20 +10:00
Peter Hutterer
18b3efa2ed spa: make two headers compatible with older gcc-c++
c++ 7.5.0 can only initialize structs with continuous members, so let's
initialize the fields explicitly to NULL.

Fixes #1284
2021-06-10 15:19:15 +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
5cf3c28fa4 config.h is a local header, not a system one
Change the #include accordingly, that's what we use in the rest of the tree
too.
2021-06-10 09:04:16 +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
5ba43b8349 audioconvert: add config.h to include directories
Some of the files here #include "config.h"
2021-06-10 09:04:16 +10:00
Peter Hutterer
e38cc427bf spa: fix indentation in audioconvert/meson.build
Was partially using spaces, partially 2-space tabs. Use 2 spaces only and fix
the few lines where the indentation was completely out of whack.
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
1b5ffa7891 filter: init the Latency param correctly
See #911
2021-06-09 21:12:19 +02: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
Wim Taymans
d91cc99d92 properties: escape '/' as well 2021-06-09 18:08:26 +02:00
Wim Taymans
eb8546a682 json: also escape '/' as required by JSON 2021-06-09 18:03:42 +02:00
Wim Taymans
262e609b73 conf: use serialize_dict to write state files
Instead of our home-brew version.
2021-06-09 18:00:47 +02:00
Wim Taymans
54326abd54 properties: improve serialize method
Properly escape the keys because we're trying to generate
valid JSON.
Always place ',' after items.
Add a flag to add a '\n' before each item.
Don't try to string-encode the value when it's already a string.
2021-06-09 17:57:58 +02:00
Wim Taymans
a10cb3a597 jack: unlock mutex on error path
This needs some more fixing because it leaks everything.
2021-06-09 17:57:05 +02:00
Wim Taymans
4b6fb5e96a v4l2: report latency 2021-06-09 17:15:34 +02:00
Wim Taymans
85d34d8d94 conf: add comment about removing sections
Sections that don't need to be changed can be removed because they
are now taken from the main config file.
2021-06-09 15:25:58 +02:00
Wim Taymans
db44fe47ee conf: Load and stack all config files.
Load and parse config files in the following order:

$PIPEWIRE_CONFIG_DIR or /usr/share/pipewire
/etc/pipewire
$XDG_CONFIG_DIR or ~/.config/pipewire

This ensure we always load a working base config and reduce the
chances of failing because of a back user config file.

The user config file now only needs to contain the section that
needs the be changed.

See #207
2021-06-09 12:15:39 +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
Peter Hutterer
0054319d88 meson.build: add -D_GNU_SOURCE to the project arguments
This appends it to every compilation command so we can get rid of the c_args
for (almost all) executables.
2021-06-09 07:47:51 +00:00
Peter Hutterer
fee4d0eae1 spa: switch the include header test to C++ by default
If we have a C++ compiler, compile all the #include tests with that - it'll
pick up any issues that a C compiler will pick up anyway. This saves us from
having a separate C++ compiler test and it'll test each header separately for
C++ compatibility..
2021-06-09 07:43:46 +00:00
Wim Taymans
750cafd7d1 context: use pw_context_destroy() in error cases
Make sure we free all the resources of a context when it can't be
created.
2021-06-09 09:41:50 +02:00
Wim Taymans
c12bdb8c6c pipewire: cleanup on error
To make leak checks more accurate.
2021-06-09 09:41:50 +02:00