severity_test.sh.in 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/sh
  2. # Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
  3. #
  4. # Permission to use, copy, modify, and/or distribute this software for any
  5. # purpose with or without fee is hereby granted, provided that the above
  6. # copyright notice and this permission notice appear in all copies.
  7. #
  8. # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  9. # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  10. # AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  11. # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  12. # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  13. # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  14. # PERFORMANCE OF THIS SOFTWARE.
  15. # \brief Severity test
  16. #
  17. # Checks that the logger will limit the output of messages less severy than
  18. # the severity/debug setting.
  19. testname="Severity test"
  20. echo $testname
  21. failcount=0
  22. tempfile=@abs_builddir@/severity_test_tempfile_$$
  23. passfail() {
  24. if [ $1 -eq 0 ]; then
  25. echo " -- pass"
  26. else
  27. echo " ** FAIL"
  28. failcount=`expr $failcount + $1`
  29. fi
  30. }
  31. echo "1. runInitTest default parameters: "
  32. cat > $tempfile << .
  33. FATAL [alpha.example] MSG_WRITERR, error writing to test1: 42
  34. ERROR [alpha.example] MSG_RDLOCMES, reading local message file dummy/file
  35. WARN [alpha.dlm] MSG_READERR, error reading from message file a.txt: dummy reason
  36. INFO [alpha.dlm] MSG_OPENIN, unable to open message file example.msg for input: dummy reason
  37. .
  38. ./logger_example -c stdout | cut -d' ' -f3- | diff $tempfile -
  39. passfail $?
  40. echo "2. Severity filter: "
  41. cat > $tempfile << .
  42. FATAL [alpha.example] MSG_WRITERR, error writing to test1: 42
  43. ERROR [alpha.example] MSG_RDLOCMES, reading local message file dummy/file
  44. .
  45. ./logger_example -c stdout -s error | cut -d' ' -f3- | diff $tempfile -
  46. passfail $?
  47. echo "3. Debug level: "
  48. cat > $tempfile << .
  49. FATAL [alpha.example] MSG_WRITERR, error writing to test1: 42
  50. ERROR [alpha.example] MSG_RDLOCMES, reading local message file dummy/file
  51. WARN [alpha.dlm] MSG_READERR, error reading from message file a.txt: dummy reason
  52. INFO [alpha.dlm] MSG_OPENIN, unable to open message file example.msg for input: dummy reason
  53. DEBUG [alpha.example] MSG_RDLOCMES, reading local message file dummy/0
  54. DEBUG [alpha.example] MSG_RDLOCMES, reading local message file dummy/24
  55. DEBUG [alpha.example] MSG_RDLOCMES, reading local message file dummy/25
  56. .
  57. ./logger_example -c stdout -s debug -d 25 | cut -d' ' -f3- | diff $tempfile -
  58. passfail $?
  59. rm -f $tempfile
  60. if [ $failcount -eq 0 ]; then
  61. echo "PASS: $testname"
  62. elif [ $failcount -eq 1 ]; then
  63. echo "FAIL: $testname - 1 test failed"
  64. else
  65. echo "FAIL: $testname - $failcount tests failed"
  66. fi
  67. exit $failcount