1#!/bin/sh 2# 3# Copyright (C) 2010, 2012 Internet Systems Consortium, Inc. ("ISC") 4# 5# Permission to use, copy, modify, and/or 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. 8# 9# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 10# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 11# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 12# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 13# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 14# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 15# PERFORMANCE OF THIS SOFTWARE. 16 17# Id: run.sh,v 1.2 2010/06/17 05:38:05 marka Exp 18 19SYSTEMTESTTOP=. 20. $SYSTEMTESTTOP/conf.sh 21 22stopservers=true 23 24case $1 in 25 --keep) stopservers=false; shift ;; 26esac 27 28test $# -gt 0 || { echo "usage: $0 [--keep] test-directory" >&2; exit 1; } 29 30test=$1 31shift 32 33test -d $test || { echo "$0: $test: no such test" >&2; exit 1; } 34 35echo "S:$test:`date`" >&2 36echo "T:$test:1:A" >&2 37echo "A:Virtual time test $test" >&2 38 39if [ x$PERL = x ] 40then 41 echo "I:Perl not available. Skipping test." >&2 42 echo "R:UNTESTED" >&2 43 echo "E:$test:`date`" >&2 44 exit 0; 45fi 46 47$PERL testsock.pl || { 48 echo "I:Network interface aliases not set up. Skipping test." >&2 49 echo "R:UNTESTED" >&2 50 echo "E:$test:`date`" >&2 51 exit 0; 52} 53 54# Check for test-specific prerequisites. 55if 56 test ! -f $test/prereq.sh || 57 ( cd $test && sh prereq.sh "$@" ) 58then 59 : prereqs ok 60else 61 echo "I:Prerequisites for $test missing, skipping test." >&2 62 echo "R:UNTESTED" >&2 63 echo "E:$test:`date`" >&2 64 exit 0; 65fi 66 67# Set up any dynamically generated test data 68if test -f $test/setup.sh 69then 70 ( cd $test && sh setup.sh "$@" ) 71fi 72 73# Start name servers running 74$PERL start.pl $test || exit 1 75 76# Run the tests 77( cd $test ; sh tests.sh ) 78 79status=$? 80 81if $stopservers 82then 83 : 84else 85 exit $status 86fi 87 88# Shutdown 89$PERL stop.pl $test 90 91status=`expr $status + $?` 92 93if [ $status != 0 ]; then 94 echo "R:FAIL" 95 # Don't clean up - we need the evidence. 96 find . -name core -exec chmod 0644 '{}' \; 97else 98 echo "R:PASS" 99 100 # Clean up. 101 if test -f $test/clean.sh 102 then 103 ( cd $test && sh clean.sh "$@" ) 104 fi 105fi 106 107echo "E:$test:`date`" 108 109exit $status 110