logger_lock_test.sh.in 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/sh
  2. # Copyright (C) 2012 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 locker interprocess sync locks are acquired and
  16. # released correctly.
  17. failcount=0
  18. tempfile=@abs_builddir@/logger_lock_test_tempfile_$$
  19. destfile=@abs_builddir@/logger_lock_test_destfile_$$
  20. passfail() {
  21. if [ $1 -eq 0 ]; then
  22. echo " pass"
  23. else
  24. echo " FAIL"
  25. failcount=`expr $failcount + $1`
  26. fi
  27. }
  28. echo -n "Testing that logger acquires and releases locks correctly:"
  29. cat > $tempfile << .
  30. LOGGER_LOCK_TEST: LOCK
  31. INFO [bind10.log] LOG_LOCK_TEST_MESSAGE this is a test message.
  32. LOGGER_LOCK_TEST: UNLOCK
  33. .
  34. rm -f $destfile
  35. B10_LOGGER_SEVERITY=INFO B10_LOGGER_DESTINATION=stdout ./logger_lock_test > $destfile
  36. cut -d' ' -f3- $destfile | diff $tempfile -
  37. passfail $?
  38. # Tidy up.
  39. rm -f $tempfile $destfile
  40. exit $failcount