annotate tests/test-as-advertised.sh @ 77:adce5f7e2917 qt5

Don't need to check for Dataquay, and in fact we can pick up the wrong version if we do. Just assume it is available (building in e.g. sv subdir configuration)
author Chris Cannam
date Tue, 07 May 2013 15:58:20 +0100
parents 94d988cef54e
children 0fe5abb56a6e
rev   line source
Chris@0 1 #!/bin/bash
Chris@0 2
Chris@0 3 mypath=`dirname $0`
Chris@42 4 r=$mypath/../sonic-annotator
Chris@0 5
Chris@0 6 infile=$mypath/audio/3clicks8.wav
Chris@0 7 testplug=vamp:vamp-example-plugins:percussiononsets
Chris@0 8 tmpdir=$mypath/tmp_1_$$.dir
Chris@0 9 tmpwav=$tmpdir/test.wav
Chris@0 10
Chris@0 11 trap "rm -rf $tmpdir" 0
Chris@0 12
Chris@0 13 fail() {
Chris@0 14 echo "Test failed: $1"
Chris@0 15 exit 1
Chris@0 16 }
Chris@0 17
Chris@0 18 types=`\
Chris@0 19 $r --help 2>&1 | \
Chris@0 20 grep 'Supported writer types are:' | \
Chris@0 21 sed -e 's/^.*://' -e 's/[,\.]//g' \
Chris@0 22 `
Chris@0 23 [ -n "$types" ] || \
Chris@0 24 fail "Fails to report sensible list of writers in help text?"
Chris@0 25
Chris@0 26 onsets=$mypath/transforms/transforms-as-advertised-percussiononsets-onsets.n3
Chris@0 27 df=$mypath/transforms/transforms-as-advertised-percussiononsets-detectionfunction.n3
Chris@0 28
Chris@0 29 adbdir=$tmpdir/audiodb-test
Chris@0 30 mkdir -p $adbdir
Chris@0 31
Chris@0 32 for type in $types; do
Chris@0 33
Chris@0 34 mkdir -p $tmpdir
Chris@0 35 cp $infile $tmpwav
Chris@0 36
Chris@0 37 # Some of these are special cases:
Chris@0 38 #
Chris@0 39 # * The "default" writer type always prints to stdout instead of
Chris@0 40 # to a file.
Chris@0 41 #
Chris@0 42 # * The "audiodb" writer will not print any output for features
Chris@0 43 # that have no values (but are only point events). I don't know
Chris@0 44 # how reasonable that is, but it's clearly intentional. It also
Chris@0 45 # writes to a subdirectory $basedir/$catid/$trackid.$output
Chris@0 46
Chris@0 47 case $type in
Chris@0 48 audiodb)
Chris@0 49 $r -t $df -w $type $tmpwav --audiodb-basedir $tmpdir --audiodb-catid `basename $adbdir` 2>/dev/null || \
Chris@0 50 fail "Fails to run with reader type \"$type\" and default options"
Chris@0 51 ;;
Chris@0 52 default)
Chris@0 53 $r -t $onsets -w $type $tmpwav > $tmpdir/test.out 2>/dev/null || \
Chris@0 54 fail "Fails to run with reader type \"$type\" and default options"
Chris@0 55 ;;
Chris@0 56 *)
Chris@0 57 $r -t $onsets -w $type $tmpwav 2>/dev/null || \
Chris@0 58 fail "Fails to run with reader type \"$type\" and default options"
Chris@0 59 ;;
Chris@0 60 esac
Chris@0 61 newfiles=`ls $tmpdir | fgrep -v .wav`
Chris@0 62 if [ "$type" = audiodb ]; then newfiles=`ls $adbdir`; fi
Chris@0 63
Chris@0 64 [ -n "$newfiles" ] || \
Chris@0 65 fail "Fails to create output file for reader \"$type\" with default options"
Chris@0 66
Chris@0 67 case `echo $newfiles | wc -w` in
Chris@0 68 [2-9])
Chris@0 69 if [ "$type" != audiodb ]; then
Chris@0 70 fail "Produces more than one output file for reader \"$type\" with default options"
Chris@0 71 fi
Chris@0 72 ;;
Chris@0 73 1)
Chris@0 74 if [ "$type" = audiodb ]; then
Chris@0 75 fail "Produces only one output file for reader \"$type\" with default options (expected two)"
Chris@0 76 fi
Chris@0 77 ;;
Chris@0 78 esac
Chris@0 79
Chris@0 80 rm -r $tmpdir
Chris@0 81 done
Chris@0 82