comparison tests/test-csv-destinations.sh @ 50:d40b62a2006f

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