annotate test/regression.sh @ 266:d04675d44928 tip master

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