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