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