From 7518588df677c260eb2fdf10541ef17c9b096492 Mon Sep 17 00:00:00 2001 From: Niols Date: Mon, 3 Apr 2023 13:21:51 +0000 Subject: [PATCH] Add basic NixOS tests for TiMidity++ --- nixos/tests/all-tests.nix | 1 + nixos/tests/timidity/basic.nix | 20 ++++++++++++++ nixos/tests/timidity/default.nix | 4 +++ nixos/tests/timidity/tam-lin.midi | Bin 0 -> 4728 bytes nixos/tests/timidity/with-vorbis.nix | 40 +++++++++++++++++++++++++++ 5 files changed, 65 insertions(+) create mode 100644 nixos/tests/timidity/basic.nix create mode 100644 nixos/tests/timidity/default.nix create mode 100644 nixos/tests/timidity/tam-lin.midi create mode 100644 nixos/tests/timidity/with-vorbis.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index fb85df8808f1..0337315421ea 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1041,6 +1041,7 @@ in { tika = runTest ./tika.nix; timescaledb = handleTest ./timescaledb.nix {}; timezone = handleTest ./timezone.nix {}; + timidity = handleTest ./timidity {}; tinc = handleTest ./tinc {}; tinydns = handleTest ./tinydns.nix {}; tinyproxy = handleTest ./tinyproxy.nix {}; diff --git a/nixos/tests/timidity/basic.nix b/nixos/tests/timidity/basic.nix new file mode 100644 index 000000000000..4bbbac8fbc6c --- /dev/null +++ b/nixos/tests/timidity/basic.nix @@ -0,0 +1,20 @@ +import ../make-test-python.nix ( + { pkgs, ... }: + { + + name = "timidity"; + + nodes.machine = + { pkgs, ... }: + { + environment.systemPackages = [ pkgs.timidity ]; + }; + + testScript = '' + start_all () + + ## TiMidity++ is around. + machine.succeed("command -v timidity") + ''; + } +) diff --git a/nixos/tests/timidity/default.nix b/nixos/tests/timidity/default.nix new file mode 100644 index 000000000000..8e136a9721e6 --- /dev/null +++ b/nixos/tests/timidity/default.nix @@ -0,0 +1,4 @@ +inputs: { + basic = import ./basic.nix inputs; + with-vorbis = import ./with-vorbis.nix inputs; +} diff --git a/nixos/tests/timidity/tam-lin.midi b/nixos/tests/timidity/tam-lin.midi new file mode 100644 index 0000000000000000000000000000000000000000..38560e1ade44de52c43a9fb1614cd5a1d9b027e8 GIT binary patch literal 4728 zcmeYb$w*;fU|?flWMF1&@C_--W?*3OVEE6>!0?}uGr1@=u_V99N`c`&qnx{6sDe*s zPGvxTUW$T|o{^EBkpcoR{EuK^VG`nC_#ep3Vk_9(!0=z60b(A77=5lfKCATOJP80KIP4*Ni8fkf^| z@-j3%!&AaYj(1m3Qg>xwnBWCscrh?cfQz_BB}@RxAm~O1umC)F!Ii@E5?qAJ#(98T z=fS`*0iMO3qY@^7N&y7j=l~YLRO$oL?1QWsQw_oxn6WsGgKPE#nd>=N!w#OR;e{%u z2s{hGBM?&rUWCG<9WH{Y3vLBm3eKQa(ilx?;7mDyxfCAhgCeChI>1{qoGuI#jiQ3SE3E^gt@~7#Jp6MZwHzW|(LN z(gHO{6Qn{Dp9%wz3Ihg)i8fIT6CI)$CYpl;Y#10OIxsLyG-qI#s0|X(#;1Y=zgR}W zY-)!15@r(#X5b95!4e+un4`eA!znyS@CyYY1`qX-nm#}|tC;~_hJbPwN;zT#FC{>w z4OBI_2!fV4ARVC62TOcGRl~|BkV^8*CZW7BfR`1}QVCp4K}#i2=|oMl$ndjX6k5p( zE{dTgFDRsFVJ5sZHiz5Z3@N8!6 B8{z-} literal 0 HcmV?d00001 diff --git a/nixos/tests/timidity/with-vorbis.nix b/nixos/tests/timidity/with-vorbis.nix new file mode 100644 index 000000000000..db7d23a8c9c0 --- /dev/null +++ b/nixos/tests/timidity/with-vorbis.nix @@ -0,0 +1,40 @@ +import ../make-test-python.nix ( + { pkgs, ... }: + { + + name = "timidity-with-vorbis"; + + nodes.machine = + { pkgs, ... }: + { + environment.systemPackages = with pkgs; [ + (timidity.override { enableVorbis = true; }) + ffmpeg # # for `ffprobe` + ]; + }; + + testScript = '' + import json + + start_all() + + ## TiMidity++ is around and it claims to support Ogg Vorbis. + machine.succeed("command -v timidity") + machine.succeed("timidity --help | grep 'Ogg Vorbis'") + + ## TiMidity++ manages to process a MIDI input and produces an Ogg Vorbis + ## output file. NOTE: the `timidity` CLI succeeds even when the input file + ## does not exist; hence our test for the output file's existence. + machine.succeed("cp ${./tam-lin.midi} tam-lin.midi") + machine.succeed("timidity -Ov tam-lin.midi && test -e tam-lin.ogg") + + ## The output file has the expected characteristics. + metadata_as_text = machine.succeed("ffprobe -show_format -print_format json -i tam-lin.ogg") + metadata = json.loads(metadata_as_text) + assert metadata['format']['format_name'] == 'ogg', \ + f"expected 'format_name' to be 'ogg', got '{metadata['format']['format_name']}'" + assert 37 <= float(metadata['format']['duration']) <= 38, \ + f"expected 'duration' to be between 37s and 38s, got {metadata['format']['duration']}s" + ''; + } +)