6177a0ab94f9fbabac0a776085ed44d5793ede44
[libav.git] / tests / fate-run.sh
1 #! /bin/sh
2
3 base=$(dirname $0)
4 . "${base}/md5.sh"
5
6 test="${1#fate-}"
7 samples=$2
8 target_exec=$3
9 target_path=$4
10 command=$5
11 cmp=${6:-diff}
12 ref=${7:-"${base}/ref/fate/${test}"}
13 fuzz=$8
14
15 # compatibility with Mike's test specs
16 SAMPLES_PATH=$samples
17 BUILD_PATH=$target_path
18
19 outdir="tests/data/fate"
20 outfile="${outdir}/${test}"
21
22 do_tiny_psnr(){
23 psnr=$(tests/tiny_psnr "$1" "$2" 2 0 0)
24 val=$(expr "$psnr" : ".*$3: *\([0-9.]*\)")
25 size1=$(expr "$psnr" : '.*bytes: *\([0-9]*\)')
26 size2=$(expr "$psnr" : '.*bytes:[ 0-9]*/ *\([0-9]*\)')
27 res=$(echo "$val $4 $5" | bc)
28 if [ "$res" != 1 ] || [ $size1 != $size2 ]; then
29 echo "$psnr"
30 return 1
31 fi
32 }
33
34 oneoff(){
35 do_tiny_psnr "$1" "$2" MAXDIFF '<=' ${fuzz:-1}
36 }
37
38 stddev(){
39 do_tiny_psnr "$1" "$2" stddev '<=' ${fuzz:-1}
40 }
41
42 if ! test -e "$ref"; then
43 echo "reference file '$ref' not found"
44 exit 1
45 fi
46
47 mkdir -p "$outdir"
48
49 eval $target_exec $command > "$outfile" 2>/dev/null || exit
50
51 case $cmp in
52 diff) diff -u -w "$ref" "$outfile" ;;
53 oneoff) oneoff "$ref" "$outfile" "$fuzz" ;;
54 stddev) stddev "$ref" "$outfile" "$fuzz" ;;
55 esac
56
57 test $? = 0 && rm $outfile