blob: 121e6a8b1fc96ad15d9cecdac8f4edfbe203681b [file] [log] [blame]
jsewarde2cac932004-02-25 13:14:39 +00001#!/bin/sh
2
njnf0e0a642005-07-21 21:26:07 +00003#----------------------------------------------------------------------------
4# Automated build and test for Valgrind. Compares Valgrind from 24 hours
njn5a1ba022009-01-07 04:14:42 +00005# ago with the current one. See the README.txt on how to run it.
njnf0e0a642005-07-21 21:26:07 +00006#----------------------------------------------------------------------------
7
8#----------------------------------------------------------------------------
bart82864962009-04-27 08:04:57 +00009# Helper functions
njnf0e0a642005-07-21 21:26:07 +000010#----------------------------------------------------------------------------
jsewarde2cac932004-02-25 13:14:39 +000011
bart3bd1fc52012-02-13 08:47:51 +000012# Returns the revision number for the source files at date $1 in Subversion
13# repo $2. Note: the "--depth" command line argument is supported from
14# Subversion version 1.5 on.
bart82864962009-04-27 08:04:57 +000015get_svn_revision() {
bart3bd1fc52012-02-13 08:47:51 +000016 (
17 cd $DIR
18 rm -rf infodir
19 if ! svn co -r "{$1}" --depth empty "$2" infodir > /dev/null 2>&1; then
20 # Subversion 1.4 or before.
21 rm -rf infodir
22 svn co -r "{$1}" --non-recursive "$2" infodir > /dev/null
23 fi
24 svn info infodir | sed -n 's/^Revision: //p'
25 rm -rf infodir
26 )
bart82864962009-04-27 08:04:57 +000027}
28
tom44380b12005-03-31 10:19:59 +000029runcmd () {
njnf0e0a642005-07-21 21:26:07 +000030 logfile=$1
31 str=$2
32 shift 2
tom44380b12005-03-31 10:19:59 +000033
njne21f85d2009-06-04 01:43:49 +000034 # Header in short logfile.
35 # We use "printf" to avoid printing a newline; "echo -n" isn't POSIX and
36 # so isn't supported on all systems.
37 printf " $str ... " >> $logfile.short
tom44380b12005-03-31 10:19:59 +000038
njnf0e0a642005-07-21 21:26:07 +000039 # Header and command in verbose logfile
njne21f85d2009-06-04 01:43:49 +000040 printf " $str ... " >> $logfile.verbose
njnf0e0a642005-07-21 21:26:07 +000041 echo "$*" >> $logfile.verbose
42
43 # Run the command
bartfd97cec2009-01-12 08:23:15 +000044 ("${ABT_EVAL}" "$*") >> $logfile.verbose 2>&1
njnf0e0a642005-07-21 21:26:07 +000045 res=$?
46
47 # Write result to the short logfile
njn62647eb2009-01-07 04:47:20 +000048 if [ $res = 0 ]
tom44380b12005-03-31 10:19:59 +000049 then
njnf0e0a642005-07-21 21:26:07 +000050 echo "done" >> $logfile.short
tom44380b12005-03-31 10:19:59 +000051 else
njnf0e0a642005-07-21 21:26:07 +000052 echo "failed" >> $logfile.short
tom44380b12005-03-31 10:19:59 +000053 fi
njnf0e0a642005-07-21 21:26:07 +000054
55 return $res
tom44380b12005-03-31 10:19:59 +000056}
57
njnf0e0a642005-07-21 21:26:07 +000058#----------------------------------------------------------------------------
59# Startup
60#----------------------------------------------------------------------------
bart82864962009-04-27 08:04:57 +000061
62valgrind_svn_repo="svn://svn.valgrind.org/valgrind/trunk"
bart3bd1fc52012-02-13 08:47:51 +000063vex_svn_repo="svn://svn.valgrind.org/vex/trunk"
bart82864962009-04-27 08:04:57 +000064
bartfd97cec2009-01-12 08:23:15 +000065# Must have exactly two arguments
njndf8a1112009-01-07 06:19:03 +000066if [ $# -ne 2 ] ; then
bart87fa0df2009-04-05 11:02:29 +000067 echo "usage: $0 /path/to/valgrind/nightly <tag>"
njndf8a1112009-01-07 06:19:03 +000068 exit 1
69fi
70
njnf0e0a642005-07-21 21:26:07 +000071# Get args from command line
njne43358f2009-06-04 23:17:12 +000072DIR=$1
73TAG=$2
jsewarde2cac932004-02-25 13:14:39 +000074
njnf0e0a642005-07-21 21:26:07 +000075# Get times and date
njne43358f2009-06-04 23:17:12 +000076START=`date "+%F %H:%M:%S %Z"`
jsewarde2cac932004-02-25 13:14:39 +000077
njne21f85d2009-06-04 01:43:49 +000078# This is one of the formats SVN accepts. Yes, the 'T' appears in the final
79# string, it's supposed to be like that.
80svn_date_format="+%Y-%m-%dT%H:%M:%S"
81
82# The time-and-date from 24 hours ago is tricky; Linux and Darwin have
83# different ways of getting it, so we try things until something works.
84svn_old_date=
85if [ "z" = "z${svn_old_date}" ] ; then
86 # Linux method.
87 svn_old_date=`date --date=yesterday $svn_date_format 2> /dev/null`
88fi
89if [ "z" = "z${svn_old_date}" ] ; then
90 # Darwin method.
91 svn_old_date=`date -v-24H $svn_date_format 2> /dev/null`
92fi
93if [ "z" = "z${svn_old_date}" ] ; then
94 echo "Sorry, can't work out the time and date for 24 hours ago, aborting"
95 exit 1;
96fi
97
98# The time-and-date for now is easy.
99svn_new_date=`date $svn_date_format`
njnf0e0a642005-07-21 21:26:07 +0000100
njne43358f2009-06-04 23:17:12 +0000101cd $DIR
jsewarde2cac932004-02-25 13:14:39 +0000102
bart82864962009-04-27 08:04:57 +0000103# Clean up output files produced by a previous run.
bart72e40632011-07-30 11:26:57 +0000104rm -rf diffs diffs.txt diff.short final new.short new.verbose old.short old.verbose
njne43358f2009-06-04 23:17:12 +0000105rm -rf sendmail.log unchanged.log valgrind-old valgrind-new
bart82864962009-04-27 08:04:57 +0000106
njndf8a1112009-01-07 06:19:03 +0000107# Setup any relevant environment variables from conf/<tag>.conf.
njne43358f2009-06-04 23:17:12 +0000108. conf/$TAG.conf
bart4a101072008-09-08 18:43:53 +0000109if [ "${ABT_JOBS}" = "" ]; then
110 ABT_JOBS=1
111fi
bartfd97cec2009-01-12 08:23:15 +0000112if [ "${ABT_EVAL}" = "" ]; then
113 ABT_EVAL="eval"
114fi
bart4a101072008-09-08 18:43:53 +0000115if [ "${ABT_RUN_REGTEST}" = "" ]; then
njne43358f2009-06-04 23:17:12 +0000116 ABT_RUN_REGTEST="make regtest"
bart4a101072008-09-08 18:43:53 +0000117fi
jsewarde2cac932004-02-25 13:14:39 +0000118
philippef31fe6f2013-09-27 18:10:29 +0000119if [ "${ABT_PERF_TOOLS}" = "" ]; then
120 ABT_PERF_TOOLS="--tools=none,memcheck,callgrind,helgrind,cachegrind,drd,massif"
121fi
122if [ "${ABT_PERF_REPS}" = "" ]; then
123 ABT_PERF_REPS="--reps=3"
124fi
125
jsewarde2cac932004-02-25 13:14:39 +0000126
njnf0e0a642005-07-21 21:26:07 +0000127#----------------------------------------------------------------------------
128# Check out, build, test
129#----------------------------------------------------------------------------
jsewarde2cac932004-02-25 13:14:39 +0000130
bart3bd1fc52012-02-13 08:47:51 +0000131vg_old_rev="`get_svn_revision ${svn_old_date} ${valgrind_svn_repo}`"
132vg_new_rev="`get_svn_revision ${svn_new_date} ${valgrind_svn_repo}`"
133vex_old_rev="`get_svn_revision ${svn_old_date} ${vex_svn_repo}`"
134vex_new_rev="`get_svn_revision ${svn_new_date} ${vex_svn_repo}`"
135if [ "${vg_old_rev}" = "${vg_new_rev}" -a "${vex_old_rev}" = "${vex_new_rev}" ]
136then
137 echo "Both {$svn_old_date} and {$svn_new_date} correspond to Valgrind r${vg_new_rev} / VEX r${vex_new_rev}"\
bart82864962009-04-27 08:04:57 +0000138 "-- skipping nightly build." >unchanged.log
139 exit 0
140fi
141
njnf0e0a642005-07-21 21:26:07 +0000142# Do everything twice -- once for the 24 hours old Valgrind, and once
143# for the current one.
144for logfile in old new ; do
jsewarde2cac932004-02-25 13:14:39 +0000145
njnf0e0a642005-07-21 21:26:07 +0000146 # Remove old short and verbose log files, and start the new ones
147 for ext in short verbose ; do
148 echo > $logfile.$ext
149 done
jsewarde2cac932004-02-25 13:14:39 +0000150
njnf0e0a642005-07-21 21:26:07 +0000151 # Choose the current Valgrind, or one from 24 hours ago
152 if [ $logfile = "old" ] ; then
153 svn_date=$svn_old_date
154 else
155 svn_date=$svn_new_date
156 fi
jsewarde2cac932004-02-25 13:14:39 +0000157
njnf0e0a642005-07-21 21:26:07 +0000158 # Get dates for the old and new versions
159
160 # Check out, build, run tests
161 runcmd $logfile \
njnf0e0a642005-07-21 21:26:07 +0000162 "Checking out valgrind source tree" \
bart3bd1fc52012-02-13 08:47:51 +0000163 "svn co ${valgrind_svn_repo} -r {$svn_date} valgrind-$logfile\
164 && svn update -r {$svn_date} valgrind-$logfile/VEX" && \
njnf0e0a642005-07-21 21:26:07 +0000165 \
166 runcmd $logfile \
167 "Configuring valgrind " \
njne43358f2009-06-04 23:17:12 +0000168 "cd valgrind-$logfile && ./autogen.sh && ./configure --prefix=`pwd`/valgrind-$logfile/Inst ${ABT_CONFIGURE_OPTIONS}" && \
njnf0e0a642005-07-21 21:26:07 +0000169 \
170 runcmd $logfile \
171 "Building valgrind " \
njne43358f2009-06-04 23:17:12 +0000172 "cd valgrind-$logfile && make -j ${ABT_JOBS} && make -j ${ABT_JOBS} check && make install" && \
njnf0e0a642005-07-21 21:26:07 +0000173 \
174 runcmd $logfile \
175 "Running regression tests " \
njne43358f2009-06-04 23:17:12 +0000176 "cd valgrind-$logfile && ${ABT_RUN_REGTEST}"
njnf0e0a642005-07-21 21:26:07 +0000177
floriandfc9bd12015-08-03 20:03:41 +0000178 # Stash away the return code of the regression run
179 regrun_rc=$?
180
njnf0e0a642005-07-21 21:26:07 +0000181 # Grab some indicative text for the short log file -- if the regtests
182 # succeeded, show their results. If we didn't make it that far, show the
183 # last 20 lines.
184 egrep -q '^== [0-9]+ tests' $logfile.verbose && (
185 echo >> $logfile.short
186 echo "Regression test results follow" >> $logfile.short
187 echo >> $logfile.short
188 awk '/^== [0-9]+ tests/, /^$/ { print }' $logfile.verbose >> $logfile.short
floriandfc9bd12015-08-03 20:03:41 +0000189 # Check the return code of the regression run; we might have successfully
190 # run all tests but still failed in the post-regtest checks.
191 if [ $regrun_rc != "0" ]; then
192 echo >> $logfile.short
193 echo "Last 20 lines of verbose log follow" >> $logfile.short \
194 echo >> $logfile.short
195 tail -20 $logfile.verbose >> $logfile.short
196 fi
njnf0e0a642005-07-21 21:26:07 +0000197 ) || (
198 echo >> $logfile.short
199 echo "Last 20 lines of verbose log follow" >> $logfile.short \
200 echo >> $logfile.short
201 tail -20 $logfile.verbose >> $logfile.short
202 )
203done
204
philippef31fe6f2013-09-27 18:10:29 +0000205# if requested, run regression tests and produce results in perflogfile.out
206if [ "${ABT_PERF}" != "" ]; then
207 cd valgrind-new
208 echo ${ABT_PERF_TOOLS} ${ABT_PERF_REPS} ${ABT_PERF} > ../perflogfile
209 (time perl perf/vg_perf ${ABT_PERF_TOOLS} ${ABT_PERF_REPS} ${ABT_PERF} perf) >> ../perflogfile 2>&1
210 cd ..
211fi
212
213
njnf0e0a642005-07-21 21:26:07 +0000214#----------------------------------------------------------------------------
215# Prepare results and send
216#----------------------------------------------------------------------------
217
njn951c8262009-06-04 02:25:39 +0000218# Get times and date
njne43358f2009-06-04 23:17:12 +0000219END=`date "+%F %H:%M:%S %Z"`
njn951c8262009-06-04 02:25:39 +0000220
florian84ada6b2011-10-04 16:53:34 +0000221# Gather some information about this run and its environment
222valgrind_revision="`svn info valgrind-new | grep Revision | sed 's/Revision[ ]*:[ ]*//'`"
223vex_revision="`svn info valgrind-new/VEX | grep Revision | sed 's/Revision[ ]*:[ ]*//'`"
florian6a27ab32011-11-03 02:10:02 +0000224gcc_version="`gcc --version 2> /dev/null | head -1`"
philippedd6c5142013-01-23 21:46:22 +0000225gdb_version="`gdb --version 2> /dev/null | head -1`"
florian6a27ab32011-11-03 02:10:02 +0000226as_version="`as --version 2> /dev/null | head -1`"
mjw76f2cb12014-09-06 17:37:54 +0000227libc_so="`ls -1 /lib/libc.so.* /lib64/libc.so.* /lib32/libc.so.* /lib/*-linux-gnu/libc.so.* 2>/dev/null | tail -1`"
florian84ada6b2011-10-04 16:53:34 +0000228libc="unknown"
229if [ "x$libc_so" != "x" ]; then
230 if [ -e "$libc_so" -a -r "$libc_so" ]; then
mjwf2c02302014-09-03 17:06:05 +0000231 libc="`$libc_so | head -1`"
florian84ada6b2011-10-04 16:53:34 +0000232 fi
233fi
florian472e42d2011-11-24 16:07:41 +0000234libc=`echo $libc | sed "s/, by Roland.*//"`
florian84ada6b2011-10-04 16:53:34 +0000235uname_stuff="`uname -mrs`"
mjwac5aafe2014-09-06 17:37:55 +0000236if [ -r /etc/os-release ]; then
mjw83b18f42014-09-06 18:33:14 +0000237 vendor_stuff="`. /etc/os-release; echo ${NAME} ${VERSION}`"
mjwac5aafe2014-09-06 17:37:55 +0000238elif which lsb_release 2>&1 > /dev/null; then
239 vendor_stuff="`lsb_release -sicr | xargs echo`"
240elif [ -e "/etc/issue.net" -a -r "/etc/issue.net" ]; then
florian84ada6b2011-10-04 16:53:34 +0000241 vendor_stuff="`cat /etc/issue.net | head -1`"
242else
243 vendor_stuff="unknown"
244fi
245
246echo "valgrind revision: $valgrind_revision" > final
247echo "VEX revision: $vex_revision" >> final
florian6a27ab32011-11-03 02:10:02 +0000248echo "C compiler: $gcc_version" >> final
philippedd6c5142013-01-23 21:46:22 +0000249echo "GDB: $gdb_version" >> final
florian6a27ab32011-11-03 02:10:02 +0000250echo "Assembler: $as_version" >> final
florian84ada6b2011-10-04 16:53:34 +0000251echo "C library: $libc" >> final
252echo "uname -mrs: $uname_stuff" >> final
253echo "Vendor version: $vendor_stuff" >> final
254
njnf0e0a642005-07-21 21:26:07 +0000255# 'final' shows the difference between the old and new results
florian84ada6b2011-10-04 16:53:34 +0000256echo >> final
njne43358f2009-06-04 23:17:12 +0000257echo "Nightly build on" $TAG "(" $ABT_DETAILS ")" >> final
258echo "Started at" $START >> final
259echo "Ended at" $END >> final
njnf0e0a642005-07-21 21:26:07 +0000260
njn2e3fcf32005-08-16 03:28:47 +0000261# If the results differ from 24 hours ago, print extra stuff.
262diff -C1 old.short new.short > diff.short
263changed=$?
264
265if [ $changed != 0 ] ; then
266 echo "Results differ from 24 hours ago" >> final
njncec804b2009-03-10 03:38:05 +0000267 changed_str=""
njn2e3fcf32005-08-16 03:28:47 +0000268else
269 echo "Results unchanged from 24 hours ago" >> final
njncec804b2009-03-10 03:38:05 +0000270 changed_str="(unchanged) "
njn2e3fcf32005-08-16 03:28:47 +0000271fi
272
njnf0e0a642005-07-21 21:26:07 +0000273# Always show the current results.
274cat new.short >> final
275
njn2e3fcf32005-08-16 03:28:47 +0000276if [ $changed != 0 ] ; then
njnf0e0a642005-07-21 21:26:07 +0000277 echo "=================================================" >> final
278 echo "== Results from 24 hours ago ==" >> final
279 echo "=================================================" >> final
280 cat old.short >> final
281
282 echo >> final
283 echo "=================================================" >> final
284 echo "== Difference between 24 hours ago and now ==" >> final
285 echo "=================================================" >> final
286 echo >> final
287 cat diff.short >> final
288 echo >> final
289fi
290
philippef31fe6f2013-09-27 18:10:29 +0000291# add perf results if requested
292if [ "${ABT_PERF}" != "" ]; then
293 cat perflogfile >> final
294fi
295
njndf8a1112009-01-07 06:19:03 +0000296# Gather up the diffs (at most the first 100 lines for each one) into a
297# single file.
298MAX_LINES=100
bart30401252009-01-12 11:06:05 +0000299diff_files=`find . -name '*.diff*' | sort`
njndf8a1112009-01-07 06:19:03 +0000300if [ z"$diff_files" = z ] ; then
301 echo "Congratulations, all tests passed!" >> diffs
302else
303 for i in $diff_files ; do
304 echo "=================================================" >> diffs
305 echo $i >> diffs
306 echo "=================================================" >> diffs
307 if [ `wc -l < $i` -le $MAX_LINES ] ; then
308 cat $i >> diffs
309 else
njn1f2df3e2009-01-07 08:08:41 +0000310 head -n $MAX_LINES $i >> diffs
njndf8a1112009-01-07 06:19:03 +0000311 echo "<truncated beyond $MAX_LINES lines>" >> diffs
312 fi
313 done
314fi
315
bart72e40632011-07-30 11:26:57 +0000316# Rename diffs into diffs.txt such that it can be viewed easily with an
317# e-mail client.
318mv diffs diffs.txt
319
njndf8a1112009-01-07 06:19:03 +0000320# Use the conf/<tag>.sendmail script to email the results.
njne43358f2009-06-04 23:17:12 +0000321conf/$TAG.sendmail \
322 "$changed_str$START nightly build ($TAG, $ABT_DETAILS)" \
njndf8a1112009-01-07 06:19:03 +0000323 final \
bart72e40632011-07-30 11:26:57 +0000324 diffs.txt > sendmail.log 2>&1