annotate tests/test-csv-destinations.sh @ 115:95de6db296a1

Merge from multiplex branch
author Chris Cannam
date Fri, 03 Oct 2014 15:07:19 +0100
parents d40b62a2006f
children 0fe5abb56a6e
rev   line source
Chris@50 1 #!/bin/bash
Chris@50 2
Chris@50 3 mypath=`dirname $0`
Chris@50 4 r=$mypath/../sonic-annotator
Chris@50 5
Chris@50 6 infile1=$mypath/audio/3clicks8.wav
Chris@50 7 infile2=$mypath/audio/6clicks8.wav
Chris@50 8
Chris@50 9 outfile1=$mypath/audio/3clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.csv
Chris@50 10 outfile2=$mypath/audio/6clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.csv
Chris@50 11
Chris@50 12 infile1dot=$mypath/audio/3.clicks.8.wav
Chris@50 13 outfile1dot=$mypath/audio/3.clicks.8_vamp_vamp-example-plugins_percussiononsets_onsets.csv
Chris@50 14
Chris@50 15 outfile3=$mypath/audio/3clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.csv
Chris@50 16 outfile4=$mypath/audio/3clicks8_vamp_vamp-example-plugins_percussiononsets_detectionfunction.csv
Chris@50 17
Chris@50 18 testplug=vamp:vamp-example-plugins:percussiononsets
Chris@50 19 tmpcsv=$mypath/tmp_1_$$.csv
Chris@50 20
Chris@50 21 trap "rm -f $tmpcsv $outfile1 $outfile2 $outfile3 $outfile4 $infile1dot $outfile1dot" 0
Chris@50 22
Chris@50 23 fail() {
Chris@50 24 echo "Test failed: $1"
Chris@50 25 exit 1
Chris@50 26 }
Chris@50 27
Chris@50 28 transformpfx=$mypath/transforms/transforms-rdf-writer-percussiononsets
Chris@50 29
Chris@50 30 check_csv() {
Chris@50 31 test -f $1 || \
Chris@50 32 fail "Fails to write output to expected location $1 for $2"
Chris@50 33 # every line must contain the same number of commas
Chris@50 34 formats=`awk -F, '{ print NF; }' $1 | sort | uniq | wc | awk '{ print $1 }'`
Chris@50 35 if [ "$formats" != "1" ]; then
Chris@50 36 fail "Output is not consistently formatted comma-separated file for $2"
Chris@50 37 fi
Chris@50 38 rm -f $1
Chris@50 39 }
Chris@50 40
Chris@50 41
Chris@50 42 ctx="onsets transform, one audio file, default CSV writer destination"
Chris@50 43
Chris@50 44 rm -f $outfile1
Chris@50 45
Chris@50 46 $r -t $transformpfx-onsets.n3 -w csv $infile1 2>/dev/null || \
Chris@50 47 fail "Fails to run with $ctx"
Chris@50 48
Chris@50 49 check_csv $outfile1 "$ctx"
Chris@50 50
Chris@50 51
Chris@50 52 ctx="onsets transform, one audio file with dots in filename, default CSV writer destination"
Chris@50 53
Chris@50 54 rm -f $outfile1
Chris@50 55
Chris@50 56 cp $infile1 $infile1dot
Chris@50 57
Chris@50 58 $r -t $transformpfx-onsets.n3 -w csv $infile1dot 2>/dev/null || \
Chris@50 59 fail "Fails to run with $ctx"
Chris@50 60
Chris@50 61 check_csv $outfile1dot "$ctx"
Chris@50 62
Chris@50 63 rm -f $infile1dot $outfile1dot
Chris@50 64
Chris@50 65
Chris@50 66 ctx="onsets and df transforms, one audio file, default CSV writer destination"
Chris@50 67
Chris@50 68 rm -f $outfile1
Chris@50 69
Chris@50 70 $r -t $transformpfx-onsets.n3 -t $transformpfx-detectionfunction.n3 -w csv $infile1 2>/dev/null || \
Chris@50 71 fail "Fails to run with $ctx"
Chris@50 72
Chris@50 73 check_csv $outfile1 "$ctx"
Chris@50 74
Chris@50 75
Chris@50 76 ctx="onsets transform, two audio files, default CSV writer destination"
Chris@50 77
Chris@50 78 rm -f $outfile1
Chris@50 79 rm -f $outfile2
Chris@50 80
Chris@50 81 $r -t $transformpfx-onsets.n3 -w csv $infile1 $infile2 2>/dev/null || \
Chris@50 82 fail "Fails to run with $ctx"
Chris@50 83
Chris@50 84 check_csv $outfile1 "$ctx"
Chris@50 85 check_csv $outfile2 "$ctx"
Chris@50 86
Chris@50 87
Chris@50 88 ctx="onsets transform, two audio files, one-file CSV writer"
Chris@50 89
Chris@50 90 $r -t $transformpfx-onsets.n3 -w csv --csv-one-file $tmpcsv $infile1 $infile2 2>/dev/null || \
Chris@50 91 fail "Fails to run with $ctx"
Chris@50 92
Chris@50 93 check_csv $tmpcsv "$ctx"
Chris@50 94
Chris@50 95
Chris@50 96 ctx="onsets transform, two audio files, stdout CSV writer"
Chris@50 97
Chris@50 98 $r -t $transformpfx-onsets.n3 -w csv --csv-stdout $infile1 $infile2 2>/dev/null >$tmpcsv || \
Chris@50 99 fail "Fails to run with $ctx"
Chris@50 100
Chris@50 101 check_csv $tmpcsv "$ctx"
Chris@50 102
Chris@50 103
Chris@50 104 ctx="existing output file and no --csv-force"
Chris@50 105
Chris@50 106 touch $outfile1
Chris@50 107
Chris@50 108 $r -t $transformpfx-onsets.n3 -w csv $infile1 2>/dev/null && \
Chris@50 109 fail "Fails by completing successfully when output file already exists (should refuse and bail out)"
Chris@50 110
Chris@50 111
Chris@50 112 ctx="existing output file and --csv-force"
Chris@50 113
Chris@50 114 touch $outfile1
Chris@50 115
Chris@50 116 $r -t $transformpfx-onsets.n3 -w csv --csv-force $infile1 2>/dev/null || \
Chris@50 117 fail "Fails to run with $ctx"
Chris@50 118
Chris@50 119 check_csv $outfile1 "$ctx"
Chris@50 120
Chris@50 121
Chris@50 122 exit 0