Chris@103: #!/bin/bash Chris@103: Chris@119: . ../include.sh Chris@103: Chris@233: tmpfile1=$mypath/tmp_1_$$ Chris@233: tmpfile2=$mypath/tmp_2_$$ Chris@103: Chris@233: trap "rm -f $tmpfile1 $tmpfile2" 0 Chris@103: Chris@119: transform=$mypath/transforms/detectionfunction.n3 Chris@103: Chris@117: urlbase=http://vamp-plugins.org/sonic-annotator/testfiles Chris@117: Chris@233: have_network=yes Chris@234: if ! ping -c 1 8.8.8.8 2>/dev/null 1>&2 ; then Chris@233: echo "(network appears unavailable, skipping networking tests)" Chris@233: have_network=no Chris@233: fi Chris@233: Chris@117: Chris@117: # 1. Recursive local directory Chris@117: Chris@103: # Note, the output here depends on all the audio files present -- we Chris@111: # would have to regenerate it if we added more test audio files. Note Chris@111: # that the -r flag is not supposed to pick up playlist files, only Chris@111: # audio files Chris@233: $r -t $transform -w csv --csv-stdout -r --summary-only $audiopath > $tmpfile1 2>/dev/null || \ Chris@103: fail "Fails to run transform $transform with recursive dir option" Chris@103: Chris@119: expected=$mypath/expected/all-files Chris@233: csvcompare $tmpfile1 $expected.csv || \ Chris@111: faildiff "Output mismatch for transform $transform with summaries and recursive dir option" $tmpfile $expected.csv Chris@103: Chris@117: Chris@117: # 2. Local playlist file referring to local audio files Chris@117: Chris@117: # Here we strip any leading path from the audio file in the output, Chris@103: # because the playlist reader will have resolved files to absolute Chris@103: # paths and those will differ between systems Chris@233: $r -t $transform -w csv --csv-stdout $audiopath/playlist.m3u --summary-only 2>/dev/null > "$tmpfile2" || \ Chris@103: fail "Fails to run transform $transform with playlist input" Chris@103: Chris@233: cat "$tmpfile2" | sed 's,^"[^"]*/,",' > "$tmpfile1" Chris@233: Chris@119: expected=$mypath/expected/playlist Chris@233: csvcompare $tmpfile1 $expected.csv || \ Chris@233: faildiff "Output mismatch for transform $transform with summaries and playlist input" $tmpfile1 $expected.csv Chris@103: Chris@117: Chris@117: # 3. Multiple files supplied directly on command line Chris@117: Chris@117: # Strip paths again, just so we can use the same output comparison Chris@117: # file as above Chris@233: $r -t $transform -w csv --csv-stdout $audiopath/3clicks.mp3 $audiopath/6clicks.ogg --summary-only 2>/dev/null > $tmpfile2 || \ Chris@104: fail "Fails to run transform $transform with 2-file input" Chris@103: Chris@233: cat "$tmpfile2" | sed 's,^"[^"]*/,",' > "$tmpfile1" Chris@233: Chris@119: expected=$mypath/expected/playlist Chris@233: csvcompare $tmpfile1 $expected.csv || \ Chris@233: faildiff "Output mismatch for transform $transform with summaries and 2-file input" $tmpfile1 $expected.csv Chris@103: Chris@104: Chris@125: # 4. Multiple files supplied directly on command line, with file: URL Chris@125: Chris@233: $r -t $transform -w csv --csv-stdout $audiopath/3clicks.mp3 file://`pwd`/$audiopath/6clicks.ogg --summary-only 2>/dev/null > $tmpfile2 || \ Chris@125: fail "Fails to run transform $transform with 2-file input" Chris@125: Chris@233: cat "$tmpfile2" | sed 's,^"[^"]*/,",' > "$tmpfile1" Chris@117: Chris@119: expected=$mypath/expected/playlist Chris@233: csvcompare $tmpfile1 $expected.csv || \ Chris@233: faildiff "Output mismatch for transform $transform with summaries and 2-file input using file:// URL" $tmpfile1 $expected.csv Chris@117: Chris@117: Chris@233: if [ "$have_network" = "yes" ]; then Chris@117: Chris@233: # 5. Remote playlist file referring to remote audio files Chris@117: Chris@233: $r -t $transform -w csv --csv-stdout $urlbase/playlist.m3u --summary-only 2>/dev/null > $tmpfile2 || \ Chris@233: fail "Fails to run transform $transform with remote playlist input" Chris@117: Chris@233: cat "$tmpfile2" | sed 's,^"[^"]*/,",' > "$tmpfile1" Chris@117: Chris@233: expected=$mypath/expected/playlist Chris@233: csvcompare $tmpfile1 $expected.csv || \ Chris@233: faildiff "Output mismatch for transform $transform with summaries and remote playlist input" $tmpfile1 $expected.csv Chris@117: Chris@117: Chris@233: # 6. Local playlist file referring to mixture of remote and local audio files Chris@117: Chris@233: $r -t $transform -w csv --csv-stdout $audiopath/remote-playlist.m3u --summary-only 2>/dev/null > $tmpfile2 || \ Chris@233: fail "Fails to run transform $transform with playlist of remote files" Chris@117: Chris@233: cat "$tmpfile2" | sed 's,^"[^"]*/,",' > "$tmpfile1" Chris@117: Chris@233: expected=$mypath/expected/playlist Chris@233: csvcompare $tmpfile1 $expected.csv || \ Chris@233: faildiff "Output mismatch for transform $transform with summaries and remote playlist input" $tmpfile1 $expected.csv Chris@117: Chris@117: Chris@233: # 7. Multiple remote files supplied directly on command line Chris@233: Chris@233: $r -t $transform -w csv --csv-stdout $urlbase/3clicks.mp3 $urlbase/6clicks.ogg --summary-only 2>/dev/null > $tmpfile2 || \ Chris@233: fail "Fails to run transform $transform with 2-file remote input" Chris@233: Chris@233: cat "$tmpfile2" | sed 's,^"[^"]*/,",' > "$tmpfile1" Chris@233: Chris@233: expected=$mypath/expected/playlist Chris@233: csvcompare $tmpfile1 $expected.csv || \ Chris@233: faildiff "Output mismatch for transform $transform with summaries and 2-file input" $tmpfile1 $expected.csv Chris@233: Chris@233: Chris@233: # 8. Mixture of remote and local files supplied on command line Chris@233: Chris@233: $r -t $transform -w csv --csv-stdout $audiopath/3clicks.mp3 $urlbase/6clicks.ogg --summary-only 2>/dev/null > $tmpfile2 || \ Chris@233: fail "Fails to run transform $transform with 2-file remote input" Chris@233: Chris@233: cat "$tmpfile2" | sed 's,^"[^"]*/,",' > "$tmpfile1" Chris@233: Chris@233: expected=$mypath/expected/playlist Chris@233: csvcompare $tmpfile1 $expected.csv || \ Chris@233: faildiff "Output mismatch for transform $transform with summaries and mixed local/remote 2-file input" $tmpfile1 $expected.csv Chris@233: Chris@233: fi Chris@218: Chris@218: # 9. As 3, but multiplexing rather than extracting separately from each file Chris@218: Chris@233: $r -t $transform --multiplex -w csv --csv-stdout $audiopath/3clicks.mp3 $audiopath/6clicks.ogg --summary-only 2>/dev/null > $tmpfile2 || \ Chris@218: fail "Fails to run transform $transform with 2-file input" Chris@218: Chris@233: cat "$tmpfile2" | sed 's,^"[^"]*/,",' > "$tmpfile1" Chris@233: Chris@218: expected=$mypath/expected/multiplexed Chris@233: csvcompare $tmpfile1 $expected.csv || \ Chris@233: faildiff "Output mismatch for transform $transform with summaries and 2-file multiplexed input" $tmpfile1 $expected.csv Chris@218: