tests.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. # detect source directory
  13. [ -z "$srcdir" ] && srcdir=`dirname "$0"`
  14. set -u
  15. name=`basename "$0"`
  16. test=`echo ${name} | cut -d '.' -f 1`
  17. [ -d logs ] || mkdir logs
  18. if [ ! -r "$test" ]; then
  19. echo "$test: test not found" >>tests-skipped.lst
  20. echo "${name}: test \"$test\" not found!"; exit 77
  21. exit 1
  22. fi
  23. # read in functions
  24. . "${srcdir}/functions.inc"
  25. type expect >/dev/null 2>&1
  26. if [ $? -ne 0 ]; then
  27. echo "$test: \"expect\" not found" >>tests-skipped.lst
  28. echo "${name}: \"expect\" not found."
  29. exit 77
  30. fi
  31. type telnet >/dev/null 2>&1
  32. if [ $? -ne 0 ]; then
  33. echo "$test: \"telnet\" not found" >>tests-skipped.lst
  34. echo "${name}: \"telnet\" not found."
  35. exit 77
  36. fi
  37. case "$test" in
  38. *ssl*)
  39. type openssl >/dev/null 2>&1
  40. if [ $? -ne 0 ]; then
  41. echo "$test: \"openssl\" not found" >>tests-skipped.lst
  42. echo "${name}: \"openssl\" not found."
  43. exit 77
  44. fi
  45. ;;
  46. esac
  47. # prepare expect script
  48. e_in="${srcdir}/${test}.e"
  49. e_tmp="${test}.e_"
  50. e_exec="$e_in"
  51. if test -t 1 2>/dev/null; then
  52. sed -e 's|^expect |puts -nonewline stderr "."; expect |g' \
  53. "$e_in" >"$e_tmp"
  54. [ $? -eq 0 ] && e_exec="$e_tmp"
  55. fi
  56. echo_n "running ${test} ..."
  57. expect "$e_exec" >logs/${test}.log; r=$?
  58. [ $r -eq 0 ] && echo " ok." || echo " failure!"
  59. rm -f "$e_tmp"
  60. exit $r