]> arthur.barton.de Git - ngircd-alex.git/blob - src/testsuite/tests.sh
Clarify that "CAFile" is not set by default
[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 set -u
16
17 name=`basename "$0"`
18 test=`echo ${name} | cut -d '.' -f 1`
19 [ -d logs ] || mkdir logs
20
21 if [ ! -r "$test" ]; then
22         echo "$test: test not found" >>tests-skipped.lst
23         echo "${name}: test \"$test\" not found!";  exit 77
24         exit 1
25 fi
26
27 # read in functions
28 . "${srcdir}/functions.inc"
29
30 type expect >/dev/null 2>&1
31 if [ $? -ne 0 ]; then
32         echo "$test: \"expect\" not found" >>tests-skipped.lst
33         echo "${name}: \"expect\" not found."
34         exit 77
35 fi
36 type telnet >/dev/null 2>&1
37 if [ $? -ne 0 ]; then
38         echo "$test: \"telnet\" not found" >>tests-skipped.lst
39         echo "${name}: \"telnet\" not found."
40         exit 77
41 fi
42
43 case "$test" in
44         *ssl*)
45                 type openssl >/dev/null 2>&1
46                 if [ $? -ne 0 ]; then
47                         echo "$test: \"openssl\" not found" >>tests-skipped.lst
48                         echo "${name}: \"openssl\" not found."
49                         exit 77
50                 fi
51                 ;;
52 esac
53
54 # prepare expect script
55 e_in="${srcdir}/${test}.e"
56 e_tmp="${test}.e_"
57 e_exec="$e_in"
58 if test -t 1 2>/dev/null; then
59         sed -e 's|^expect |puts -nonewline stderr "."; expect |g' \
60                 "$e_in" >"$e_tmp"
61         [ $? -eq 0 ] && e_exec="$e_tmp"
62 fi
63
64 echo_n "running ${test} ..."
65 expect "$e_exec" >logs/${test}.log; r=$?
66 [ $r -eq 0 ] && echo " ok." || echo " failure!"
67
68 rm -f "$e_tmp"
69 exit $r