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