Remove unneeded wrapper function.
[libav.git] / tests / fate-run.sh
CommitLineData
2fad0977
MR
1#! /bin/sh
2
3base=$(dirname $0)
4. "${base}/md5.sh"
5
b82be636
MR
6base64=tests/base64
7
2fad0977 8test="${1#fate-}"
122a9af7 9samples=$2
2fad0977 10target_exec=$3
122a9af7 11target_path=$4
2fad0977 12command=$5
3ade7d32 13cmp=${6:-diff}
3ade7d32
MR
14ref=${7:-"${base}/ref/fate/${test}"}
15fuzz=$8
26e87a22 16
2fad0977
MR
17outdir="tests/data/fate"
18outfile="${outdir}/${test}"
bcb0a154 19errfile="${outdir}/${test}.err"
b82be636
MR
20cmpfile="${outdir}/${test}.diff"
21repfile="${outdir}/${test}.rep"
2fad0977 22
e153cfa8 23do_tiny_psnr(){
aab3ea5f 24 psnr=$(tests/tiny_psnr "$1" "$2" 2 0 0)
e153cfa8 25 val=$(expr "$psnr" : ".*$3: *\([0-9.]*\)")
83b203dc
MR
26 size1=$(expr "$psnr" : '.*bytes: *\([0-9]*\)')
27 size2=$(expr "$psnr" : '.*bytes:[ 0-9]*/ *\([0-9]*\)')
e153cfa8
MR
28 res=$(echo "$val $4 $5" | bc)
29 if [ "$res" != 1 ] || [ $size1 != $size2 ]; then
aab3ea5f
MR
30 echo "$psnr"
31 return 1
32 fi
33}
34
e153cfa8
MR
35oneoff(){
36 do_tiny_psnr "$1" "$2" MAXDIFF '<=' ${fuzz:-1}
37}
38
39stddev(){
40 do_tiny_psnr "$1" "$2" stddev '<=' ${fuzz:-1}
41}
42
2b18c451
MR
43ffmpeg(){
44 $target_exec $target_path/ffmpeg "$@"
45}
46
47framecrc(){
48 ffmpeg "$@" -f framecrc -
49}
50
51framemd5(){
52 ffmpeg "$@" -f framemd5 -
53}
54
55crc(){
56 ffmpeg "$@" -f crc -
57}
58
59md5(){
60 ffmpeg "$@" md5:
61}
62
63pcm(){
64 ffmpeg "$@" -vn -f s16le -
65}
66
9a3f31ef
MR
67regtest(){
68 t="${test#$2-}"
69 ref=${base}/ref/$2/$t
157c9241 70 cleanfiles="$cleanfiles $outfile $errfile"
9a3f31ef 71 outfile=tests/data/regression/$2/$t
bcb0a154 72 errfile=tests/data/$t.$2.err
9a3f31ef
MR
73 ${base}/${1}-regression.sh $t $2 $3 "$target_exec" "$target_path"
74}
75
76codectest(){
77 regtest codec $1 tests/$1
78}
79
80lavftest(){
81 regtest lavf lavf tests/vsynth1
82}
83
84lavfitest(){
8fae6e7c 85 cleanfiles="tests/data/lavfi/${test#lavfi-}.nut"
9a3f31ef
MR
86 regtest lavfi lavfi tests/vsynth1
87}
88
89seektest(){
90 t="${test#seek-}"
91 ref=${base}/ref/seek/$t
92 case $t in
93 image_*) file="tests/data/images/${t#image_}/%02d.${t#image_}" ;;
94 *) file=$(echo $t | tr _ '?')
95 for d in acodec vsynth2 lavf; do
96 test -f tests/data/$d/$file && break
97 done
98 file=$(echo tests/data/$d/$file)
99 ;;
100 esac
101 $target_exec $target_path/tests/seek_test $target_path/$file
102}
150ef830 103
2fad0977
MR
104mkdir -p "$outdir"
105
bcb0a154 106$command > "$outfile" 2>$errfile
ffe72624 107err=$?
3ade7d32 108
b82be636
MR
109if test -e "$ref"; then
110 case $cmp in
111 diff) diff -u -w "$ref" "$outfile" >$cmpfile ;;
112 oneoff) oneoff "$ref" "$outfile" "$fuzz" >$cmpfile ;;
113 stddev) stddev "$ref" "$outfile" "$fuzz" >$cmpfile ;;
114 esac
115 cmperr=$?
116 test $err = 0 && err=$cmperr
117 test $err = 0 || cat $cmpfile
118else
9a3f31ef 119 echo "reference file '$ref' not found"
b82be636 120 err=1
9a3f31ef
MR
121fi
122
b82be636 123echo "${test}:${err}:$($base64 <$cmpfile):$($base64 <$errfile)" >$repfile
7d610af6 124
b82be636
MR
125test $err = 0 && rm -f $outfile $errfile $cmpfile $cleanfiles
126exit $err