FATE: remove WMA acodec tests
[ffmpeg.git] / tests / fate-run.sh
1 #! /bin/sh
2
3 export LC_ALL=C
4
5 base=$(dirname $0)
6 . "${base}/md5.sh"
7
8 base64=tests/base64
9
10 test="${1#fate-}"
11 samples=$2
12 target_exec=$3
13 target_path=$4
14 command=$5
15 cmp=${6:-diff}
16 ref=${7:-"${base}/ref/fate/${test}"}
17 fuzz=${8:-1}
18 threads=${9:-1}
19 thread_type=${10:-frame+slice}
20 cpuflags=${11:-all}
21 cmp_shift=${12:-0}
22 cmp_target=${13:-0}
23 size_tolerance=${14:-0}
24
25 outdir="tests/data/fate"
26 outfile="${outdir}/${test}"
27 errfile="${outdir}/${test}.err"
28 cmpfile="${outdir}/${test}.diff"
29 repfile="${outdir}/${test}.rep"
30
31 # $1=value1, $2=value2, $3=threshold
32 # prints 0 if absolute difference between value1 and value2 is <= threshold
33 compare(){
34     v=$(echo "scale=2; if ($1 >= $2) { $1 - $2 } else { $2 - $1 }" | bc)
35     echo "if ($v <= $3) { 0 } else { 1 }" | bc
36 }
37
38 do_tiny_psnr(){
39     psnr=$(tests/tiny_psnr "$1" "$2" 2 $cmp_shift 0)
40     val=$(expr "$psnr" : ".*$3: *\([0-9.]*\)")
41     size1=$(expr "$psnr" : '.*bytes: *\([0-9]*\)')
42     size2=$(expr "$psnr" : '.*bytes:[ 0-9]*/ *\([0-9]*\)')
43     val_cmp=$(compare $val $cmp_target $fuzz)
44     size_cmp=$(compare $size1 $size2 $size_tolerance)
45     if [ "$val_cmp" != 0 ] || [ "$size_cmp" != 0 ]; then
46         echo "$psnr"
47         return 1
48     fi
49 }
50
51 oneoff(){
52     do_tiny_psnr "$1" "$2" MAXDIFF
53 }
54
55 stddev(){
56     do_tiny_psnr "$1" "$2" stddev
57 }
58
59 run(){
60     test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
61     $target_exec $target_path/"$@"
62 }
63
64 avconv(){
65     run avconv -nostats -threads $threads -thread_type $thread_type -cpuflags $cpuflags "$@"
66 }
67
68 framecrc(){
69     avconv "$@" -f framecrc -
70 }
71
72 framemd5(){
73     avconv "$@" -f framemd5 -
74 }
75
76 crc(){
77     avconv "$@" -f crc -
78 }
79
80 md5(){
81     avconv "$@" md5:
82 }
83
84 pcm(){
85     avconv "$@" -vn -f s16le -
86 }
87
88 enc_dec_pcm(){
89     out_fmt=$1
90     pcm_fmt=$2
91     shift 2
92     encfile="${outdir}/${test}.${out_fmt}"
93     cleanfiles=$encfile
94     avconv -i $ref "$@" -f $out_fmt -y $encfile || return
95     avconv -i $encfile -c:a pcm_${pcm_fmt} -f wav -
96 }
97
98 regtest(){
99     t="${test#$2-}"
100     ref=${base}/ref/$2/$t
101     ${base}/${1}-regression.sh $t $2 $3 "$target_exec" "$target_path" "$threads" "$thread_type" "$cpuflags"
102 }
103
104 codectest(){
105     regtest codec $1 tests/$1
106 }
107
108 lavftest(){
109     regtest lavf lavf tests/vsynth1
110 }
111
112 lavfitest(){
113     cleanfiles="tests/data/lavfi/${test#lavfi-}.nut"
114     regtest lavfi lavfi tests/vsynth1
115 }
116
117 seektest(){
118     t="${test#seek-}"
119     ref=${base}/ref/seek/$t
120     case $t in
121         image_*) file="tests/data/images/${t#image_}/%02d.${t#image_}" ;;
122         *)       file=$(echo $t | tr _ '?')
123                  for d in acodec vsynth2 lavf; do
124                      test -f tests/data/$d/$file && break
125                  done
126                  file=$(echo tests/data/$d/$file)
127                  ;;
128     esac
129     run libavformat/seek-test $target_path/$file
130 }
131
132 mkdir -p "$outdir"
133
134 exec 3>&2
135 $command > "$outfile" 2>$errfile
136 err=$?
137
138 if [ $err -gt 128 ]; then
139     sig=$(kill -l $err 2>/dev/null)
140     test "${sig}" = "${sig%[!A-Za-z]*}" || unset sig
141 fi
142
143 if test -e "$ref"; then
144     case $cmp in
145         diff)   diff -u -w "$ref" "$outfile"            >$cmpfile ;;
146         oneoff) oneoff     "$ref" "$outfile"            >$cmpfile ;;
147         stddev) stddev     "$ref" "$outfile"            >$cmpfile ;;
148         null)   cat               "$outfile"            >$cmpfile ;;
149     esac
150     cmperr=$?
151     test $err = 0 && err=$cmperr
152     test $err = 0 || cat $cmpfile
153 else
154     echo "reference file '$ref' not found"
155     err=1
156 fi
157
158 echo "${test}:${sig:-$err}:$($base64 <$cmpfile):$($base64 <$errfile)" >$repfile
159
160 test $err = 0 && rm -f $outfile $errfile $cmpfile $cleanfiles
161 exit $err