console_test.sh.in 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. # The logger supports the idea of a "console" logger than logs to either stdout
  16. # or stderr. This test checks that both these options work.
  17. export B10_FROM_SOURCE=@abs_top_srcdir@
  18. testname="Console output test"
  19. echo $testname
  20. failcount=0
  21. tempfile=@abs_builddir@/console_test_tempfile_$$
  22. # Look at tempfile and check that the count equals the expected count
  23. passfail() {
  24. count=`wc -l $tempfile | awk '{print $1}'`
  25. if [ $count -eq $1 ]; then
  26. echo " pass"
  27. else
  28. echo " FAIL"
  29. failcount=`expr $failcount + $1`
  30. fi
  31. }
  32. echo -n "1. Checking that console output to stdout goes to stdout:"
  33. rm -f $tempfile
  34. ./logger_example -c stdout -s error 1> $tempfile 2> /dev/null
  35. passfail 4
  36. echo -n "2. Checking that console output to stdout does not go to stderr:"
  37. rm -f $tempfile
  38. ./logger_example -c stdout -s error 1> /dev/null 2> $tempfile
  39. passfail 0
  40. echo -n "3. Checking that console output to stderr goes to stderr:"
  41. rm -f $tempfile
  42. ./logger_example -c stderr -s error 1> /dev/null 2> $tempfile
  43. passfail 4
  44. echo -n "4. Checking that console output to stderr does not go to stdout:"
  45. rm -f $tempfile
  46. ./logger_example -c stderr -s error 1> $tempfile 2> /dev/null
  47. passfail 0
  48. if [ $failcount -eq 0 ]; then
  49. echo "PASS: $testname"
  50. elif [ $failcount -eq 1 ]; then
  51. echo "FAIL: $testname - 1 test failed"
  52. else
  53. echo "FAIL: $testname - $failcount tests failed"
  54. fi
  55. # Tidy up
  56. rm -f $tempfile
  57. exit $failcount