fate: qtrle: disable audio in all tests
[libav.git] / tests / fate-run.sh
CommitLineData
2fad0977
MR
1#! /bin/sh
2
078ae66b
MR
3export LC_ALL=C
4
2fad0977
MR
5base=$(dirname $0)
6. "${base}/md5.sh"
7
b82be636
MR
8base64=tests/base64
9
2fad0977 10test="${1#fate-}"
122a9af7 11samples=$2
2fad0977 12target_exec=$3
122a9af7 13target_path=$4
2fad0977 14command=$5
3ade7d32 15cmp=${6:-diff}
3ade7d32 16ref=${7:-"${base}/ref/fate/${test}"}
0720d263 17fuzz=${8:-1}
7851eb68 18threads=${9:-1}
bc5acfa7 19thread_type=${10:-frame+slice}
018f39ef 20cpuflags=${11:-all}
5ecadc66 21cmp_shift=${12:-0}
bb684296 22cmp_target=${13:-0}
cffd7580 23size_tolerance=${14:-0}
26e87a22 24
2fad0977
MR
25outdir="tests/data/fate"
26outfile="${outdir}/${test}"
bcb0a154 27errfile="${outdir}/${test}.err"
b82be636
MR
28cmpfile="${outdir}/${test}.diff"
29repfile="${outdir}/${test}.rep"
2fad0977 30
9cc338b1
JR
31target_path(){
32 test ${1} = ${1#/} && p=${target_path}/
33 echo ${p}${1}
34}
35
bb684296
JR
36# $1=value1, $2=value2, $3=threshold
37# prints 0 if absolute difference between value1 and value2 is <= threshold
38compare(){
a56fba50 39 echo "scale=2; v = $1 - $2; if (v < 0) v = -v; if (v > $3) r = 1; r" | bc
bb684296
JR
40}
41
e153cfa8 42do_tiny_psnr(){
5ecadc66 43 psnr=$(tests/tiny_psnr "$1" "$2" 2 $cmp_shift 0)
e153cfa8 44 val=$(expr "$psnr" : ".*$3: *\([0-9.]*\)")
83b203dc
MR
45 size1=$(expr "$psnr" : '.*bytes: *\([0-9]*\)')
46 size2=$(expr "$psnr" : '.*bytes:[ 0-9]*/ *\([0-9]*\)')
bb684296 47 val_cmp=$(compare $val $cmp_target $fuzz)
cffd7580
JR
48 size_cmp=$(compare $size1 $size2 $size_tolerance)
49 if [ "$val_cmp" != 0 ] || [ "$size_cmp" != 0 ]; then
aab3ea5f
MR
50 echo "$psnr"
51 return 1
52 fi
53}
54
e153cfa8 55oneoff(){
bb684296 56 do_tiny_psnr "$1" "$2" MAXDIFF
e153cfa8
MR
57}
58
59stddev(){
bb684296 60 do_tiny_psnr "$1" "$2" stddev
e153cfa8
MR
61}
62
40fa14f7
MR
63oneline(){
64 val=$(cat "$2")
65 test x"$val" = x"$1" || { r=$?; printf -- '-%s\n+%s\n' "$ref" "$val"; }
66 return ${r:-0}
67}
68
dff1fc51 69run(){
c4795e80 70 test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
dff1fc51
MR
71 $target_exec $target_path/"$@"
72}
73
4bfa67bd
RB
74probefmt(){
75 run avprobe -show_format_entry format_name -v 0 "$@"
76}
77
6291d7e4 78avconv(){
018f39ef 79 run avconv -nostats -threads $threads -thread_type $thread_type -cpuflags $cpuflags "$@"
2b18c451
MR
80}
81
82framecrc(){
6291d7e4 83 avconv "$@" -f framecrc -
2b18c451
MR
84}
85
86framemd5(){
6291d7e4 87 avconv "$@" -f framemd5 -
2b18c451
MR
88}
89
90crc(){
6291d7e4 91 avconv "$@" -f crc -
2b18c451
MR
92}
93
94md5(){
6291d7e4 95 avconv "$@" md5:
2b18c451
MR
96}
97
98pcm(){
6291d7e4 99 avconv "$@" -vn -f s16le -
2b18c451
MR
100}
101
90e5b58a
JR
102enc_dec_pcm(){
103 out_fmt=$1
9cc338b1
JR
104 dec_fmt=$2
105 pcm_fmt=$3
106 src_file=$(target_path $4)
107 shift 4
90e5b58a
JR
108 encfile="${outdir}/${test}.${out_fmt}"
109 cleanfiles=$encfile
9cc338b1
JR
110 encfile=$(target_path ${encfile})
111 avconv -i $src_file "$@" -f $out_fmt -y ${encfile} || return
112 avconv -f $out_fmt -i ${encfile} -c:a pcm_${pcm_fmt} -f ${dec_fmt} -
90e5b58a
JR
113}
114
9a3f31ef
MR
115regtest(){
116 t="${test#$2-}"
117 ref=${base}/ref/$2/$t
018f39ef 118 ${base}/${1}-regression.sh $t $2 $3 "$target_exec" "$target_path" "$threads" "$thread_type" "$cpuflags"
9a3f31ef
MR
119}
120
121codectest(){
122 regtest codec $1 tests/$1
123}
124
125lavftest(){
126 regtest lavf lavf tests/vsynth1
127}
128
129lavfitest(){
8fae6e7c 130 cleanfiles="tests/data/lavfi/${test#lavfi-}.nut"
9a3f31ef
MR
131 regtest lavfi lavfi tests/vsynth1
132}
133
134seektest(){
135 t="${test#seek-}"
136 ref=${base}/ref/seek/$t
137 case $t in
138 image_*) file="tests/data/images/${t#image_}/%02d.${t#image_}" ;;
139 *) file=$(echo $t | tr _ '?')
140 for d in acodec vsynth2 lavf; do
141 test -f tests/data/$d/$file && break
142 done
143 file=$(echo tests/data/$d/$file)
144 ;;
145 esac
dec4b470 146 run libavformat/seek-test $target_path/$file
9a3f31ef 147}
150ef830 148
2fad0977
MR
149mkdir -p "$outdir"
150
c4795e80 151exec 3>&2
bcb0a154 152$command > "$outfile" 2>$errfile
ffe72624 153err=$?
3ade7d32 154
4e705a68
MR
155if [ $err -gt 128 ]; then
156 sig=$(kill -l $err 2>/dev/null)
5b60c293 157 test "${sig}" = "${sig%[!A-Za-z]*}" || unset sig
4e705a68
MR
158fi
159
40fa14f7 160if test -e "$ref" || test $cmp = "oneline" ; then
b82be636
MR
161 case $cmp in
162 diff) diff -u -w "$ref" "$outfile" >$cmpfile ;;
0720d263
JR
163 oneoff) oneoff "$ref" "$outfile" >$cmpfile ;;
164 stddev) stddev "$ref" "$outfile" >$cmpfile ;;
40fa14f7 165 oneline)oneline "$ref" "$outfile" >$cmpfile ;;
84757de0 166 null) cat "$outfile" >$cmpfile ;;
b82be636
MR
167 esac
168 cmperr=$?
169 test $err = 0 && err=$cmperr
170 test $err = 0 || cat $cmpfile
171else
9a3f31ef 172 echo "reference file '$ref' not found"
b82be636 173 err=1
9a3f31ef
MR
174fi
175
4e705a68 176echo "${test}:${sig:-$err}:$($base64 <$cmpfile):$($base64 <$errfile)" >$repfile
7d610af6 177
b82be636
MR
178test $err = 0 && rm -f $outfile $errfile $cmpfile $cleanfiles
179exit $err