comparison tests/test-as-advertised/test-as-advertised.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-as-advertised.sh@0fe5abb56a6e
children b3d73c08b6ce
comparison
equal deleted inserted replaced
118:0fe5abb56a6e 119:7a31201dc42d
1 #!/bin/bash
2
3 . ../include.sh
4
5 infile=$audiopath/3clicks8.wav
6 tmpdir=$mypath/tmp_1_$$.dir
7 tmpwav=$tmpdir/test.wav
8
9 trap "rm -rf $tmpdir" 0
10
11 types=`\
12 $r --help 2>&1 | \
13 grep 'Supported writer types are:' | \
14 sed -e 's/^.*://' -e 's/[,\.]//g' \
15 `
16 [ -n "$types" ] || \
17 fail "Fails to report sensible list of writers in help text?"
18
19 onsets=$mypath/transforms/percussiononsets-onsets.n3
20 df=$mypath/transforms/percussiononsets-detectionfunction.n3
21
22 adbdir=$tmpdir/audiodb-test
23 mkdir -p $adbdir
24
25 for type in $types; do
26
27 mkdir -p $tmpdir
28 cp $infile $tmpwav
29
30 # Some of these are special cases:
31 #
32 # * The "default" writer type always prints to stdout instead of
33 # to a file.
34 #
35 # * The "audiodb" writer will not print any output for features
36 # that have no values (but are only point events). I don't know
37 # how reasonable that is, but it's clearly intentional. It also
38 # writes to a subdirectory $basedir/$catid/$trackid.$output
39
40 case $type in
41 audiodb)
42 $r -t $df -w $type $tmpwav --audiodb-basedir $tmpdir --audiodb-catid `basename $adbdir` 2>/dev/null || \
43 fail "Fails to run with reader type \"$type\" and default options"
44 ;;
45 default)
46 $r -t $onsets -w $type $tmpwav > $tmpdir/test.out 2>/dev/null || \
47 fail "Fails to run with reader type \"$type\" and default options"
48 ;;
49 *)
50 $r -t $onsets -w $type $tmpwav 2>/dev/null || \
51 fail "Fails to run with reader type \"$type\" and default options"
52 ;;
53 esac
54 newfiles=`ls $tmpdir | fgrep -v .wav`
55 if [ "$type" = audiodb ]; then newfiles=`ls $adbdir`; fi
56
57 [ -n "$newfiles" ] || \
58 fail "Fails to create output file for reader \"$type\" with default options"
59
60 case `echo $newfiles | wc -w` in
61 [2-9])
62 if [ "$type" != audiodb ]; then
63 fail "Produces more than one output file for reader \"$type\" with default options"
64 fi
65 ;;
66 1)
67 if [ "$type" = audiodb ]; then
68 fail "Produces only one output file for reader \"$type\" with default options (expected two)"
69 fi
70 ;;
71 esac
72
73 rm -r $tmpdir
74 done
75
76 exit 0
77