fate: Be silent when switching to Git branch
[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
8226e977 12workdir=$(cd $(dirname $config) && pwd)
a9dc6111 13make=make
8b0816cb 14tar='tar c'
a9dc6111
MR
15
16. "$config"
17
18test -n "$slot" || die "slot not specified"
19test -n "$repo" || die "repo not specified"
20test -d "$samples" || die "samples location not specified"
21
42eb9154
JG
22: ${branch:=master}
23
a9dc6111
MR
24lock(){
25 lock=$1/fate.lock
26 (set -C; exec >$lock) 2>/dev/null || return
27 trap 'rm $lock' EXIT
28}
29
30checkout(){
31 case "$repo" in
32 file:*|/*) src="${repo#file:}" ;;
42eb9154 33 git:*) git clone --quiet --branch "$branch" "$repo" "$src" ;;
a9dc6111
MR
34 esac
35}
36
37update()(
38 cd ${src} || return
39 case "$repo" in
8caadfc5 40 git:*) git fetch --force; git reset --quiet --hard "origin/$branch" ;;
a9dc6111
MR
41 esac
42)
43
44configure()(
45 cd ${build} || return
46 ${src}/configure \
47 --prefix="${inst}" \
48 --samples="${samples}" \
74c847e0 49 --enable-gpl \
a9dc6111
MR
50 ${arch:+--arch=$arch} \
51 ${cpu:+--cpu="$cpu"} \
f01c7715 52 ${toolchain:+--toolchain="$toolchain"} \
a9dc6111 53 ${cross_prefix:+--cross-prefix="$cross_prefix"} \
d7b9b66a 54 ${as:+--as="$as"} \
a9dc6111 55 ${cc:+--cc="$cc"} \
2b366008 56 ${ld:+--ld="$ld"} \
a9dc6111
MR
57 ${target_os:+--target-os="$target_os"} \
58 ${sysroot:+--sysroot="$sysroot"} \
59 ${target_exec:+--target-exec="$target_exec"} \
60 ${target_path:+--target-path="$target_path"} \
ba13606c 61 ${target_samples:+--target-samples="$target_samples"} \
a9dc6111
MR
62 ${extra_cflags:+--extra-cflags="$extra_cflags"} \
63 ${extra_ldflags:+--extra-ldflags="$extra_ldflags"} \
64 ${extra_libs:+--extra-libs="$extra_libs"} \
65 ${extra_conf}
66)
67
68compile()(
69 cd ${build} || return
70 ${make} ${makeopts} && ${make} install
71)
72
73fate()(
c209d0df 74 test "$build_only" = "yes" && return
a9dc6111
MR
75 cd ${build} || return
76 ${make} ${makeopts} -k fate
77)
78
673fe599 79clean(){
20e1829d 80 rm -rf ${build} ${inst}
673fe599
MR
81}
82
a9dc6111
MR
83report(){
84 date=$(date -u +%Y%m%d%H%M%S)
42eb9154 85 echo "fate:1:${date}:${slot}:${version}:$1:$2:${branch}:${comment}" >report
a9dc6111 86 cat ${build}/config.fate ${build}/tests/data/fate/*.rep >>report
8b0816cb 87 test -n "$fate_recv" && $tar report *.log | gzip | $fate_recv
a9dc6111
MR
88}
89
90fail(){
91 report "$@"
51124db8 92 clean
a9dc6111
MR
93 exit
94}
95
96mkdir -p ${workdir} || die "Error creating ${workdir}"
97lock ${workdir} || die "${workdir} locked"
98cd ${workdir} || die "cd ${workdir} failed"
99
100src=${workdir}/src
eb8da636
MR
101: ${build:=${workdir}/build}
102: ${inst:=${workdir}/install}
a9dc6111
MR
103
104test -d "$src" && update || checkout || die "Error fetching source"
105
106cd ${workdir}
107
108version=$(${src}/version.sh ${src})
32a15a24
MR
109test "$version" = "$(cat version-$slot 2>/dev/null)" && exit 0
110echo ${version} >version-$slot
a9dc6111 111
69a9c80b 112rm -rf "${build}" *.log
a9dc6111
MR
113mkdir -p ${build}
114
115configure >configure.log 2>&1 || fail $? "error configuring"
116compile >compile.log 2>&1 || fail $? "error compiling"
117fate >test.log 2>&1 || fail $? "error testing"
118report 0 success
673fe599 119clean