Statistics
| Branch: | Revision:

ffmpeg / tests / fate-run.sh @ 0ba84856

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