annotate test/regression.sh @ 230:e713abed48e5

Spelling
author Chris Cannam <cannam@all-day-breakfast.com>
date Fri, 24 May 2019 11:41:51 +0100
parents 97352295ca97
children c9c562f37dd7
rev   line source
c@226 1 #!/bin/bash
c@226 2
c@226 3 set -eu
c@226 4
c@226 5 mydir=$(dirname "$0")
c@226 6
c@226 7 source_url=https://code.soundsoftware.ac.uk/attachments/download/1698/Zweieck-Duell.ogg
c@226 8
c@226 9 testfile="$mydir/tmp/input.ogg"
c@226 10 outfile="$mydir/tmp/output.csv"
c@226 11 truncated_testfile="$mydir/tmp/truncated.ogg"
c@226 12
c@226 13 mkdir -p "$mydir/tmp"
c@226 14
c@226 15 if sonic-annotator -v >/dev/null ; then
c@226 16 :
c@226 17 else
c@226 18 echo "Failed to find required binary sonic-annotator"
c@226 19 exit 1
c@226 20 fi
c@226 21
c@226 22 if [ ! -f "$testfile" ]; then
c@226 23 if wget --version >/dev/null ; then
c@226 24 wget -O "$testfile" "$source_url"
c@226 25 else
c@226 26 curl -o "$testfile" "$source_url"
c@226 27 fi
c@226 28 fi
c@226 29
c@226 30 dd if="$testfile" of="$truncated_testfile" bs=1024 count=100
c@226 31
c@226 32 ids=$( VAMP_PATH="$mydir/.." sonic-annotator --list )
c@226 33
c@226 34 successes=0
c@226 35 failures=0
c@226 36 skipped=0
c@226 37 total=0
c@226 38 failed_tests=""
c@226 39
c@226 40 for id in $ids ; do
c@226 41
c@226 42 echo
c@226 43 echo "Regression testing: $id"
c@226 44
c@226 45 total=$(($total + 1))
c@226 46
c@226 47 plugin=$(echo "$id" | cut -d: -f3)
c@226 48 output=$(echo "$id" | cut -d: -f4)
c@226 49
c@226 50 nondeterministic=false
c@226 51 case "$plugin:$output" in
c@226 52 qm-segmenter:segmentation) nondeterministic=true;;
c@226 53 *) ;;
c@226 54 esac
c@226 55
c@226 56 if [ "$nondeterministic" = "true" ]; then
c@226 57 echo "This plugin is nondeterministic, can't run regression test - skipping"
c@226 58 skipped=$(($skipped + 1))
c@226 59 continue
c@226 60 fi
c@226 61
c@226 62 bulky=false
c@226 63 case "$plugin:$output" in
c@226 64 qm-adaptivespectrogram:output) bulky=true;;
c@226 65 qm-chromagram:chromagram) bulky=true;;
c@226 66 qm-constantq:constantq) bulky=true;;
c@226 67 qm-dwt:wcoeff) bulky=true;;
c@226 68 qm-mfcc:coefficients) bulky=true;;
c@226 69 esac
c@226 70
c@226 71 infile="$testfile"
c@226 72 if [ "$bulky" = "true" ]; then
c@226 73 echo "This plugin produces bulky output, using shortened test file"
c@226 74 infile="$truncated_testfile"
c@226 75 fi
c@226 76
c@226 77 VAMP_PATH="$mydir/.." \
c@226 78 sonic-annotator \
c@226 79 -d "$id" \
c@226 80 -w csv \
c@226 81 --csv-omit-filename \
c@226 82 --csv-one-file "$outfile" \
c@226 83 --csv-force \
c@226 84 "$infile"
c@226 85
c@226 86 expected="$mydir/regression-expected/$plugin/$output.csv"
c@226 87
c@226 88 if cmp "$outfile" "$expected" ; then
c@226 89 echo "Done, test passed"
c@226 90 successes=$(($successes + 1))
c@226 91 else
c@226 92 echo
c@226 93 echo "*** FAIL: Result does not match expected output. Diff begins:"
c@226 94 echo
c@226 95 diff -u "$outfile" "$expected" | head -20
c@226 96 failures=$(($failures + 1))
c@226 97 failed_tests="$failed_tests $plugin:$output"
c@226 98 fi
c@226 99 done
c@226 100
c@226 101 echo
c@226 102
c@226 103 if [ "$failures" = "0" ]; then
c@226 104 echo "Done, all tests passed"
c@226 105 if [ "$skipped" != "0" ]; then
c@226 106 echo "($skipped test(s) skipped)"
c@226 107 fi
c@226 108 exit 0
c@226 109 else
c@226 110 echo "ERROR: Some tests failed!"
c@226 111 echo "$successes/$total tests passed"
c@226 112 echo "$skipped/$total tests were skipped"
c@226 113 echo "$failures/$total tests failed"
c@226 114 echo "The following tests failed:$failed_tests"
c@226 115 exit 1
c@226 116 fi