c@226: #!/bin/bash c@226: c@226: set -eu c@226: c@226: mydir=$(dirname "$0") c@226: c@226: source_url=https://code.soundsoftware.ac.uk/attachments/download/1698/Zweieck-Duell.ogg c@226: c@226: testfile="$mydir/tmp/input.ogg" c@226: truncated_testfile="$mydir/tmp/truncated.ogg" c@226: c@226: mkdir -p "$mydir/tmp" c@226: c@226: if sonic-annotator -v >/dev/null ; then c@226: : c@226: else c@226: echo "Failed to find required binary sonic-annotator" c@226: exit 1 c@226: fi c@226: c@226: if [ ! -f "$testfile" ]; then c@226: if wget --version >/dev/null ; then c@226: wget -O "$testfile" "$source_url" c@226: else c@226: curl -o "$testfile" "$source_url" c@226: fi c@226: fi c@226: c@226: dd if="$testfile" of="$truncated_testfile" bs=1024 count=100 c@226: c@226: ids=$( VAMP_PATH="$mydir/.." sonic-annotator --list ) c@226: c@226: successes=0 c@226: failures=0 c@226: skipped=0 c@226: total=0 c@226: failed_tests="" c@226: c@226: for id in $ids ; do c@226: c@226: echo c@226: echo "Regression testing: $id" c@226: c@226: total=$(($total + 1)) c@226: c@226: plugin=$(echo "$id" | cut -d: -f3) c@226: output=$(echo "$id" | cut -d: -f4) c@226: c@226: nondeterministic=false c@226: case "$plugin:$output" in c@226: qm-segmenter:segmentation) nondeterministic=true;; c@226: *) ;; c@226: esac c@226: c@226: if [ "$nondeterministic" = "true" ]; then c@226: echo "This plugin is nondeterministic, can't run regression test - skipping" c@226: skipped=$(($skipped + 1)) c@226: continue c@226: fi c@226: c@226: bulky=false c@226: case "$plugin:$output" in c@226: qm-adaptivespectrogram:output) bulky=true;; c@226: qm-chromagram:chromagram) bulky=true;; c@226: qm-constantq:constantq) bulky=true;; c@226: qm-dwt:wcoeff) bulky=true;; c@226: qm-mfcc:coefficients) bulky=true;; c@226: esac c@226: c@226: infile="$testfile" c@226: if [ "$bulky" = "true" ]; then c@226: echo "This plugin produces bulky output, using shortened test file" c@226: infile="$truncated_testfile" c@226: fi cannam@233: cannam@233: mkdir -p "$mydir/regression-obtained/$plugin" cannam@233: outfile="$mydir/regression-obtained/$plugin/$output.csv" cannam@233: c@226: VAMP_PATH="$mydir/.." \ c@226: sonic-annotator \ c@226: -d "$id" \ c@226: -w csv \ c@226: --csv-omit-filename \ c@226: --csv-one-file "$outfile" \ c@226: --csv-force \ c@226: "$infile" c@226: c@226: expected="$mydir/regression-expected/$plugin/$output.csv" c@226: c@226: if cmp "$outfile" "$expected" ; then c@226: echo "Done, test passed" c@226: successes=$(($successes + 1)) c@226: else c@226: echo c@226: echo "*** FAIL: Result does not match expected output. Diff begins:" c@226: echo c@226: diff -u "$outfile" "$expected" | head -20 c@226: failures=$(($failures + 1)) c@226: failed_tests="$failed_tests $plugin:$output" c@226: fi c@226: done c@226: c@226: echo c@226: c@226: if [ "$failures" = "0" ]; then c@226: echo "Done, all tests passed" c@226: if [ "$skipped" != "0" ]; then c@226: echo "($skipped test(s) skipped)" c@226: fi c@226: exit 0 c@226: else c@226: echo "ERROR: Some tests failed!" c@226: echo "$successes/$total tests passed" c@226: echo "$skipped/$total tests were skipped" c@226: echo "$failures/$total tests failed" c@226: echo "The following tests failed:$failed_tests" c@226: exit 1 c@226: fi