Commit | Line | Data |
---|---|---|
a9dc6111 MR |
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=$(dirname $config) | |
13 | make=make | |
14 | ||
15 | . "$config" | |
16 | ||
17 | test -n "$slot" || die "slot not specified" | |
18 | test -n "$repo" || die "repo not specified" | |
19 | test -d "$samples" || die "samples location not specified" | |
20 | ||
21 | lock(){ | |
22 | lock=$1/fate.lock | |
23 | (set -C; exec >$lock) 2>/dev/null || return | |
24 | trap 'rm $lock' EXIT | |
25 | } | |
26 | ||
27 | checkout(){ | |
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 | ||
35 | update()( | |
36 | cd ${src} || return | |
37 | case "$repo" in | |
38 | git:*) git pull ;; | |
39 | svn:*) svn up ;; | |
40 | esac | |
41 | ) | |
42 | ||
43 | configure()( | |
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 | ||
62 | compile()( | |
63 | cd ${build} || return | |
64 | ${make} ${makeopts} && ${make} install | |
65 | ) | |
66 | ||
67 | fate()( | |
68 | cd ${build} || return | |
69 | ${make} ${makeopts} -k fate | |
70 | ) | |
71 | ||
72 | report(){ | |
73 | date=$(date -u +%Y%m%d%H%M%S) | |
74 | echo "fate:0:${date}:${slot}:${version}:$1:$2" >report | |
75 | cat ${build}/config.fate ${build}/tests/data/fate/*.rep >>report | |
76 | test -n "$fate_recv" && tar cz report *.log | $fate_recv | |
77 | } | |
78 | ||
79 | fail(){ | |
80 | report "$@" | |
81 | exit | |
82 | } | |
83 | ||
84 | mkdir -p ${workdir} || die "Error creating ${workdir}" | |
85 | lock ${workdir} || die "${workdir} locked" | |
86 | cd ${workdir} || die "cd ${workdir} failed" | |
87 | ||
88 | src=${workdir}/src | |
89 | build=${workdir}/build | |
90 | inst=${workdir}/install | |
91 | report=tests/data/fate/report | |
92 | ||
93 | test -d "$src" && update || checkout || die "Error fetching source" | |
94 | ||
95 | cd ${workdir} | |
96 | ||
97 | version=$(${src}/version.sh ${src}) | |
98 | test "$version" = "$(cat version 2>/dev/null)" && exit 0 | |
99 | echo ${version} >version | |
100 | ||
101 | rm -rf "${build}" | |
102 | mkdir -p ${build} | |
103 | ||
104 | configure >configure.log 2>&1 || fail $? "error configuring" | |
105 | compile >compile.log 2>&1 || fail $? "error compiling" | |
106 | fate >test.log 2>&1 || fail $? "error testing" | |
107 | report 0 success |