free libevent event-base memory when gotwebd exits to avoid leak report
[got-portable.git] / util / got-build-regress.sh
blob5e69e7a41136867e7c6a7becce542178c8034e37
1 #!/bin/sh
3 # Copyright (c) 2020 Stefan Sperling <stsp@openbsd.org>
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 prog=`basename $0`
18 usage="$prog [-fG] [-b branch] [-R testroot] [-r from-address] [-w worktree] email-address ..."
19 branch=main
20 worktree=$HOME/got
21 fromaddr_arg=
22 force=0
23 gotd=0
24 webd=0
25 testroot="/tmp"
27 while getopts b:fGR:r:w: arg; do
28 case $arg in
30 branch="$OPTARG" ;;
32 force=1 ;;
34 gotd=1 ;;
36 webd=1 ;;
38 worktree="$OPTARG" ;;
40 fromaddr_arg="-r $OPTARG" ;;
42 testroot="$OPTARG" ;;
44 echo "usage: $usage" >&2
45 exit 1 ;;
46 esac
47 done
48 shift $(($OPTIND - 1))
50 recipients="$@"
51 if [ -z "$recipients" ]; then
52 echo "usage: $usage" >&2
53 exit 1
56 log_cmd() {
57 logfile=$1
58 shift
59 echo \$ $@ >> $logfile
60 $* >> $logfile 2>&1
63 ncpu=`sysctl -n hw.ncpuonline`
64 lockfile=$worktree/.${prog}.lock
66 cd "$worktree" || exit 1
68 lockfile -r 3 "$lockfile" || exit 1
69 trap "rm -f '$lockfile'" HUP INT QUIT KILL TERM EXIT
71 rm -f regress.log failures.log
72 echo -n "$prog for branch '$branch' on " > build.log
73 date -u >> build.log
75 printf "\nRunning on " >> build.log
76 sysctl -n kern.version >> build.log
78 printf "\n\tCleaning the work tree\n\n" >> build.log
79 log_cmd build.log got status
80 log_cmd build.log make clean
82 printf "\n\n\tUpdating the work tree\n\n" >> build.log
83 log_cmd build.log cat .got/base-commit
84 old_basecommit=`cat .got/base-commit`
85 log_cmd build.log /usr/local/bin/got update -b "$branch"
86 update_status="$?"
87 if [ "$update_status" -ne 0 ]; then
88 mail $fromaddr_arg -s "$prog update failure" $recipients < build.log
89 exit 0
91 new_basecommit=`cat .got/base-commit`
93 if [ "$force" -ne 1 -a "$old_basecommit" == "$new_basecommit" ]; then
94 exit 0
97 printf "\n\n\tTesting a regular dev build\n\n" >> build.log
98 log_cmd build.log make obj
99 log_cmd build.log make -j $ncpu
100 build_status="$?"
101 if [ "$build_status" -ne 0 ]; then
102 mail $fromaddr_arg -s "$prog build failure" $recipients < build.log
103 exit 0
105 log_cmd build.log make install
106 log_cmd build.log make -j $ncpu webd
107 build_status="$?"
108 if [ "$build_status" -ne 0 ]; then
109 mail $fromaddr_arg -s "$prog build failure" $recipients < build.log
110 exit 0
112 log_cmd build.log make -j $ncpu server
113 build_status="$?"
114 if [ "$build_status" -ne 0 ]; then
115 mail $fromaddr_arg -s "$prog build failure" $recipients < build.log
116 exit 0
118 log_cmd build.log make server-install
120 printf "\n\n\tRunning tests\n\n" >> build.log
121 log_cmd regress.log env PATH=$HOME/bin:$PATH make regress GOT_TEST_ROOT="$testroot"
122 regress_status="$?"
123 cat regress.log >> build.log
124 egrep "test.*failed" regress.log > failures.log
125 regress_failure_grep="$?"
126 if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 0 ]; then
127 printf "\n\n\t Test failures:\n\n" >> build.log
128 cat failures.log >> build.log
129 mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
130 exit 0
133 printf "\n\n\tRunning tests with pack files\n\n" >> build.log
134 log_cmd regress.log env PATH=$HOME/bin:$PATH make regress GOT_TEST_ROOT="$testroot" GOT_TEST_PACK=1
135 regress_status="$?"
136 cat regress.log >> build.log
137 egrep "test.*failed" regress.log > failures.log
138 regress_failure_grep="$?"
139 if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 0 ]; then
140 printf "\n\n\t Test failures:\n\n" >> build.log
141 cat failures.log >> build.log
142 mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
143 exit 0
146 printf "\n\n\tRunning tests with pack files using ref-delta\n\n" >> build.log
147 log_cmd regress.log env PATH=$HOME/bin:$PATH make regress GOT_TEST_ROOT="$testroot" GOT_TEST_PACK=ref-delta
148 regress_status="$?"
149 cat regress.log >> build.log
150 egrep "test.*failed" regress.log > failures.log
151 regress_failure_grep="$?"
152 if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 0 ]; then
153 printf "\n\n\t Test failures:\n\n" >> build.log
154 cat failures.log >> build.log
155 mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
156 exit 0
159 printf "\n\n\tRunning tests with sha256\n\n" >> build.log
160 log_cmd regress.log env PATH=$HOME/bin:$PATH make regress GOT_TEST_ROOT="$testroot" GOT_TEST_ALGO=sha256
161 regress_status="$?"
162 cat regress.log >> build.log
163 egrep "test.*failed" regress.log > failures.log
164 regress_failure_grep="$?"
165 if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 0 ]; then
166 printf "\n\n\t Test failures:\n\n" >> build.log
167 cat failures.log >> build.log
168 mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
169 exit 0
172 printf "\n\n\tRunning tests with sha256 and pack files\n\n" >> build.log
173 log_cmd regress.log env PATH=$HOME/bin:$PATH make regress GOT_TEST_ROOT="$testroot" GOT_TEST_ALGO=sha256 GOT_TEST_PACK=1
174 regress_status="$?"
175 cat regress.log >> build.log
176 egrep "test.*failed" regress.log > failures.log
177 regress_failure_grep="$?"
178 if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 0 ]; then
179 printf "\n\n\t Test failures:\n\n" >> build.log
180 cat failures.log >> build.log
181 mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
182 exit 0
185 if [ $gotd -ne 0 ]; then
186 printf "\n\n\tRunning gotd tests\n\n" >> build.log
187 log_cmd regress.log doas env PATH=$HOME/bin:$PATH make server-regress
188 regress_status=$?
189 cat regress.log >> build.log
190 egrep "test.*failed" regress.log > failures.log
191 regress_failure_grep="$?"
192 if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 0 ]; then
193 printf "\n\n\t Test failures:\n\n" >> build.log
194 cat failures.log >> build.log
195 mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
196 exit 0
200 if [ $webd -ne 0 ]; then
201 printf "\n\n\tRunning gotwebd tests\n\n" >> build.log
202 log_cmd regress.log doas env PATH=$HOME/bin:$PATH make webd-regress
203 regress_status=$?
204 cat regress.log >> build.log
205 egrep "test.*failed" regress.log > failures.log
206 regress_failure_grep="$?"
207 if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 0 ]; then
208 printf "\n\n\t Test failures:\n\n" >> build.log
209 cat failures.log >> build.log
210 mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
211 exit 0
215 printf "\n\n\tTesting a release build\n\n" >> build.log
216 log_cmd build.log make clean
217 log_cmd build.log make obj
218 log_cmd build.log make -j $ncpu GOT_RELEASE=Yes
219 log_cmd build.log make -j $ncpu GOT_RELEASE=Yes webd
220 log_cmd build.log make -j $ncpu GOT_RELEASE=Yes server
221 build_status="$?"
222 if [ "$build_status" -ne 0 ]; then
223 mail $fromaddr_arg -s "$prog release mode build failure" $recipients < build.log
224 exit 0
227 exit 0