]>
Commit | Line | Data |
---|---|---|
3d885c4d | 1 | #!/bin/sh |
bea1ee2e | 2 | # |
4abfd78b | 3 | # Run all or some build tests for a given OS environment. |
bea1ee2e | 4 | # |
14777424 | 5 | top=`dirname $0` |
bea1ee2e | 6 | |
4abfd78b AJ |
7 | globalResult=0 |
8 | ||
1c148717 | 9 | cleanup="no" |
14777424 | 10 | verbose="no" |
4abfd78b | 11 | keepGoing="no" |
f2374628 | 12 | remove_cache_file="true" |
14777424 AJ |
13 | while [ $# -ge 1 ]; do |
14 | case "$1" in | |
15 | --cleanup) | |
1c148717 AJ |
16 | cleanup="yes" |
17 | shift | |
14777424 AJ |
18 | ;; |
19 | --verbose) | |
20 | verbose="yes" | |
21 | shift | |
22 | ;; | |
4abfd78b AJ |
23 | --keep-going) |
24 | keepGoing="yes" | |
25 | shift | |
26 | ;; | |
f2374628 AJ |
27 | --use-config-cache) |
28 | #environment variable will be picked up by buildtest.sh | |
29 | cache_file=/tmp/config.cache.$$ | |
30 | export cache_file | |
31 | shift | |
32 | ;; | |
33 | --aggressively-use-config-cache) | |
34 | #environment variable will be picked up by buildtest.sh | |
35 | #note: use ONLY if you know what you're doing | |
36 | cache_file=/tmp/config.cache | |
37 | remove_cache_file="false" | |
38 | export cache_file | |
39 | shift | |
40 | ;; | |
14777424 AJ |
41 | *) |
42 | break | |
43 | ;; | |
44 | esac | |
45 | done | |
1c148717 | 46 | |
14777424 AJ |
47 | logtee() { |
48 | if [ $verbose = yes ]; then | |
49 | tee $1 | |
50 | else | |
51 | cat >$1 | |
52 | fi | |
53 | } | |
54 | ||
55 | buildtest() { | |
56 | opts=$1 | |
4abfd78b AJ |
57 | layer=`basename ${opts} .opts` |
58 | btlayer="bt${layer}" | |
14777424 AJ |
59 | log=${btlayer}.log |
60 | echo "TESTING: ${layer}" | |
6c34942f AJ |
61 | if test -e ${btlayer}; then |
62 | chmod -R 777 ${btlayer}; | |
63 | fi | |
3f3f6a5c AJ |
64 | rm -f -r ${btlayer} || ( echo "FATAL: Failed to prepare test build sandpit." ; exit 1 ) |
65 | mkdir ${btlayer} | |
8750c38e AJ |
66 | if test "${verbose}" = "yes" ; then |
67 | ls -la ${btlayer} | |
68 | fi | |
14777424 | 69 | { |
4abfd78b | 70 | result=255 |
14777424 AJ |
71 | cd ${btlayer} |
72 | if test -e $top/test-suite/buildtest.sh ; then | |
4abfd78b AJ |
73 | $top/test-suite/buildtest.sh ${opts} 2>&1 |
74 | result=$? | |
14777424 | 75 | elif test -e ../$top/test-suite/buildtest.sh ; then |
4abfd78b AJ |
76 | ../$top/test-suite/buildtest.sh ../${opts} 2>&1 |
77 | result=$? | |
78 | else | |
79 | echo "Error: cannot find $top/test-suite/buildtest.sh script" | |
80 | result=1 | |
14777424 | 81 | fi |
4abfd78b AJ |
82 | |
83 | # log the result for the outer script to notice | |
84 | echo "buildtest.sh result is $result"; | |
85 | } 2>&1 | logtee ${log} | |
86 | ||
87 | result=1 # failure by default | |
88 | if grep -q '^buildtest.sh result is 0$' ${log}; then | |
89 | result=0 | |
90 | fi | |
91 | ||
92 | # Display BUILD parameters to double check that we are building the | |
93 | # with the right parameters. TODO: Make less noisy. | |
14777424 | 94 | grep -E "BUILD" ${log} |
4abfd78b | 95 | |
0f6442bc | 96 | errors="^ERROR|\ error:|\ Error\ |No\ such|assertion\ failed|FAIL:|:\ undefined" |
4abfd78b AJ |
97 | grep -E "${errors}" ${log} |
98 | ||
4abfd78b AJ |
99 | if test $result -eq 0; then |
100 | # successful execution | |
8750c38e | 101 | if test "${verbose}" = "yes"; then |
4abfd78b AJ |
102 | echo "Build OK. Global result is $globalResult." |
103 | fi | |
3f3f6a5c AJ |
104 | if test "${cleanup}" = "yes" ; then |
105 | echo "REMOVE DATA: ${btlayer}" | |
106 | chmod -R 777 ${btlayer} | |
107 | rm -f -r ${btlayer} | |
108 | echo "REMOVE LOG: ${log}" | |
109 | rm -f -r ${log} | |
110 | fi | |
14777424 | 111 | else |
8750c38e AJ |
112 | if test "${verbose}" != "yes" ; then |
113 | echo "Build Failed. Last log lines are:" | |
114 | tail -20 ${log} | |
115 | else | |
116 | echo "Build FAILED." | |
117 | fi | |
118 | globalResult=1 | |
14777424 | 119 | fi |
14777424 AJ |
120 | } |
121 | ||
f2374628 AJ |
122 | # if using cache, make sure to clear it up first |
123 | if [ -n "$cache_file" -a -e "$cache_file" -a "$remove_cache_file" = "true" ]; then | |
124 | rm $cache_file | |
125 | fi | |
126 | ||
4abfd78b AJ |
127 | # Decide what tests to run, $* contains test spec names or filenames. |
128 | # Use all knows specs if $* is empty or a special macro called 'all'. | |
129 | if test -n "$*" -a "$*" != all; then | |
130 | tests="$*" | |
131 | else | |
132 | tests=`ls -1 $top/test-suite/buildtests/layer*.opts` | |
bea1ee2e AJ |
133 | fi |
134 | ||
4abfd78b AJ |
135 | for t in $tests; do |
136 | if test -e "$t"; then | |
137 | # A configuration file | |
138 | cfg="$t" | |
139 | elif test -e "$top/test-suite/buildtests/${t}.opts"; then | |
140 | # A well-known configuration name | |
141 | cfg="$top/test-suite/buildtests/${t}.opts" | |
142 | else | |
143 | echo "Error: Unknown test specs '$t'" | |
144 | cfg='' | |
145 | globalResult=1 | |
146 | fi | |
147 | ||
148 | # run the test, if any | |
149 | if test -n "$cfg"; then | |
150 | buildtest $cfg | |
151 | fi | |
152 | ||
153 | # quit on errors unless we should $keepGoing | |
154 | if test $globalResult -ne 0 -a $keepGoing != yes; then | |
155 | exit $globalResult | |
156 | fi | |
bea1ee2e | 157 | done |
4abfd78b | 158 | |
f2374628 AJ |
159 | # if using cache, make sure to clear it up first |
160 | if [ -n "$cache_file" -a -e "$cache_file" -a "$remove_cache_file" = "true" ]; then | |
161 | rm $cache_file | |
162 | fi | |
163 | ||
4abfd78b | 164 | exit $globalResult |