run.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #!/bin/sh
  2. #
  3. # Copyright (C) 2004, 2007, 2010 Internet Systems Consortium, Inc. ("ISC")
  4. # Copyright (C) 2000, 2001 Internet Software Consortium.
  5. #
  6. # Permission to use, copy, modify, and/or distribute this software for any
  7. # purpose with or without fee is hereby granted, provided that the above
  8. # copyright notice and this permission notice appear in all copies.
  9. #
  10. # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  11. # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  12. # AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  13. # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  14. # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  15. # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. # PERFORMANCE OF THIS SOFTWARE.
  17. # $Id: run.sh,v 1.45 2010-12-20 21:35:45 each Exp $
  18. #
  19. # Run a system test.
  20. #
  21. SYSTEMTESTTOP=.
  22. . $SYSTEMTESTTOP/conf.sh
  23. stopservers=true
  24. case $1 in
  25. --keep) stopservers=false; shift ;;
  26. esac
  27. test $# -gt 0 || { echo "usage: $0 [--keep] test-directory" >&2; exit 1; }
  28. test=$1
  29. shift
  30. test -d $test || { echo "$0: $test: no such test" >&2; exit 1; }
  31. echo "S:$test:`date`" >&2
  32. echo "T:$test:1:A" >&2
  33. echo "A:System test $test" >&2
  34. if [ x$PERL = x ]
  35. then
  36. echo "I:Perl not available. Skipping test." >&2
  37. echo "R:UNTESTED" >&2
  38. echo "E:$test:`date`" >&2
  39. exit 0;
  40. fi
  41. $PERL testsock.pl || {
  42. echo "I:Network interface aliases not set up. Skipping test." >&2;
  43. echo "R:UNTESTED" >&2;
  44. echo "E:$test:`date`" >&2;
  45. exit 0;
  46. }
  47. # Check for test-specific prerequisites.
  48. test ! -f $test/prereq.sh || ( cd $test && sh prereq.sh "$@" )
  49. result=$?
  50. if [ $result -eq 0 ]; then
  51. : prereqs ok
  52. else
  53. echo "I:Prerequisites for $test missing, skipping test." >&2
  54. [ $result -eq 255 ] && echo "R:SKIPPED" || echo "R:UNTESTED"
  55. echo "E:$test:`date`" >&2
  56. exit 0
  57. fi
  58. # Check for PKCS#11 support
  59. if
  60. test ! -f $test/usepkcs11 || sh cleanpkcs11.sh
  61. then
  62. : pkcs11 ok
  63. else
  64. echo "I:Need PKCS#11 for $test, skipping test." >&2
  65. echo "R:PKCS11ONLY" >&2
  66. echo "E:$test:`date`" >&2
  67. exit 0
  68. fi
  69. # Set up any dynamically generated test data
  70. if test -f $test/setup.sh
  71. then
  72. ( cd $test && sh setup.sh "$@" )
  73. fi
  74. # Start name servers running
  75. $PERL start.pl $test || exit 1
  76. # Run the tests
  77. ( cd $test ; sh tests.sh )
  78. status=$?
  79. if $stopservers
  80. then
  81. :
  82. else
  83. exit $status
  84. fi
  85. # Shutdown
  86. $PERL stop.pl $test
  87. status=`expr $status + $?`
  88. if [ $status != 0 ]; then
  89. echo "R:FAIL"
  90. # Don't clean up - we need the evidence.
  91. find . -name core -exec chmod 0644 '{}' \;
  92. else
  93. echo "R:PASS"
  94. # Clean up.
  95. if test -f $test/clean.sh
  96. then
  97. ( cd $test && sh clean.sh "$@" )
  98. fi
  99. fi
  100. echo "E:$test:`date`"
  101. exit $status