Admin/isatest-makeall
author nipkow
Mon, 08 Jul 2002 15:01:58 +0200
changeset 13312 ad91cf279f06
parent 13246 e51efc2029e9
child 13320 2c6ee189ae63
permissions -rwxr-xr-x
*** empty log message ***

#!/usr/bin/env bash
#
# $Id$
# Author: Gerwin Klein, TU Muenchen
# License: GPL (GNU GENERAL PUBLIC LICENSE)
#
# DESCRIPTION: Run isatool makeall from specified distribution and settings.
#              Send email if it fails.

## global settings
MAILTO="kleing@in.tum.de test@jflex.de"

LOGPREFIX=~/log

MASTERLOG=$LOGPREFIX/isatest.log

## diagnostics

PRG="$(basename "$0")"

function usage()
{
  echo
  echo "Usage: $PRG distributionpath settings1 [settings2 ...]"
  echo
  echo "  Run isatool makeall from specified distribution and settings."
  echo "  Send email if it fails."
  echo
  exit 1
}

function fail()
{
  echo "$1" >&2
  exit 2
}

## main

# argument checking

[ "$1" = "-?" ] && usage
[ "$#" -lt "2" ] && usage

DISTPREFIX=$1
shift

[ -d $DISTPREFIX ] || fail "$DISTPREFIX is not a directory."

for SETTINGS in $@; do

    [ -r $SETTINGS ] || fail "Cannot read $SETTINGS."
    

    # logfile setup

    DATE=$(date "+%d-%b-%Y")
    SHORT=${SETTINGS##*/}
    TESTLOG=$LOGPREFIX/isatest-makeall-$SHORT-$DATE-$HOSTNAME.log

    # the test

    echo ------------------- starting test --- `date` --- $HOSTNAME > $TESTLOG 2>&1

    cp $DISTPREFIX/Isabelle/etc/settings $DISTPREFIX/Isabelle/etc/settings.save-$SHORT
    cat $SETTINGS >> $DISTPREFIX/Isabelle/etc/settings
    $DISTPREFIX/Isabelle/bin/isatool makeall all >> $TESTLOG 2>&1 

    if [ $? -eq 0 ]
    then
        echo ------------------- test successful --- `date` --- $HOSTNAME >> $TESTLOG 2>&1
        mv $DISTPREFIX/Isabelle/etc/settings.save-$SHORT $DISTPREFIX/Isabelle/etc/settings
        gzip -f $TESTLOG
	rm -rf ~/isabelle-$SHORT
    else
        echo ------------------- test FAILED --- `date` --- $HOSTNAME >> $TESTLOG 2>&1
	FAIL="$FAIL$SHORT "
	for R in $MAILTO; do
    		mail -t $R <<EOM
Subject: isabelle test failed

Test for platform $SHORT failed. Log file available at

$HOSTNAME:$TESTLOG
EOM
	done
        # more action here
    fi

done

ELAPSED=$("$HOME/bin/showtime" "$SECONDS")

if [ "$FAIL" != "" ]; then
	echo "$(date) $HOSTNAME $PRG: targets ${FAIL}FAILED, elapsed time $ELAPSED." >> $MASTERLOG
	exit 1
else
        echo "$(date) $HOSTNAME $PRG: all tests successful, elapsed time $ELAPSED." >> $MASTERLOG
fi

# end