run.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. #
  18. # Run a system test.
  19. #
  20. SYSTEMTESTTOP=.
  21. . $SYSTEMTESTTOP/conf.sh
  22. stopservers=true
  23. case $1 in
  24. --keep) stopservers=false; shift ;;
  25. esac
  26. test $# -gt 0 || { echo "usage: $0 [--keep] test-directory" >&2; exit 1; }
  27. test=$1
  28. shift
  29. test -d $test || { echo "$0: $test: no such test" >&2; exit 1; }
  30. echo "S:$test:`date`" >&2
  31. echo "T:$test:1:A" >&2
  32. echo "A:System test $test" >&2
  33. if [ x$PERL = x ]
  34. then
  35. echo "I:Perl not available. Skipping test." >&2
  36. echo "R:UNTESTED" >&2
  37. echo "E:$test:`date`" >&2
  38. exit 0;
  39. fi
  40. $PERL $TESTSOCK || {
  41. echo "I:Network interface aliases not set up. Skipping test." >&2;
  42. echo "R:UNTESTED" >&2;
  43. echo "E:$test:`date`" >&2;
  44. exit 0;
  45. }
  46. # Check for test-specific prerequisites.
  47. test ! -f $test/prereq.sh || ( cd $test && sh prereq.sh "$@" )
  48. result=$?
  49. if [ $result -eq 0 ]; then
  50. : prereqs ok
  51. else
  52. echo "I:Prerequisites for $test missing, skipping test." >&2
  53. [ $result -eq 255 ] && echo "R:SKIPPED" || echo "R:UNTESTED"
  54. echo "E:$test:`date`" >&2
  55. exit 0
  56. fi
  57. # Check for PKCS#11 support
  58. if
  59. test ! -f $test/usepkcs11 || sh cleanpkcs11.sh
  60. then
  61. : pkcs11 ok
  62. else
  63. echo "I:Need PKCS#11 for $test, skipping test." >&2
  64. echo "R:PKCS11ONLY" >&2
  65. echo "E:$test:`date`" >&2
  66. exit 0
  67. fi
  68. # Set up any dynamically generated test data
  69. if test -f $test/setup.sh
  70. then
  71. ( cd $test && sh setup.sh "$@" )
  72. fi
  73. # Start name servers running
  74. $PERL start.pl $test || exit 1
  75. # Run the tests
  76. ( cd $test ; sh tests.sh )
  77. status=$?
  78. if $stopservers
  79. then
  80. :
  81. else
  82. exit $status
  83. fi
  84. # Shutdown
  85. $PERL stop.pl $test
  86. status=`expr $status + $?`
  87. if [ $status != 0 ]; then
  88. echo "R:FAIL"
  89. # Don't clean up - we need the evidence.
  90. find . -name core -exec chmod 0644 '{}' \;
  91. else
  92. echo "R:PASS"
  93. # Clean up.
  94. if test -f $test/clean.sh
  95. then
  96. ( cd $test && sh clean.sh "$@" )
  97. fi
  98. fi
  99. echo "E:$test:`date`"
  100. exit $status