fate: use our variable names in test rules imported from Mike's db
[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 outdir="tests/data/fate"
16 outfile="${outdir}/${test}"
17
18 do_tiny_psnr(){
19 psnr=$(tests/tiny_psnr "$1" "$2" 2 0 0)
20 val=$(expr "$psnr" : ".*$3: *\([0-9.]*\)")
21 size1=$(expr "$psnr" : '.*bytes: *\([0-9]*\)')
22 size2=$(expr "$psnr" : '.*bytes:[ 0-9]*/ *\([0-9]*\)')
23 res=$(echo "$val $4 $5" | bc)
24 if [ "$res" != 1 ] || [ $size1 != $size2 ]; then
25 echo "$psnr"
26 return 1
27 fi
28 }
29
30 oneoff(){
31 do_tiny_psnr "$1" "$2" MAXDIFF '<=' ${fuzz:-1}
32 }
33
34 stddev(){
35 do_tiny_psnr "$1" "$2" stddev '<=' ${fuzz:-1}
36 }
37
38 if ! test -e "$ref"; then
39 echo "reference file '$ref' not found"
40 exit 1
41 fi
42
43 mkdir -p "$outdir"
44
45 eval $target_exec $command > "$outfile" 2>/dev/null || exit
46
47 case $cmp in
48 diff) diff -u -w "$ref" "$outfile" ;;
49 oneoff) oneoff "$ref" "$outfile" "$fuzz" ;;
50 stddev) stddev "$ref" "$outfile" "$fuzz" ;;
51 esac
52
53 test $? = 0 && rm $outfile