]> arthur.barton.de Git - ngircd-alex.git/blob - src/testsuite/tests.sh
ngIRCd Release 27
[ngircd-alex.git] / src / testsuite / tests.sh
1 #!/bin/sh
2 #
3 # ngIRCd Test Suite
4 # Copyright (c)2001-2024 Alexander Barton (alex@barton.de) and Contributors.
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 # Please read the file COPYING, README and AUTHORS for more information.
11 #
12
13 # detect source directory
14 [ -z "$srcdir" ] && srcdir=`dirname $0`
15
16 name=`basename $0`
17 test=`echo ${name} | cut -d '.' -f 1`
18 [ -d logs ] || mkdir logs
19
20 if [ ! -r "$test" ]; then
21   echo "$test: test not found" >>tests-skipped.lst
22   echo "${name}: test \"$test\" not found!";  exit 77
23   exit 1
24 fi
25
26 # read in functions
27 . ${srcdir}/functions.inc
28
29 type expect > /dev/null 2>&1
30 if [ $? -ne 0 ]; then
31   echo "$test: \"expect\" not found" >>tests-skipped.lst
32   echo "${name}: \"expect\" not found.";  exit 77
33 fi
34 type telnet > /dev/null 2>&1
35 if [ $? -ne 0 ]; then
36   echo "$test: \"telnet\" not found" >>tests-skipped.lst
37   echo "${name}: \"telnet\" not found.";  exit 77
38 fi
39
40 case "$test" in
41   *ssl*)
42     type openssl > /dev/null 2>&1
43     if [ $? -ne 0 ]; then
44       echo "$test: \"openssl\" not found" >>tests-skipped.lst
45       echo "${name}: \"openssl\" not found.";  exit 77
46     fi
47     ;;
48 esac
49
50 # prepare expect script
51 e_in="${srcdir}/${test}.e"
52 e_tmp="${test}.e_"
53 e_exec="$e_in"
54 if test -t 1 2>/dev/null; then
55         sed -e 's|^expect |puts -nonewline stderr "."; expect |g' \
56                 "$e_in" >"$e_tmp"
57         [ $? -eq 0 ] && e_exec="$e_tmp"
58 fi
59
60 echo_n "running ${test} ..."
61 expect "$e_exec" > logs/${test}.log; r=$?
62 [ $r -eq 0 ] && echo " ok." || echo " failure!"
63
64 rm -f "$e_tmp"
65 exit $r
66
67 # -eof-