2 mkTest = { systemWide ? false , fullVersion ? false }:
3 import ./make-test-python.nix ({ pkgs, lib, ... }:
5 testFile = pkgs.fetchurl {
7 "https://file-examples.com/storage/fe5947fd2362fc197a3c2df/2017/11/file_example_MP3_700KB.mp3";
8 hash = "sha256-+iggJW8s0/LfA/okfXsB550/55Q0Sq3OoIzuBrzOPJQ=";
13 pkgs.writeScriptBin key ''
15 ${sox}/bin/play ${testFile}
16 ${sox}/bin/sox ${testFile} -t wav - | ${alsa-utils}/bin/aplay
17 touch /tmp/${key}_success
20 testers = builtins.mapAttrs makeTestPlay {
21 testPlay = { inherit (pkgs) sox alsa-utils; };
22 testPlay32 = { inherit (pkgs.pkgsi686Linux) sox alsa-utils; };
25 name = "pulseaudio${lib.optionalString fullVersion "Full"}${lib.optionalString systemWide "-systemWide"}";
26 meta = with pkgs.lib.maintainers; {
27 maintainers = [ synthetica ] ++ pkgs.pulseaudio.meta.maintainers;
30 nodes.machine = { ... }:
33 imports = [ ./common/wayland-cage.nix ];
34 hardware.pulseaudio = {
38 } // lib.optionalAttrs fullVersion {
39 package = pkgs.pulseaudioFull;
42 environment.systemPackages = [ testers.testPlay pkgs.pavucontrol ]
43 ++ lib.optional pkgs.stdenv.hostPlatform.isx86_64 testers.testPlay32;
44 } // lib.optionalAttrs systemWide {
45 users.users.alice.extraGroups = [ "pulse-access" ];
46 systemd.services.pulseaudio.wantedBy = [ "multi-user.target" ];
51 testScript = { ... }: ''
52 machine.wait_until_succeeds("pgrep xterm")
53 machine.wait_for_text("alice@machine")
55 machine.send_chars("testPlay \n")
56 machine.wait_for_file("/tmp/testPlay_success")
57 ${lib.optionalString pkgs.stdenv.hostPlatform.isx86_64 ''
58 machine.send_chars("testPlay32 \n")
59 machine.wait_for_file("/tmp/testPlay32_success")
61 machine.screenshot("testPlay")
63 ${lib.optionalString (!systemWide) ''
64 machine.send_chars("pacmd info && touch /tmp/pacmd_success\n")
65 machine.wait_for_file("/tmp/pacmd_success")
68 # Pavucontrol only loads when Pulseaudio is running. If it isn't, the
69 # text "Dummy Output" (sound device name) will never show.
70 machine.send_chars("pavucontrol\n")
71 machine.wait_for_text("Dummy Output")
72 machine.screenshot("Pavucontrol")
75 in builtins.mapAttrs (key: val: mkTest val) {
76 user = { systemWide = false; fullVersion = false; };
77 system = { systemWide = true; fullVersion = false; };
78 userFull = { systemWide = false; fullVersion = true; };
79 systemFull = { systemWide = true; fullVersion = true; };