Statistics
| Branch: | Revision:

ffmpeg / tests / fate-run.sh @ 5b60c293

History | View | Annotate | Download (2.68 KB)

1
#! /bin/sh
2

    
3
base=$(dirname $0)
4
. "${base}/md5.sh"
5

    
6
base64=tests/base64
7

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

    
17
outdir="tests/data/fate"
18
outfile="${outdir}/${test}"
19
errfile="${outdir}/${test}.err"
20
cmpfile="${outdir}/${test}.diff"
21
repfile="${outdir}/${test}.rep"
22

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

    
35
oneoff(){
36
    do_tiny_psnr "$1" "$2" MAXDIFF '<=' ${fuzz:-1}
37
}
38

    
39
stddev(){
40
    do_tiny_psnr "$1" "$2" stddev  '<=' ${fuzz:-1}
41
}
42

    
43
ffmpeg(){
44
    $target_exec $target_path/ffmpeg "$@"
45
}
46

    
47
framecrc(){
48
    ffmpeg "$@" -f framecrc -
49
}
50

    
51
framemd5(){
52
    ffmpeg "$@" -f framemd5 -
53
}
54

    
55
crc(){
56
    ffmpeg "$@" -f crc -
57
}
58

    
59
md5(){
60
    ffmpeg "$@" md5:
61
}
62

    
63
pcm(){
64
    ffmpeg "$@" -vn -f s16le -
65
}
66

    
67
regtest(){
68
    t="${test#$2-}"
69
    ref=${base}/ref/$2/$t
70
    cleanfiles="$cleanfiles $outfile $errfile"
71
    outfile=tests/data/regression/$2/$t
72
    errfile=tests/data/$t.$2.err
73
    ${base}/${1}-regression.sh $t $2 $3 "$target_exec" "$target_path"
74
}
75

    
76
codectest(){
77
    regtest codec $1 tests/$1
78
}
79

    
80
lavftest(){
81
    regtest lavf lavf tests/vsynth1
82
}
83

    
84
lavfitest(){
85
    cleanfiles="tests/data/lavfi/${test#lavfi-}.nut"
86
    regtest lavfi lavfi tests/vsynth1
87
}
88

    
89
seektest(){
90
    t="${test#seek-}"
91
    ref=${base}/ref/seek/$t
92
    case $t in
93
        image_*) file="tests/data/images/${t#image_}/%02d.${t#image_}" ;;
94
        *)       file=$(echo $t | tr _ '?')
95
                 for d in acodec vsynth2 lavf; do
96
                     test -f tests/data/$d/$file && break
97
                 done
98
                 file=$(echo tests/data/$d/$file)
99
                 ;;
100
    esac
101
    $target_exec $target_path/tests/seek_test $target_path/$file
102
}
103

    
104
mkdir -p "$outdir"
105

    
106
$command > "$outfile" 2>$errfile
107
err=$?
108

    
109
if [ $err -gt 128 ]; then
110
    sig=$(kill -l $err 2>/dev/null)
111
    test "${sig}" = "${sig%[!A-Za-z]*}" || unset sig
112
fi
113

    
114
if test -e "$ref"; then
115
    case $cmp in
116
        diff)   diff -u -w "$ref" "$outfile"            >$cmpfile ;;
117
        oneoff) oneoff     "$ref" "$outfile" "$fuzz"    >$cmpfile ;;
118
        stddev) stddev     "$ref" "$outfile" "$fuzz"    >$cmpfile ;;
119
    esac
120
    cmperr=$?
121
    test $err = 0 && err=$cmperr
122
    test $err = 0 || cat $cmpfile
123
else
124
    echo "reference file '$ref' not found"
125
    err=1
126
fi
127

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

    
130
test $err = 0 && rm -f $outfile $errfile $cmpfile $cleanfiles
131
exit $err