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