Statistics
| Branch: | Revision:

ffmpeg / tests / fate-run.sh @ d370e3e9

History | View | Annotate | Download (2.81 KB)

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