fate: Add build-only targets to FATE
[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}
47b5996b 24cmp_unit=${15:-2}
b01b60a2 25gen=${16:-no}
96a06dba 26hwaccel=${17:-none}
35d1f726 27report_type=${18:-standard}
26e87a22 28
2fad0977
MR
29outdir="tests/data/fate"
30outfile="${outdir}/${test}"
bcb0a154 31errfile="${outdir}/${test}.err"
b82be636
MR
32cmpfile="${outdir}/${test}.diff"
33repfile="${outdir}/${test}.rep"
2fad0977 34
9cc338b1
JR
35target_path(){
36 test ${1} = ${1#/} && p=${target_path}/
37 echo ${p}${1}
38}
39
bb684296
JR
40# $1=value1, $2=value2, $3=threshold
41# prints 0 if absolute difference between value1 and value2 is <= threshold
42compare(){
a982c5d7 43 awk "BEGIN { v = $1 - $2; printf ((v < 0 ? -v : v) > $3) }"
bb684296
JR
44}
45
e153cfa8 46do_tiny_psnr(){
47b5996b 47 psnr=$(tests/tiny_psnr "$1" "$2" $cmp_unit $cmp_shift 0)
e153cfa8 48 val=$(expr "$psnr" : ".*$3: *\([0-9.]*\)")
83b203dc
MR
49 size1=$(expr "$psnr" : '.*bytes: *\([0-9]*\)')
50 size2=$(expr "$psnr" : '.*bytes:[ 0-9]*/ *\([0-9]*\)')
bb684296 51 val_cmp=$(compare $val $cmp_target $fuzz)
cffd7580
JR
52 size_cmp=$(compare $size1 $size2 $size_tolerance)
53 if [ "$val_cmp" != 0 ] || [ "$size_cmp" != 0 ]; then
aab3ea5f
MR
54 echo "$psnr"
55 return 1
56 fi
57}
58
e153cfa8 59oneoff(){
bb684296 60 do_tiny_psnr "$1" "$2" MAXDIFF
e153cfa8
MR
61}
62
63stddev(){
bb684296 64 do_tiny_psnr "$1" "$2" stddev
e153cfa8
MR
65}
66
40fa14f7 67oneline(){
0ff0af73 68 printf '%s\n' "$1" | diff -u -b - "$2"
40fa14f7
MR
69}
70
dff1fc51 71run(){
c4795e80 72 test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
dff1fc51
MR
73 $target_exec $target_path/"$@"
74}
75
4bfa67bd
RB
76probefmt(){
77 run avprobe -show_format_entry format_name -v 0 "$@"
78}
79
b90c8a3d
VG
80probestream(){
81 run avprobe -show_stream_entry "$1" -v 0 "$2"
82}
83
6291d7e4 84avconv(){
96a06dba 85 dec_opts="-hwaccel $hwaccel -threads $threads -thread_type $thread_type"
8d18bc55
AK
86 avconv_args="-nostats -cpuflags $cpuflags"
87 for arg in $@; do
da025d11 88 [ x${arg} = x-i ] && avconv_args="${avconv_args} ${dec_opts}"
8d18bc55
AK
89 avconv_args="${avconv_args} ${arg}"
90 done
91 run avconv ${avconv_args}
2b18c451
MR
92}
93
94framecrc(){
6291d7e4 95 avconv "$@" -f framecrc -
2b18c451
MR
96}
97
98framemd5(){
6291d7e4 99 avconv "$@" -f framemd5 -
2b18c451
MR
100}
101
102crc(){
6291d7e4 103 avconv "$@" -f crc -
2b18c451
MR
104}
105
106md5(){
6291d7e4 107 avconv "$@" md5:
2b18c451
MR
108}
109
110pcm(){
6291d7e4 111 avconv "$@" -vn -f s16le -
2b18c451
MR
112}
113
90e5b58a
JR
114enc_dec_pcm(){
115 out_fmt=$1
9cc338b1
JR
116 dec_fmt=$2
117 pcm_fmt=$3
118 src_file=$(target_path $4)
119 shift 4
90e5b58a
JR
120 encfile="${outdir}/${test}.${out_fmt}"
121 cleanfiles=$encfile
9cc338b1
JR
122 encfile=$(target_path ${encfile})
123 avconv -i $src_file "$@" -f $out_fmt -y ${encfile} || return
124 avconv -f $out_fmt -i ${encfile} -c:a pcm_${pcm_fmt} -f ${dec_fmt} -
90e5b58a
JR
125}
126
0c1959b0 127FLAGS="-flags +bitexact -sws_flags +accurate_rnd+bitexact -fflags +bitexact"
7263cd55
MR
128DEC_OPTS="-threads $threads -idct simple $FLAGS"
129ENC_OPTS="-threads 1 -idct simple -dct fastint"
130
131enc_dec(){
132 src_fmt=$1
133 srcfile=$2
134 enc_fmt=$3
135 enc_opt=$4
136 dec_fmt=$5
137 dec_opt=$6
138 encfile="${outdir}/${test}.${enc_fmt}"
139 decfile="${outdir}/${test}.out.${dec_fmt}"
140 cleanfiles="$cleanfiles $decfile"
141 test "$7" = -keep || cleanfiles="$cleanfiles $encfile"
142 tsrcfile=$(target_path $srcfile)
143 tencfile=$(target_path $encfile)
144 tdecfile=$(target_path $decfile)
145 avconv -f $src_fmt $DEC_OPTS -i $tsrcfile $ENC_OPTS $enc_opt $FLAGS \
146 -f $enc_fmt -y $tencfile || return
147 do_md5sum $encfile
148 echo $(wc -c $encfile)
9146e872 149 avconv $DEC_OPTS -i $tencfile $ENC_OPTS $dec_opt $FLAGS \
7263cd55
MR
150 -f $dec_fmt -y $tdecfile || return
151 do_md5sum $decfile
152 tests/tiny_psnr $srcfile $decfile $cmp_unit $cmp_shift
153}
154
9a3f31ef 155lavftest(){
bd392785
DB
156 t="${test#lavf-}"
157 ref=${base}/ref/lavf/$t
158 ${base}/lavf-regression.sh $t lavf tests/vsynth1 "$target_exec" "$target_path" "$threads" "$thread_type" "$cpuflags"
9a3f31ef
MR
159}
160
03b052c0
DB
161video_filter(){
162 filters=$1
163 shift
164 label=${test#filter-}
165 raw_src="${target_path}/tests/vsynth1/%02d.pgm"
166 printf '%-20s' $label
4141a5a2
DB
167 avconv $DEC_OPTS -f image2 -c:v pgmyuv -i $raw_src \
168 $FLAGS $ENC_OPTS -vf "$filters" -c:v rawvideo -frames:v 5 $* -f nut md5:
03b052c0
DB
169}
170
b963f021
DB
171pixfmts(){
172 filter=${test#filter-pixfmts-}
173 filter_args=$1
174
a6a750c7 175 showfiltfmts="$target_exec $target_path/libavfilter/tests/filtfmts"
b963f021
DB
176 exclude_fmts=${outfile}${filter}_exclude_fmts
177 out_fmts=${outfile}${filter}_out_fmts
178
179 # exclude pixel formats which are not supported as input
180 avconv -pix_fmts list 2>/dev/null | awk 'NR > 8 && /^\..\./ { print $2 }' | sort >$exclude_fmts
181 $showfiltfmts scale | awk -F '[ \r]' '/^OUTPUT/{ print $3 }' | sort | comm -23 - $exclude_fmts >$out_fmts
182
183 pix_fmts=$($showfiltfmts $filter | awk -F '[ \r]' '/^INPUT/{ print $3 }' | sort | comm -12 - $out_fmts)
358b7ec3
TG
184
185 outertest=$test
b963f021
DB
186 for pix_fmt in $pix_fmts; do
187 test=$pix_fmt
2fb02ecf 188 video_filter "format=$pix_fmt,$filter=$filter_args" -pix_fmt $pix_fmt -frames:v 1
b963f021
DB
189 done
190
191 rm $exclude_fmts $out_fmts
358b7ec3 192 test=$outertest
b963f021
DB
193}
194
db869f4e
DB
195null(){
196 :
197}
198
2fad0977
MR
199mkdir -p "$outdir"
200
c4795e80 201exec 3>&2
7263cd55 202eval $command >"$outfile" 2>$errfile
ffe72624 203err=$?
3ade7d32 204
4e705a68
MR
205if [ $err -gt 128 ]; then
206 sig=$(kill -l $err 2>/dev/null)
5b60c293 207 test "${sig}" = "${sig%[!A-Za-z]*}" || unset sig
4e705a68
MR
208fi
209
698ac8f9 210if test -e "$ref" || test $cmp = "oneline" || test $cmp = "null" ; then
b82be636 211 case $cmp in
11e33402 212 diff) diff -u -b "$ref" "$outfile" >$cmpfile ;;
0720d263
JR
213 oneoff) oneoff "$ref" "$outfile" >$cmpfile ;;
214 stddev) stddev "$ref" "$outfile" >$cmpfile ;;
40fa14f7 215 oneline)oneline "$ref" "$outfile" >$cmpfile ;;
84757de0 216 null) cat "$outfile" >$cmpfile ;;
b82be636
MR
217 esac
218 cmperr=$?
219 test $err = 0 && err=$cmperr
35d1f726 220 if [ "$report_type" = "ignore" ]; then
eef860dd 221 test $err = 0 || echo "IGNORE\t${test}" && err=0 && unset sig
35d1f726
JG
222 else
223 test $err = 0 || cat $cmpfile
224 fi
b82be636 225else
9a3f31ef 226 echo "reference file '$ref' not found"
b82be636 227 err=1
9a3f31ef
MR
228fi
229
35d1f726 230if [ $err -eq 0 ] && test $report_type = "standard" ; then
3b1e35d4
TG
231 unset cmpo erro
232else
233 cmpo="$($base64 <$cmpfile)"
234 erro="$($base64 <$errfile)"
235fi
236echo "${test}:${sig:-$err}:$cmpo:$erro" >$repfile
7d610af6 237
b01b60a2
LB
238if test $err != 0 && test $gen != "no" ; then
239 echo "GEN $ref"
240 cp -f "$outfile" "$ref"
241 err=$?
242fi
243
b82be636
MR
244test $err = 0 && rm -f $outfile $errfile $cmpfile $cleanfiles
245exit $err