dxa: remove useless code
[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
MR
16ref=${7:-"${base}/ref/fate/${test}"}
17fuzz=$8
7851eb68 18threads=${9:-1}
bc5acfa7 19thread_type=${10:-frame+slice}
018f39ef 20cpuflags=${11:-all}
26e87a22 21
2fad0977
MR
22outdir="tests/data/fate"
23outfile="${outdir}/${test}"
bcb0a154 24errfile="${outdir}/${test}.err"
b82be636
MR
25cmpfile="${outdir}/${test}.diff"
26repfile="${outdir}/${test}.rep"
2fad0977 27
e153cfa8 28do_tiny_psnr(){
aab3ea5f 29 psnr=$(tests/tiny_psnr "$1" "$2" 2 0 0)
e153cfa8 30 val=$(expr "$psnr" : ".*$3: *\([0-9.]*\)")
83b203dc
MR
31 size1=$(expr "$psnr" : '.*bytes: *\([0-9]*\)')
32 size2=$(expr "$psnr" : '.*bytes:[ 0-9]*/ *\([0-9]*\)')
61a187b0 33 res=$(echo "if ($val $4 $5) 1" | bc)
e153cfa8 34 if [ "$res" != 1 ] || [ $size1 != $size2 ]; then
aab3ea5f
MR
35 echo "$psnr"
36 return 1
37 fi
38}
39
e153cfa8
MR
40oneoff(){
41 do_tiny_psnr "$1" "$2" MAXDIFF '<=' ${fuzz:-1}
42}
43
44stddev(){
45 do_tiny_psnr "$1" "$2" stddev '<=' ${fuzz:-1}
46}
47
dff1fc51 48run(){
c4795e80 49 test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
dff1fc51
MR
50 $target_exec $target_path/"$@"
51}
52
6291d7e4 53avconv(){
018f39ef 54 run avconv -nostats -threads $threads -thread_type $thread_type -cpuflags $cpuflags "$@"
2b18c451
MR
55}
56
57framecrc(){
6291d7e4 58 avconv "$@" -f framecrc -
2b18c451
MR
59}
60
61framemd5(){
6291d7e4 62 avconv "$@" -f framemd5 -
2b18c451
MR
63}
64
65crc(){
6291d7e4 66 avconv "$@" -f crc -
2b18c451
MR
67}
68
69md5(){
6291d7e4 70 avconv "$@" md5:
2b18c451
MR
71}
72
73pcm(){
6291d7e4 74 avconv "$@" -vn -f s16le -
2b18c451
MR
75}
76
9a3f31ef
MR
77regtest(){
78 t="${test#$2-}"
79 ref=${base}/ref/$2/$t
018f39ef 80 ${base}/${1}-regression.sh $t $2 $3 "$target_exec" "$target_path" "$threads" "$thread_type" "$cpuflags"
9a3f31ef
MR
81}
82
83codectest(){
84 regtest codec $1 tests/$1
85}
86
87lavftest(){
88 regtest lavf lavf tests/vsynth1
89}
90
91lavfitest(){
8fae6e7c 92 cleanfiles="tests/data/lavfi/${test#lavfi-}.nut"
9a3f31ef
MR
93 regtest lavfi lavfi tests/vsynth1
94}
95
96seektest(){
97 t="${test#seek-}"
98 ref=${base}/ref/seek/$t
99 case $t in
100 image_*) file="tests/data/images/${t#image_}/%02d.${t#image_}" ;;
101 *) file=$(echo $t | tr _ '?')
102 for d in acodec vsynth2 lavf; do
103 test -f tests/data/$d/$file && break
104 done
105 file=$(echo tests/data/$d/$file)
106 ;;
107 esac
dec4b470 108 run libavformat/seek-test $target_path/$file
9a3f31ef 109}
150ef830 110
2fad0977
MR
111mkdir -p "$outdir"
112
c4795e80 113exec 3>&2
bcb0a154 114$command > "$outfile" 2>$errfile
ffe72624 115err=$?
3ade7d32 116
4e705a68
MR
117if [ $err -gt 128 ]; then
118 sig=$(kill -l $err 2>/dev/null)
5b60c293 119 test "${sig}" = "${sig%[!A-Za-z]*}" || unset sig
4e705a68
MR
120fi
121
b82be636
MR
122if test -e "$ref"; then
123 case $cmp in
124 diff) diff -u -w "$ref" "$outfile" >$cmpfile ;;
125 oneoff) oneoff "$ref" "$outfile" "$fuzz" >$cmpfile ;;
126 stddev) stddev "$ref" "$outfile" "$fuzz" >$cmpfile ;;
84757de0 127 null) cat "$outfile" >$cmpfile ;;
b82be636
MR
128 esac
129 cmperr=$?
130 test $err = 0 && err=$cmperr
131 test $err = 0 || cat $cmpfile
132else
9a3f31ef 133 echo "reference file '$ref' not found"
b82be636 134 err=1
9a3f31ef
MR
135fi
136
4e705a68 137echo "${test}:${sig:-$err}:$($base64 <$cmpfile):$($base64 <$errfile)" >$repfile
7d610af6 138
b82be636
MR
139test $err = 0 && rm -f $outfile $errfile $cmpfile $cleanfiles
140exit $err