Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (2.85 KB)

1
#! /bin/sh
2

    
3
export LC_ALL=C
4

    
5
base=$(dirname $0)
6
. "${base}/md5.sh"
7

    
8
base64=tests/base64
9

    
10
test="${1#fate-}"
11
samples=$2
12
target_exec=$3
13
target_path=$4
14
command=$5
15
cmp=${6:-diff}
16
ref=${7:-"${base}/ref/fate/${test}"}
17
fuzz=$8
18
threads=${9:-1}
19

    
20
outdir="tests/data/fate"
21
outfile="${outdir}/${test}"
22
errfile="${outdir}/${test}.err"
23
cmpfile="${outdir}/${test}.diff"
24
repfile="${outdir}/${test}.rep"
25

    
26
do_tiny_psnr(){
27
    psnr=$(tests/tiny_psnr "$1" "$2" 2 0 0)
28
    val=$(expr "$psnr" : ".*$3: *\([0-9.]*\)")
29
    size1=$(expr "$psnr" : '.*bytes: *\([0-9]*\)')
30
    size2=$(expr "$psnr" : '.*bytes:[ 0-9]*/ *\([0-9]*\)')
31
    res=$(echo "if ($val $4 $5) 1" | bc)
32
    if [ "$res" != 1 ] || [ $size1 != $size2 ]; then
33
        echo "$psnr"
34
        return 1
35
    fi
36
}
37

    
38
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
run(){
47
    test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
48
    $target_exec $target_path/"$@"
49
}
50

    
51
ffmpeg(){
52
    run ffmpeg -v 0 -threads $threads "$@"
53
}
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
regtest(){
76
    t="${test#$2-}"
77
    ref=${base}/ref/$2/$t
78
    cleanfiles="$cleanfiles $outfile $errfile"
79
    outfile=tests/data/regression/$2/$t
80
    errfile=tests/data/$t.$2.err
81
    ${base}/${1}-regression.sh $t $2 $3 "$target_exec" "$target_path" "$threads"
82
}
83

    
84
codectest(){
85
    regtest codec $1 tests/$1
86
}
87

    
88
lavftest(){
89
    regtest lavf lavf tests/vsynth1
90
}
91

    
92
lavfitest(){
93
    cleanfiles="tests/data/lavfi/${test#lavfi-}.nut"
94
    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

    
112
mkdir -p "$outdir"
113

    
114
exec 3>&2
115
$command > "$outfile" 2>$errfile
116
err=$?
117

    
118
if [ $err -gt 128 ]; then
119
    sig=$(kill -l $err 2>/dev/null)
120
    test "${sig}" = "${sig%[!A-Za-z]*}" || unset sig
121
fi
122

    
123
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
    echo "reference file '$ref' not found"
134
    err=1
135
fi
136

    
137
echo "${test}:${sig:-$err}:$($base64 <$cmpfile):$($base64 <$errfile)" >$repfile
138

    
139
test $err = 0 && rm -f $outfile $errfile $cmpfile $cleanfiles
140
exit $err