wireplumber: add ptest support

Execution takes <10s.

Sample output:

root@qemux86-64:~# ptest-runner
START: ptest-runner
2025-12-24T19:17
BEGIN: /usr/lib/wireplumber/ptest
PASS: ./wp/test-spa-json
PASS: ./wp/test-spa-pod
PASS: ./wp/test-spa-type
PASS: ./wp/test-properties
PASS: ./wp/test-core
PASS: ./wp/test-session-item
PASS: ./wp/test-json-utils
PASS: ./wp/test-events
PASS: ./wp/test-conf
PASS: ./wp/test-transition
PASS: ./wp/test-object-interest
PASS: ./wp/test-metadata
PASS: ./wp/test-object-manager
PASS: ./wp/test-factory
PASS: ./wp/test-settings
PASS: ./wp/test-proxy
PASS: ./wp/test-state
PASS: ./wp/test-component-loader
PASS: 00-test-linking-non-default-device-node.lua
PASS: 01-test-linking-non-default-device-node-capture.lua
PASS: 02-test-linking-default-device-node.lua
PASS: 03-test-linking-default-device-node-capture.lua
PASS: 04-test-linking-defined-device-node-target-object-string.lua
PASS: 05-test-linking-defined-device-node-target-object-int.lua
PASS: 06-test-linking-defined-device-node-target-object-name.lua
PASS: 07-test-linking-defined-device-node-target-object-string-capture.lua
PASS: 08-test-linking-defined-device-node-target-object-int-capture.lua
PASS: 09-test-linking-defined-device-node-target-object-name-capture.lua
PASS: 10-test-linking-defined-device-node-node-target.lua
PASS: 11-test-linking-defined-device-node-node-target-capture.lua
PASS: 12-test-linking-defined-device-node-target-node-metadata.lua
PASS: 13-test-linking-defined-device-node-target-node-metadata-capture.lua
PASS: 14-test-linking-defined-device-node-target-object-metadata.lua
PASS: 15-test-linking-defined-device-node-target-object-metadata-capture.lua
PASS: 16-test-linking-defined-device-node-target-object-int-metadata.lua
PASS: 17-test-linking-defined-device-node-target-object-int-metadata-capture.lua
PASS: 00-test-default-nodes-initial-metadata-update.lua
/usr/lib/wireplumber/ptest
PASS: pod.lua
PASS: json.lua
PASS: json-utils.lua
PASS: monitor-rules.lua
PASS: require.lua
PASS: async-activation.lua
PASS: settings.lua
PASS: event-hooks.lua
PASS: properties.lua
/usr/lib/wireplumber/ptest
PASS: ./wplua/test-wplua
PASS: ./modules/test-file-monitor
PASS: ./modules/test-si-node
PASS: ./modules/test-si-standard-link
PASS: ./modules/test-dbus-connection
PASS: ./modules/test-si-audio-adapter
PASS: ./modules/test-reserve-device
DURATION: 1
END: /usr/lib/wireplumber/ptest
2025-12-24T19:17
STOP: ptest-runner
TOTAL: 1 FAIL: 0

Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Gyorgy Sarvari 2025-12-24 21:55:16 +01:00 committed by Khem Raj
parent ca7fe11935
commit f3862b7441
No known key found for this signature in database
GPG Key ID: BB053355919D3314
3 changed files with 88 additions and 3 deletions

View File

@ -13,6 +13,7 @@ PTESTS_FAST_META_MULTIMEDIA = "\
gupnp-igd \
libmediaart-2.0 \
libopenmpt \
wireplumber \
"
PTESTS_SLOW_META_MULTIMEDIA = "\

View File

@ -0,0 +1,55 @@
#!/bin/sh
RET=0
export HOME=/invalid
export XDG_RUNTIME_DIR=/invalid
export PIPEWIRE_RUNTIME_DIR=/tmp
export XDG_CONFIG_HOME=$(pwd)/.config
export XDG_STATE_HOME=$(pwd)/.local/state
export FILE_MONITOR_DIR=$(pwd)/.local/file_monitor
export WIREPLUMBER_MODULE_DIR=/usr/lib/wireplumber-0.5
export G_TEST_SRCDIR=/usr/lib/wireplumber/ptest/data
run_scripted_test(){
test_dir=$(dirname $1)
cd $test_dir
while read line; do
arg1=$(echo $line | cut -f1 -d" ")
arg2=$(echo $line | cut -f2 -d" ")
if ./script-tester $arg1 scripts/$arg2 > $arg2.out 2>&1; then
echo PASS: $arg2
else
echo FAIL: $arg2
RET=1
fi
done < ./ptest-list
cd -
}
run_regular_test(){
if ./$1 > $1.out 2>&1; then
echo PASS: $1
else
echo FAIL: $1
RET=1
fi
}
run_test(){
case $1 in
*run-ptest)
;;
*script-tester)
run_scripted_test $1
;;
*)
run_regular_test $1
;;
esac
}
for t in $(find . -type f -executable); do
run_test $t
done
exit $RET

View File

@ -13,11 +13,12 @@ DEPENDS = "glib-2.0 glib-2.0-native lua pipewire \
SRCREV = "84429b47943d789389fbde17c06b82efb197d04e"
SRC_URI = " \
git://gitlab.freedesktop.org/pipewire/wireplumber.git;branch=master;protocol=https;tag=${PV} \
file://run-ptest \
file://90-OE-disable-session-dbus-dependent-features.lua \
"
inherit meson pkgconfig gobject-introspection systemd bash-completion
inherit meson pkgconfig gobject-introspection systemd bash-completion ptest
GIR_MESON_ENABLE_FLAG = 'enabled'
GIR_MESON_DISABLE_FLAG = 'disabled'
@ -31,11 +32,11 @@ EXTRA_OEMESON += " \
-Delogind=disabled \
-Dsystemd-system-unit-dir=${systemd_system_unitdir} \
-Dsystemd-user-unit-dir=${systemd_user_unitdir} \
-Dtests=false \
"
PACKAGECONFIG ??= " dbus \
${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd systemd-system-service systemd-user-service', '', d)} \
${@bb.utils.contains('PTEST_ENABLED', '1', 'test', '', d)} \
"
PACKAGECONFIG[systemd] = "-Dsystemd=enabled,-Dsystemd=disabled,systemd"
@ -45,6 +46,7 @@ PACKAGECONFIG[systemd-system-service] = "-Dsystemd-system-service=true,-Dsystemd
# currently lacks the feature of enabling user services.
PACKAGECONFIG[systemd-user-service] = "-Dsystemd-user-service=true,-Dsystemd-user-service=false,systemd"
PACKAGECONFIG[dbus] = ""
PACKAGECONFIG[test] = "-Dtests=true,-Dtests=false"
PACKAGESPLITFUNCS:prepend = " split_dynamic_packages "
PACKAGESPLITFUNCS:append = " set_dynamic_metapkg_rdepends "
@ -57,6 +59,30 @@ do_install:append() {
fi
}
do_install_ptest() {
install -d ${D}${PTEST_PATH}/data/config
cd ${B}/tests
find . -maxdepth 2 -type f -executable -exec install -D {} ${D}${PTEST_PATH}/{} \;
install -m 644 ${S}/tests/wp/component-loader.conf ${D}${PTEST_PATH}/data/
cp -r ${S}/tests/scripts/scripts ${D}${PTEST_PATH}/scripts/
cp -r ${S}/tests/wplua/scripts ${D}${PTEST_PATH}/wplua/
cp -r ${S}/tests/wp/conf ${D}${PTEST_PATH}/data
cp -r ${S}/tests/wp/settings ${D}${PTEST_PATH}/data
install -m 644 ${S}/src/config/wireplumber.conf ${D}${PTEST_PATH}/data/config/
install -Dm 644 ${S}/tests/wplua/scripts/lib/testlib.lua ${D}${datadir}/wireplumber/scripts/lib/testlib.lua
install -Dm 644 ${S}/tests/scripts/scripts/lib/test-utils.lua ${D}${datadir}/wireplumber/scripts/lib/test-utils.lua
# this is not a test
rm -rf ${D}${PTEST_PATH}/examples
# Beside regular bianry executables, this package comes with lua tests also
# which need to be executed with specific parameters. Take the parameters
# from the meson.build files, and read them from run-ptest script.
grep args ${S}/tests/wplua/meson.build | cut -d[ -f2 | cut -d] -f1 | tr -d ",'" > ${D}${PTEST_PATH}/wplua/ptest-list
grep args ${S}/tests/scripts/meson.build | cut -d[ -f2 | cut -d] -f1 | tr -d ",'" > ${D}${PTEST_PATH}/scripts/ptest-list
}
python split_dynamic_packages () {
# Create packages for each WirePlumber module.
wp_module_libdir = d.expand('${libdir}/${WP_MODULE_SUBDIR}')
@ -142,3 +168,6 @@ FILES:${PN}-scripts += "${datadir}/wireplumber/scripts/*"
# Dynamic packages (see set_dynamic_metapkg_rdepends).
FILES:${PN}-modules = ""
RRECOMMENDS:${PN}-modules += "${PN}-modules-meta"
FILES:${PN}-ptest += "${datadir}/wireplumber/scripts/lib/test-utils.lua ${datadir}/wireplumber/scripts/testlib.lua"
RDEPENDS:${PN}-ptest += "pipewire-modules-protocol-native ${PN}-scripts"