annotate tests/test-as-advertised/test-as-advertised.sh @ 325:d5caf5e91a86 default-writer-writes-to-files

If the default writer were to be able to write to files (but this is backward-incompatible so probably unwise)
author Chris Cannam
date Fri, 18 May 2018 12:36:48 +0100
parents f35bbb3e4d41
children
rev   line source
Chris@0 1 #!/bin/bash
Chris@0 2
Chris@119 3 . ../include.sh
Chris@0 4
Chris@119 5 infile=$audiopath/3clicks8.wav
Chris@0 6 tmpdir=$mypath/tmp_1_$$.dir
Chris@0 7 tmpwav=$tmpdir/test.wav
Chris@0 8
Chris@0 9 trap "rm -rf $tmpdir" 0
Chris@0 10
Chris@144 11 types=`$r --list-writers`
Chris@0 12 [ -n "$types" ] || \
Chris@144 13 fail "Fails to report list of writers"
Chris@0 14
Chris@119 15 onsets=$mypath/transforms/percussiononsets-onsets.n3
Chris@119 16 df=$mypath/transforms/percussiononsets-detectionfunction.n3
Chris@0 17
Chris@0 18 adbdir=$tmpdir/audiodb-test
Chris@0 19
Chris@0 20 for type in $types; do
Chris@0 21
Chris@0 22 mkdir -p $tmpdir
Chris@0 23 cp $infile $tmpwav
Chris@0 24
Chris@325 25 # Special cases:
Chris@0 26 #
Chris@0 27 # * The "audiodb" writer will not print any output for features
Chris@0 28 # that have no values (but are only point events). I don't know
Chris@0 29 # how reasonable that is, but it's clearly intentional. It also
Chris@0 30 # writes to a subdirectory $basedir/$catid/$trackid.$output
Chris@0 31
Chris@0 32 case $type in
Chris@0 33 audiodb)
Chris@144 34 mkdir -p $adbdir
Chris@0 35 $r -t $df -w $type $tmpwav --audiodb-basedir $tmpdir --audiodb-catid `basename $adbdir` 2>/dev/null || \
Chris@325 36 fail "Fails to run with writer type \"$type\" and default options"
Chris@0 37 ;;
Chris@0 38 *)
Chris@0 39 $r -t $onsets -w $type $tmpwav 2>/dev/null || \
Chris@325 40 fail "Fails to run with writer type \"$type\" and default options"
Chris@0 41 ;;
Chris@0 42 esac
Chris@0 43 newfiles=`ls $tmpdir | fgrep -v .wav`
Chris@0 44 if [ "$type" = audiodb ]; then newfiles=`ls $adbdir`; fi
Chris@0 45
Chris@0 46 [ -n "$newfiles" ] || \
Chris@325 47 fail "Fails to create output file for writer \"$type\" with default options"
Chris@0 48
Chris@0 49 case `echo $newfiles | wc -w` in
Chris@0 50 [2-9])
Chris@0 51 if [ "$type" != audiodb ]; then
Chris@325 52 fail "Produces more than one output file for writer \"$type\" with default options"
Chris@0 53 fi
Chris@0 54 ;;
Chris@0 55 1)
Chris@0 56 if [ "$type" = audiodb ]; then
Chris@325 57 fail "Produces only one output file for writer \"$type\" with default options (expected two)"
Chris@0 58 fi
Chris@0 59 ;;
Chris@0 60 esac
Chris@0 61
Chris@0 62 rm -r $tmpdir
Chris@0 63 done
Chris@0 64
Chris@119 65 exit 0
Chris@119 66