Statistics
| Branch: | Revision:

ffmpeg / tests / fate.sh @ b56a9c8e

History | View | Annotate | Download (2.93 KB)

1
#! /bin/sh
2

    
3
config=$1
4

    
5
die(){
6
    echo "$@"
7
    exit 1
8
}
9

    
10
test -r "$config"  || die "usage: fate.sh <config>"
11

    
12
workdir=$(cd $(dirname $config) && pwd)
13
make=make
14
tar='tar c'
15

    
16
. "$config"
17

    
18
test -n "$slot"    || die "slot not specified"
19
test -n "$repo"    || die "repo not specified"
20
test -d "$samples" || die "samples location not specified"
21

    
22
lock(){
23
    lock=$1/fate.lock
24
    (set -C; exec >$lock) 2>/dev/null || return
25
    trap 'rm $lock' EXIT
26
}
27

    
28
checkout(){
29
    case "$repo" in
30
        file:*|/*) src="${repo#file:}"      ;;
31
        git:*)     git clone "$repo" "$src" ;;
32
        svn:*)     svn co    "$repo" "$src" ;;
33
    esac
34
}
35

    
36
update()(
37
    cd ${src} || return
38
    case "$repo" in
39
        git:*) git pull ;;
40
        svn:*) svn up   ;;
41
    esac
42
)
43

    
44
configure()(
45
    cd ${build} || return
46
    ${src}/configure                                                    \
47
        --prefix="${inst}"                                              \
48
        --samples="${samples}"                                          \
49
        ${arch:+--arch=$arch}                                           \
50
        ${cpu:+--cpu="$cpu"}                                            \
51
        ${cross_prefix:+--cross-prefix="$cross_prefix"}                 \
52
        ${cc:+--cc="$cc"}                                               \
53
        ${target_os:+--target-os="$target_os"}                          \
54
        ${sysroot:+--sysroot="$sysroot"}                                \
55
        ${target_exec:+--target-exec="$target_exec"}                    \
56
        ${target_path:+--target-path="$target_path"}                    \
57
        ${extra_cflags:+--extra-cflags="$extra_cflags"}                 \
58
        ${extra_ldflags:+--extra-ldflags="$extra_ldflags"}              \
59
        ${extra_libs:+--extra-libs="$extra_libs"}                       \
60
        ${extra_conf}
61
)
62

    
63
compile()(
64
    cd ${build} || return
65
    ${make} ${makeopts} && ${make} install
66
)
67

    
68
fate()(
69
    cd ${build} || return
70
    ${make} ${makeopts} -k fate
71
)
72

    
73
clean(){
74
    rm -r ${build} ${inst}
75
}
76

    
77
report(){
78
    date=$(date -u +%Y%m%d%H%M%S)
79
    echo "fate:0:${date}:${slot}:${version}:$1:$2" >report
80
    cat ${build}/config.fate ${build}/tests/data/fate/*.rep >>report
81
    test -n "$fate_recv" && $tar report *.log | gzip | $fate_recv
82
}
83

    
84
fail(){
85
    report "$@"
86
    clean
87
    exit
88
}
89

    
90
mkdir -p ${workdir} || die "Error creating ${workdir}"
91
lock ${workdir}     || die "${workdir} locked"
92
cd ${workdir}       || die "cd ${workdir} failed"
93

    
94
src=${workdir}/src
95
build=${workdir}/build
96
inst=${workdir}/install
97

    
98
test -d "$src" && update || checkout || die "Error fetching source"
99

    
100
cd ${workdir}
101

    
102
version=$(${src}/version.sh ${src})
103
test "$version" = "$(cat version-$slot 2>/dev/null)" && exit 0
104
echo ${version} >version-$slot
105

    
106
rm -rf "${build}"
107
mkdir -p ${build}
108

    
109
configure >configure.log 2>&1 || fail $? "error configuring"
110
compile   >compile.log   2>&1 || fail $? "error compiling"
111
fate      >test.log      2>&1 || fail $? "error testing"
112
report 0 success
113
clean