fate: apply TARGET_EXEC only to commands starting with absolute path
[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
150ef830
MR
38if ! test -e "$ref"; then
39 echo "reference file '$ref' not found"
40 exit 1
41fi
42
2fad0977
MR
43mkdir -p "$outdir"
44
f0388cf7
MR
45case "$command" in /*) command="$target_exec $command" ;; esac
46eval $command > "$outfile" 2>/dev/null || exit
3ade7d32
MR
47
48case $cmp in
49 diff) diff -u -w "$ref" "$outfile" ;;
aab3ea5f 50 oneoff) oneoff "$ref" "$outfile" "$fuzz" ;;
e153cfa8 51 stddev) stddev "$ref" "$outfile" "$fuzz" ;;
3ade7d32 52esac
7d610af6
MR
53
54test $? = 0 && rm $outfile