Commit graph

55 commits

Author SHA1 Message Date
Peter Hutterer b00bc81929 test: fix a use-of-uninitialized-variable compiler warning
False positive, we abort in the cases where this isn't initialized.

Fixes e1672f9762
2021-09-22 12:15:33 +10:00
Peter Hutterer dfb40fb714 test: implement a test for the journal logger 2021-09-20 07:29:03 +00:00
Peter Hutterer 0cbd56f0cd spa: declare a dependency for each used library in meson.build
For SPA libraries that we link against elsewhere in the tree, declare a
declare a dependency "foo_dep" for that library that specifies how to
link to it. Then use that dependency in the various targets.

This removes the knowledge of how to link with the library from the
target which can treat it as just another dependency.

In the case of optional libraries (e.g. the journal support lib) we can
then use declare_dependency() to declare an empty dependencies and thus
link them unconditionally in the target.
2021-09-20 07:29:03 +00:00
Peter Hutterer e1672f9762 pipewire: allow for log level names in PIPEWIRE_DEBUG
Allow one of "XEWIDT" to refer to none, errors, warnings, info, debug
and trace, respectively because they're immediately recognizable. Well,
except maybe the X.

PIPEWIRE_DEBUG="I" is equivalent to PIPEWIRE_DEBUG="3" for example.
2021-09-10 07:38:20 +00:00
Peter Hutterer 0a21d76334 test: add tests for the log levels to show up correctly
Two tests, once with pw_log_set_level(), once with PIPEWIRE_DEBUG
2021-09-10 07:38:20 +00:00
Nils Tonnätt dd12910769 Revert "[Meson] Fix all deprecation warnings"
This reverts commit f7e1175ef0.
2021-08-08 19:18:40 +00:00
Nils Tonnätt f7e1175ef0 [Meson] Fix all deprecation warnings 2021-08-06 07:56:16 +00:00
Nils Tonnätt 761fa6f59d meson: fix meson test without building pipewire before
This adds project internal dependencies to some tests to let all
tests succeed. It is not adding all dependencies those tests actually
need.
2021-08-04 20:38:30 +02:00
Peter Hutterer d0060fbddd test: move the client and utils tests over here 2021-08-04 07:45:06 +00:00
Peter Hutterer 49f3d5842e test: replace all spa_assert() macros with spa_assert_se()
These are tests, we never want those to be optimized away.
2021-07-27 10:24:44 +10:00
Peter Hutterer 731888fcdd test: fix a memleak in the config tests
Fixes bba9edabee
2021-07-07 11:03:23 +00:00
Peter Hutterer 4f49e893c1 test: init the pod test buffer with a fixed value
Works around the valgrind complaints when we call spa_debug_mem() on the
buffer with various sizes.
2021-07-07 11:03:23 +00:00
Peter Hutterer 5ebfbccd16 pwtest: if a test expects a signal, skip it under valgrind
Running under valgrind enforces --no-fork so any signal will cause valgrind
to error out, failing the test abnormally. This prevents us from running
our test suite through valgrind, we'd have to mark every test specifically
whether it should run under valgrind or not.

Easier is just to automatically skip tests expecting signals.
2021-07-07 11:03:23 +00:00
Peter Hutterer bba9edabee conf: don't allow a NULL config name
No functional changes, this is enforced by the only in-tree callers of
pw_conf_load_conf() but let's enforce this properly.
2021-07-06 07:14:21 +00:00
Peter Hutterer fb2d35895e conf: ignore the prefix if the config file name is an absolute path
Fixes:
$ export PIPEWIRE_CONFIG_PREFIX=/usr/share/pipewire
$ pipewire -c /etc/pipewire/bar.conf
[W][11925.530591][          conf.c:  253 conf_load()] config 0x560039ac6510: error loading config '/usr/share/pipewire//etc/pipewire/pipewire.conf': No such file or directory
[W][11925.530721][       context.c:  178 try_load_conf()] context 0x560039ac6190: can't load config /usr/share/pipewire//etc/pipewire/pipewire.conf: No such file or directory
2021-07-06 07:14:21 +00:00
Peter Hutterer b1ac776ff0 test: remove duplicate test invocation 2021-07-06 07:14:21 +00:00
Barnabás Pőcze f5d51162c4 treewide: mark things static and const
Mark some structures, arrays static/const at various places.
In some cases this prevents unnecessary initialization
when a function is entered.

All in all, the text segments across all shared
libraries are reduced by about 2 KiB. However,
the total size increases by about 2 KiB as well.
2021-06-30 14:44:08 +02:00
Niklāvs Koļesņikovs e062c4d8de meson.build: adds summary() to optional programs 2021-06-29 17:23:37 +00:00
Peter Hutterer 0880ff9a84 spa: add spa_strendswith (copy from protocol-pulse)
Useful function, let's make it generally available.
2021-06-25 08:42:24 +00:00
Peter Hutterer 01c2cb3d45 test: shut up coverity complaints about side effects
CID 1457494:  Incorrect expression  (ASSERT_SIDE_EFFECT)
Assignment "ai = (void *)((uint8_t *)pod + 16)" has a side effect.  This code will work differently in a non-debug build.
550             spa_assert((ai = SPA_POD_ARRAY_VALUES(pod)) != NULL);

Patch generated with coccinelle snippet
	@@
	expression E1, E2;
	@@
	- spa_assert((E1 = E2) != NULL);
	+ E1 = E2;
	+ spa_assert(E1 != NULL);

And run again for == NULL
2021-06-24 11:14:27 +00:00
Wim Taymans 575d4456e1 tests: fix test 2021-06-22 16:31:51 +02:00
Evgeniy Khramtsov c3d7561d17 test: unbreak FreeBSD 2021-06-21 09:28:02 +00:00
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