fate: clean up also after failed runs
[libav.git] / tests / fate.sh
CommitLineData
a9dc6111
MR
1#! /bin/sh
2
3config=$1
4
5die(){
6 echo "$@"
7 exit 1
8}
9
10test -r "$config" || die "usage: fate.sh <config>"
11
12workdir=$(dirname $config)
13make=make
14
15. "$config"
16
17test -n "$slot" || die "slot not specified"
18test -n "$repo" || die "repo not specified"
19test -d "$samples" || die "samples location not specified"
20
21lock(){
22 lock=$1/fate.lock
23 (set -C; exec >$lock) 2>/dev/null || return
24 trap 'rm $lock' EXIT
25}
26
27checkout(){
28 case "$repo" in
29 file:*|/*) src="${repo#file:}" ;;
30 git:*) git clone "$repo" "$src" ;;
31 svn:*) svn co "$repo" "$src" ;;
32 esac
33}
34
35update()(
36 cd ${src} || return
37 case "$repo" in
38 git:*) git pull ;;
39 svn:*) svn up ;;
40 esac
41)
42
43configure()(
44 cd ${build} || return
45 ${src}/configure \
46 --prefix="${inst}" \
47 --samples="${samples}" \
48 ${arch:+--arch=$arch} \
49 ${cpu:+--cpu="$cpu"} \
50 ${cross_prefix:+--cross-prefix="$cross_prefix"} \
51 ${cc:+--cc="$cc"} \
52 ${target_os:+--target-os="$target_os"} \
53 ${sysroot:+--sysroot="$sysroot"} \
54 ${target_exec:+--target-exec="$target_exec"} \
55 ${target_path:+--target-path="$target_path"} \
56 ${extra_cflags:+--extra-cflags="$extra_cflags"} \
57 ${extra_ldflags:+--extra-ldflags="$extra_ldflags"} \
58 ${extra_libs:+--extra-libs="$extra_libs"} \
59 ${extra_conf}
60)
61
62compile()(
63 cd ${build} || return
64 ${make} ${makeopts} && ${make} install
65)
66
67fate()(
68 cd ${build} || return
69 ${make} ${makeopts} -k fate
70)
71
673fe599
MR
72clean(){
73 rm -r ${build} ${inst}
74}
75
a9dc6111
MR
76report(){
77 date=$(date -u +%Y%m%d%H%M%S)
78 echo "fate:0:${date}:${slot}:${version}:$1:$2" >report
79 cat ${build}/config.fate ${build}/tests/data/fate/*.rep >>report
80 test -n "$fate_recv" && tar cz report *.log | $fate_recv
81}
82
83fail(){
84 report "$@"
51124db8 85 clean
a9dc6111
MR
86 exit
87}
88
89mkdir -p ${workdir} || die "Error creating ${workdir}"
90lock ${workdir} || die "${workdir} locked"
91cd ${workdir} || die "cd ${workdir} failed"
92
93src=${workdir}/src
94build=${workdir}/build
95inst=${workdir}/install
96report=tests/data/fate/report
97
98test -d "$src" && update || checkout || die "Error fetching source"
99
100cd ${workdir}
101
102version=$(${src}/version.sh ${src})
103test "$version" = "$(cat version 2>/dev/null)" && exit 0
104echo ${version} >version
105
106rm -rf "${build}"
107mkdir -p ${build}
108
109configure >configure.log 2>&1 || fail $? "error configuring"
110compile >compile.log 2>&1 || fail $? "error compiling"
111fate >test.log 2>&1 || fail $? "error testing"
112report 0 success
673fe599 113clean