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