at 23.11-beta 3.1 kB view raw
1let 2 mkTest = { systemWide ? false , fullVersion ? false }: 3 import ./make-test-python.nix ({ pkgs, lib, ... }: 4 let 5 testFile = pkgs.fetchurl { 6 url = 7 "https://file-examples.com/storage/fe5947fd2362fc197a3c2df/2017/11/file_example_MP3_700KB.mp3"; 8 hash = "sha256-+iggJW8s0/LfA/okfXsB550/55Q0Sq3OoIzuBrzOPJQ="; 9 }; 10 11 makeTestPlay = key: 12 { sox, alsa-utils }: 13 pkgs.writeScriptBin key '' 14 set -euxo pipefail 15 ${sox}/bin/play ${testFile} 16 ${sox}/bin/sox ${testFile} -t wav - | ${alsa-utils}/bin/aplay 17 touch /tmp/${key}_success 18 ''; 19 20 testers = builtins.mapAttrs makeTestPlay { 21 testPlay = { inherit (pkgs) sox alsa-utils; }; 22 testPlay32 = { inherit (pkgs.pkgsi686Linux) sox alsa-utils; }; 23 }; 24 in { 25 name = "pulseaudio${lib.optionalString fullVersion "Full"}${lib.optionalString systemWide "-systemWide"}"; 26 meta = with pkgs.lib.maintainers; { 27 maintainers = [ synthetica ] ++ pkgs.pulseaudio.meta.maintainers; 28 }; 29 30 nodes.machine = { ... }: 31 32 { 33 imports = [ ./common/wayland-cage.nix ]; 34 hardware.pulseaudio = { 35 enable = true; 36 support32Bit = true; 37 inherit systemWide; 38 } // lib.optionalAttrs fullVersion { 39 package = pkgs.pulseaudioFull; 40 }; 41 42 environment.systemPackages = [ testers.testPlay pkgs.pavucontrol ] 43 ++ lib.optional pkgs.stdenv.isx86_64 testers.testPlay32; 44 } // lib.optionalAttrs systemWide { 45 users.users.alice.extraGroups = [ "pulse-access" ]; 46 systemd.services.pulseaudio.wantedBy = [ "multi-user.target" ]; 47 }; 48 49 enableOCR = true; 50 51 testScript = { ... }: '' 52 machine.wait_until_succeeds("pgrep xterm") 53 machine.wait_for_text("alice@machine") 54 55 machine.send_chars("testPlay \n") 56 machine.wait_for_file("/tmp/testPlay_success") 57 ${lib.optionalString pkgs.stdenv.isx86_64 '' 58 machine.send_chars("testPlay32 \n") 59 machine.wait_for_file("/tmp/testPlay32_success") 60 ''} 61 machine.screenshot("testPlay") 62 63 ${lib.optionalString (!systemWide) '' 64 machine.send_chars("pacmd info && touch /tmp/pacmd_success\n") 65 machine.wait_for_file("/tmp/pacmd_success") 66 ''} 67 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") 73 ''; 74 }); 75in 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; }; 80}