From: gord-fig Date: Thu, 22 Aug 2002 20:32:12 +0000 (+0000) Subject: Simplify adding manual test results to Tinderbox. X-Git-Tag: 0.5.5~79 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=95351000f1fa443e8b17f87da984880304ae9766;p=fs%2Flustre-release.git Simplify adding manual test results to Tinderbox. --- diff --git a/lustre/tests/Makefile.am b/lustre/tests/Makefile.am index c474a47..896728a 100644 --- a/lustre/tests/Makefile.am +++ b/lustre/tests/Makefile.am @@ -20,7 +20,7 @@ noinst_SCRIPTS = fs.sh intent-test.sh intent-test2.sh leak_finder.pl \ llrmount.sh llsimple.sh mdcreq.sh mdcreqcleanup.sh \ ostreq.sh runfailure-client-mds-recover.sh runfailure-mds \ runfailure-net runfailure-ost runiozone runregression-net.sh \ - runtests runvmstat snaprun.sh + runtests runvmstat snaprun.sh tbox.sh pkglib_SCRIPTS = common.sh pkgcfg_DATA = lustre.cfg noinst_PROGRAMS = openunlink testreq truncate directio openme writeme mcreate diff --git a/lustre/tests/tbox.sh b/lustre/tests/tbox.sh new file mode 100644 index 0000000..6e1b211 --- /dev/null +++ b/lustre/tests/tbox.sh @@ -0,0 +1,111 @@ +# tbox.sh - Shell functions to manage tinderbox build reporting +# Copyright (C) 2002 Cluster File Systems, Inc. +# Gord Eagle , 2002-08-22 + +HOSTNAME=`hostname` +PROGNAME=`echo "$0" | sed -e 's%^.*/%%'` +MAILPROG="${MAILPROG-mail}" + +TBOX_PHASE=build # or test +TBOX_STARTTIME=`date +%s` +TBOX_LOG="${TBOX_LOG-/tmp/tbox.$$.$TBOX_STARTTIME.log}" +TBOX_BUILDMAIL=tinderbox_builds@lustre.org +TBOX_BUILDNAME="${TBOX_BUILDNAME-$PROGNAME-$HOSTNAME}" + +# Send a status message to the list. +tbox_status() { + [ -n "$TBOX_BUILDNAME" -a -n "$TBOX_BUILDMAIL" ] || return 0 + [ "$#" -ge 4 ] || return 1 + if [ "$#" -gt 4 ]; then + log="$5" + echo >> $log + else + log= + fi + + TREE="$1" + SUBJECT="$2" + STATUS="$3" + TIMENOW="$4" + + echo "sending tinderbox mail to $TBOX_BUILDMAIL: $TREE $SUBJECT $STATUS" + + TMPFILE="/tmp/tinderbox.boilerplate.$$.$TIMENOW" + + cat > $TMPFILE <<-EOF + tinderbox: tree: $TREE + tinderbox: starttime: $TBOX_STARTTIME + tinderbox: timenow: $TIMENOW + tinderbox: builddate: $TBOX_STARTTIME + tinderbox: status: $STATUS + tinderbox: buildname: $TBOX_BUILDNAME + tinderbox: errorparser: unix + tinderbox: END + +EOF + + cat $TMPFILE $log | $MAILPROG -s "build $SUBJECT ($TBOX_BUILDNAME)" $TBOX_BUILDMAIL + rm -f $TMPFILE +} + +# Send out the failure or success message based on exit status. +tbox_exit() { + TREE="$1" + TAILPID="$2" + CODE=${3-$?} + if [ $CODE -eq 0 ]; then + SUBJECT=successful + STATUS=success + else + SUBJECT=failed + STATUS="${TBOX_PHASE}_failed" + fi + + # Send off the status message. + trap 0 + tbox_status "$TREE" "$SUBJECT" "$STATUS" + rm -f $TBOX_LOG + + # Wait for tail to display all output, then finish it. + sleep 1 + kill $TAILPID + exit $CODE +} + +# Run a subprogram, but stop it from sending its own tinderbox +# messages. +tbox_dont_start_log() { + eval 'TBOX_LOG= '"$@" +} + +# Start the log for a given tree. +tbox_start_log() { + TREE="$1" + + # Send status messages to stdout, stderr. + exec 6>&1 7>&2 + + [ -n "$TBOX_LOG" ] || return 0 + + # Initialize the output log file. + : > $TBOX_LOG + + # Send all our output to the log. + exec >>$TBOX_LOG 2>&1 + + # Monitor it on the old stdout. + tail -f $TBOX_LOG 1>&6 & + + # Allow tail to print our last output before exiting. + trap "tbox_exit \"$TREE\" $! 1" 1 2 10 15 + trap "tbox_exit \"$TREE\" $!" 0 +} + + +# Begin writing to the log and send out the initial status. +# tbox_start TREE +tbox_start() { + TREE="$1" + tbox_start_log "$TREE" + tbox_status "$TREE" starting building "$TBOX_STARTTIME" +}