summary refs log tree commit diff
path: root/pkgs/development/libraries/pipewire
diff options
context:
space:
mode:
authorNathaniel Glen <njag2202@gmail.com>2020-08-05 14:48:37 -0400
committerNathaniel Glen <njag2202@gmail.com>2020-09-19 16:33:01 -0400
commite879eb6db6715faeafd6fc514c0e2752e4dcef3f (patch)
treee404115b99b09f5d92f09b328e310fcf5cf03fa0 /pkgs/development/libraries/pipewire
parent89021b9a188880939b8683c0aabbb4b1cc5bece5 (diff)
downloadnixpkgs-e879eb6db6715faeafd6fc514c0e2752e4dcef3f.tar
nixpkgs-e879eb6db6715faeafd6fc514c0e2752e4dcef3f.tar.gz
nixpkgs-e879eb6db6715faeafd6fc514c0e2752e4dcef3f.tar.bz2
nixpkgs-e879eb6db6715faeafd6fc514c0e2752e4dcef3f.tar.lz
nixpkgs-e879eb6db6715faeafd6fc514c0e2752e4dcef3f.tar.xz
nixpkgs-e879eb6db6715faeafd6fc514c0e2752e4dcef3f.tar.zst
nixpkgs-e879eb6db6715faeafd6fc514c0e2752e4dcef3f.zip
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.
Diffstat (limited to 'pkgs/development/libraries/pipewire')
-rw-r--r--pkgs/development/libraries/pipewire/default.nix28
-rw-r--r--pkgs/development/libraries/pipewire/installed-tests-path.patch15
-rw-r--r--pkgs/development/libraries/pipewire/test-paths.nix20
3 files changed, 62 insertions, 1 deletions
diff --git a/pkgs/development/libraries/pipewire/default.nix b/pkgs/development/libraries/pipewire/default.nix
index b6cc22a18be..706d170ea43 100644
--- a/pkgs/development/libraries/pipewire/default.nix
+++ b/pkgs/development/libraries/pipewire/default.nix
@@ -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/";
diff --git a/pkgs/development/libraries/pipewire/installed-tests-path.patch b/pkgs/development/libraries/pipewire/installed-tests-path.patch
new file mode 100644
index 00000000000..154a480b73c
--- /dev/null
+++ b/pkgs/development/libraries/pipewire/installed-tests-path.patch
@@ -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')
+ 
diff --git a/pkgs/development/libraries/pipewire/test-paths.nix b/pkgs/development/libraries/pipewire/test-paths.nix
new file mode 100644
index 00000000000..98fbd516a19
--- /dev/null
+++ b/pkgs/development/libraries/pipewire/test-paths.nix
@@ -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
+''