buffer_logger_test.sh.in 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. # Checks that the initLogger() call uses for unit tests respects the setting of
  16. # the buffer value
  17. #
  18. testname="bufferLogger test"
  19. echo $testname
  20. failcount=0
  21. tempfile=@abs_builddir@/buffer_logger_test_tempfile_$$
  22. passfail() {
  23. if [ $1 -eq 0 ]; then
  24. echo " pass"
  25. else
  26. echo " FAIL"
  27. failcount=`expr $failcount + $1`
  28. fi
  29. }
  30. echo "1. Checking that buffer initialization works"
  31. echo -n " - Buffer including process() call: "
  32. cat > $tempfile << .
  33. INFO [buffertest.log] LOG_BAD_SEVERITY unrecognized log severity: info
  34. INFO [buffertest.log] LOG_BAD_SEVERITY unrecognized log severity: info
  35. .
  36. ./buffer_logger_test 2>&1 | \
  37. sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\]/[\1]/' | \
  38. cut -d' ' -f3- | diff $tempfile -
  39. passfail $?
  40. echo -n " - Buffer excluding process() call: "
  41. cat > $tempfile << .
  42. LOG_BAD_SEVERITY unrecognized log severity: info
  43. LOG_BAD_DESTINATION unrecognized log destination: debug-50
  44. LOG_BAD_SEVERITY unrecognized log severity: info
  45. .
  46. ./buffer_logger_test -n 2>&1 | diff $tempfile -
  47. passfail $?
  48. # Tidy up.
  49. rm -f $tempfile
  50. exit $failcount