comparison tests/test-csv-destinations/test-csv-destinations.sh @ 119:7a31201dc42d test-reorg

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