pipewire: add testing

This adds two tests. One is for whether the paths used by the module are
present, while the other is for testing functionality of PipeWire
itself. This is done with the recent addition of installed tests by
upstream.
This commit is contained in:
Nathaniel Glen 2020-08-05 14:48:37 -04:00
parent 89021b9a18
commit e879eb6db6
6 changed files with 69 additions and 1 deletions

View file

@ -87,6 +87,7 @@ in {
systemd.user.sockets.pipewire.wantedBy = lib.mkIf cfg.socketActivation [ "sockets.target" ];
# If any paths are updated here they must also be updated in the package test.
sound.extraConfig = mkIf cfg.alsa.enable ''
pcm_type.pipewire {
libs.native = ${pkgs.pipewire.lib}/lib/alsa-lib/libasound_module_pcm_pipewire.so ;

View file

@ -101,5 +101,6 @@ in
libxmlb = callInstalledTest ./libxmlb.nix {};
malcontent = callInstalledTest ./malcontent.nix {};
ostree = callInstalledTest ./ostree.nix {};
pipewire = callInstalledTest ./pipewire.nix {};
xdg-desktop-portal = callInstalledTest ./xdg-desktop-portal.nix {};
}

View file

@ -0,0 +1,5 @@
{ pkgs, lib, makeInstalledTest, ... }:
makeInstalledTest {
tested = pkgs.pipewire;
}

View file

@ -24,6 +24,8 @@
, vulkan-loader
, libpulseaudio
, makeFontsConf
, callPackage
, nixosTests
, ofonoSupport ? true
, nativeHspSupport ? true
}:
@ -37,7 +39,7 @@ stdenv.mkDerivation rec {
pname = "pipewire";
version = "0.3.9";
outputs = [ "out" "lib" "dev" "doc" ];
outputs = [ "out" "lib" "dev" "doc" "installedTests" ];
src = fetchFromGitLab {
domain = "gitlab.freedesktop.org";
@ -50,8 +52,14 @@ stdenv.mkDerivation rec {
patches = [
# Break up a dependency cycle between outputs.
./alsa-profiles-use-libdir.patch
# Move installed tests into their own output.
./installed-tests-path.patch
];
postPatch = ''
substituteInPlace meson.build --subst-var-by installed_tests_dir "$installedTests"
'';
nativeBuildInputs = [
doxygen
graphviz
@ -86,6 +94,7 @@ stdenv.mkDerivation rec {
"-Dman=false" # we don't have xmltoman
"-Dgstreamer=true"
"-Dudevrulesdir=lib/udev/rules.d"
"-Dinstalled_tests=true"
] ++ stdenv.lib.optional nativeHspSupport "-Dbluez5-backend-native=true"
++ stdenv.lib.optional ofonoSupport "-Dbluez5-backend-ofono=true";
@ -93,6 +102,23 @@ stdenv.mkDerivation rec {
doCheck = true;
passthru.tests = {
installedTests = nixosTests.installed-tests.pipewire;
# This ensures that all the paths used by the NixOS module are found.
test-paths = callPackage ./test-paths.nix {
paths-out = [
"share/alsa/alsa.conf.d/50-pipewire.conf"
];
paths-lib = [
"lib/alsa-lib/libasound_module_pcm_pipewire.so"
"lib/pipewire-0.3/jack"
"lib/pipewire-0.3/pulse"
"share/alsa-card-profile/mixer"
];
};
};
meta = with stdenv.lib; {
description = "Server and user space API to deal with multimedia pipelines";
homepage = "https://pipewire.org/";

View file

@ -0,0 +1,15 @@
diff --git a/meson.build b/meson.build
index ffee41b4..b75921f9 100644
--- a/meson.build
+++ b/meson.build
@@ -318,8 +318,8 @@ alsa_dep = (get_option('pipewire-alsa')
? dependency('alsa', version : '>=1.1.7')
: dependency('', required: false))
-installed_tests_metadir = join_paths(pipewire_datadir, 'installed-tests', pipewire_name)
-installed_tests_execdir = join_paths(pipewire_libexecdir, 'installed-tests', pipewire_name)
+installed_tests_metadir = join_paths('@installed_tests_dir@', 'share', 'installed-tests', pipewire_name)
+installed_tests_execdir = join_paths('@installed_tests_dir@', 'libexec', 'installed-tests', pipewire_name)
installed_tests_enabled = get_option('installed_tests')
installed_tests_template = files('template.test.in')

View file

@ -0,0 +1,20 @@
{ lib, runCommand, pipewire, paths-out, paths-lib }:
runCommand "pipewire-test-paths" { } ''
${lib.concatMapStringsSep "\n" (p: ''
if [ ! -f "${pipewire.lib}/${p}" ] && [ ! -d "${pipewire.lib}/${p}" ]; then
printf "pipewire failed to find the following path: %s\n" "${pipewire.lib}/${p}"
error=error
fi
'') paths-lib}
${lib.concatMapStringsSep "\n" (p: ''
if [ ! -f "${pipewire}/${p}" ] && [ ! -d "${pipewire}/${p}" ]; then
printf "pipewire failed to find the following path: %s\n" "${pipewire}/${p}"
error=error
fi
'') paths-out}
[ -n "$error" ] && exit 1
touch $out
''