xref: /minix/external/bsd/bind/dist/bin/tests/system/run.sh (revision fb9c64b2)
1#!/bin/sh
2#
3# Copyright (C) 2004, 2007, 2010, 2012, 2014  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#
19# Run a system test.
20#
21
22SYSTEMTESTTOP=.
23. $SYSTEMTESTTOP/conf.sh
24
25stopservers=true
26
27case $1 in
28   --keep) stopservers=false; shift ;;
29esac
30
31test $# -gt 0 || { echo "usage: $0 [--keep] test-directory" >&2; exit 1; }
32
33test=$1
34shift
35
36test -d $test || { echo "$0: $test: no such test" >&2; exit 1; }
37
38echo "S:$test:`date`" >&2
39echo "T:$test:1:A" >&2
40echo "A:System test $test" >&2
41
42if [ x${PERL:+set} = x ]
43then
44    echo "I:Perl not available.  Skipping test." >&2
45    echo "R:UNTESTED" >&2
46    echo "E:$test:`date`" >&2
47    exit 0;
48fi
49
50$PERL testsock.pl || {
51    echo "I:Network interface aliases not set up.  Skipping test." >&2;
52    echo "R:UNTESTED" >&2;
53    echo "E:$test:`date`" >&2;
54    exit 0;
55}
56
57
58# Check for test-specific prerequisites.
59test ! -f $test/prereq.sh || ( cd $test && $SHELL prereq.sh "$@" )
60result=$?
61
62if [ $result -eq 0 ]; then
63    : prereqs ok
64else
65    echo "I:Prerequisites for $test missing, skipping test." >&2
66    [ $result -eq 255 ] && echo "R:SKIPPED" || echo "R:UNTESTED"
67    echo "E:$test:`date`" >&2
68    exit 0
69fi
70
71# Check for PKCS#11 support
72if
73    test ! -f $test/usepkcs11 || $SHELL cleanpkcs11.sh
74then
75    : pkcs11 ok
76else
77    echo "I:Need PKCS#11 for $test, skipping test." >&2
78    echo "R:PKCS11ONLY" >&2
79    echo "E:$test:`date`" >&2
80    exit 0
81fi
82
83# Set up any dynamically generated test data
84if test -f $test/setup.sh
85then
86   ( cd $test && $SHELL setup.sh "$@" )
87fi
88
89# Start name servers running
90$PERL start.pl $test || exit 1
91
92# Run the tests
93( cd $test ; $SHELL tests.sh )
94
95status=$?
96
97if $stopservers
98then
99    :
100else
101    exit $status
102fi
103
104# Shutdown
105$PERL stop.pl $test
106
107status=`expr $status + $?`
108
109if [ $status != 0 ]; then
110	echo "R:FAIL"
111	# Don't clean up - we need the evidence.
112	find . -name core -exec chmod 0644 '{}' \;
113else
114	echo "R:PASS"
115
116	# Clean up.
117        rm -f $SYSTEMTESTTOP/random.data
118	if test -f $test/clean.sh
119	then
120	   ( cd $test && $SHELL clean.sh "$@" )
121	fi
122fi
123
124echo "E:$test:`date`"
125
126exit $status
127