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