fate: remove stale fate-update.sh script
[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
18
19 outdir="tests/data/fate"
20 outfile="${outdir}/${test}"
21 errfile="${outdir}/${test}.err"
22 cmpfile="${outdir}/${test}.diff"
23 repfile="${outdir}/${test}.rep"
24
25 do_tiny_psnr(){
26     psnr=$(tests/tiny_psnr "$1" "$2" 2 0 0)
27     val=$(expr "$psnr" : ".*$3: *\([0-9.]*\)")
28     size1=$(expr "$psnr" : '.*bytes: *\([0-9]*\)')
29     size2=$(expr "$psnr" : '.*bytes:[ 0-9]*/ *\([0-9]*\)')
30     res=$(echo "if ($val $4 $5) 1" | bc)
31     if [ "$res" != 1 ] || [ $size1 != $size2 ]; then
32         echo "$psnr"
33         return 1
34     fi
35 }
36
37 oneoff(){
38     do_tiny_psnr "$1" "$2" MAXDIFF '<=' ${fuzz:-1}
39 }
40
41 stddev(){
42     do_tiny_psnr "$1" "$2" stddev  '<=' ${fuzz:-1}
43 }
44
45 run(){
46     test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
47     $target_exec $target_path/"$@"
48 }
49
50 ffmpeg(){
51     run ffmpeg -v 0 "$@"
52 }
53
54 framecrc(){
55     ffmpeg "$@" -f framecrc -
56 }
57
58 framemd5(){
59     ffmpeg "$@" -f framemd5 -
60 }
61
62 crc(){
63     ffmpeg "$@" -f crc -
64 }
65
66 md5(){
67     ffmpeg "$@" md5:
68 }
69
70 pcm(){
71     ffmpeg "$@" -vn -f s16le -
72 }
73
74 regtest(){
75     t="${test#$2-}"
76     ref=${base}/ref/$2/$t
77     cleanfiles="$cleanfiles $outfile $errfile"
78     outfile=tests/data/regression/$2/$t
79     errfile=tests/data/$t.$2.err
80     ${base}/${1}-regression.sh $t $2 $3 "$target_exec" "$target_path"
81 }
82
83 codectest(){
84     regtest codec $1 tests/$1
85 }
86
87 lavftest(){
88     regtest lavf lavf tests/vsynth1
89 }
90
91 lavfitest(){
92     cleanfiles="tests/data/lavfi/${test#lavfi-}.nut"
93     regtest lavfi lavfi tests/vsynth1
94 }
95
96 seektest(){
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
108     $target_exec $target_path/tests/seek_test $target_path/$file
109 }
110
111 mkdir -p "$outdir"
112
113 exec 3>&2
114 $command > "$outfile" 2>$errfile
115 err=$?
116
117 if [ $err -gt 128 ]; then
118     sig=$(kill -l $err 2>/dev/null)
119     test "${sig}" = "${sig%[!A-Za-z]*}" || unset sig
120 fi
121
122 if 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 ;;
127     esac
128     cmperr=$?
129     test $err = 0 && err=$cmperr
130     test $err = 0 || cat $cmpfile
131 else
132     echo "reference file '$ref' not found"
133     err=1
134 fi
135
136 echo "${test}:${sig:-$err}:$($base64 <$cmpfile):$($base64 <$errfile)" >$repfile
137
138 test $err = 0 && rm -f $outfile $errfile $cmpfile $cleanfiles
139 exit $err