runtests 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. #! /bin/sh
  2. # Run ZeroMQ tests, in order. This is extracted from the tests/Makefile
  3. # which won't run as-is because it relies on libtool building things, and
  4. # thus creating various libtool files, which don't work well on z/OS
  5. #
  6. # noinst_PROGRAMS needs to be kept in sync with tests/Makefile.am, as it
  7. # defines the order in which tests are run.
  8. #
  9. # Written by Ewen McNeill <ewen@imatix.com>, 2014-07-19
  10. # Updated by Ewen McNeill <ewen@imatix.com>, 2014-07-24
  11. #---------------------------------------------------------------------------
  12. set -e # Stop if a test fails
  13. #---------------------------------------------------------------------------
  14. # Change to tests directory if necessary
  15. # Figure out where we are
  16. BIN_DIR=$(dirname $0)
  17. if [ -z "${BIN_DIR}" ]; then BIN_DIR="."; fi
  18. case "${BIN_DIR}" in
  19. .) BIN_DIR="$(pwd)"; ;;
  20. /*) ;;
  21. *) BIN_DIR="$(pwd)/${BIN_DIR}"; ;;
  22. esac
  23. # Locate top of source tree, assuming we're in builds/zos
  24. TOP="${BIN_DIR}/../.."
  25. SRCDIR="${TOP}/src"
  26. TESTDIR="${TOP}/tests"
  27. case "$(pwd)" in
  28. *tests) ;;
  29. *) echo "Changing to ${TESTDIR}"
  30. cd "${TESTDIR}"
  31. ;;
  32. esac
  33. if [ -x "test_system" ]; then
  34. :
  35. else
  36. echo "Run makelibzmq and maketests before runtests" >&2
  37. exit 1
  38. fi
  39. #---------------------------------------------------------------------------
  40. # Explanation of tests expected to fail:
  41. # test_abstract_ipc: Relies on Linux-specific IPC functionality
  42. # test_fork: Relies on using pthreads _after_ fork, _before_ exec
  43. # test_diffserv: Needs IP_PROTO, IP_TOS setsockopt(); the headers
  44. # are present on z/OS UNIX System Services, but
  45. # fails with:
  46. # EDC8109I Protocol not available. (./ip.cpp:164)
  47. # NOTE: not listed as a valid IP setsockopt() option at:
  48. # http://pic.dhe.ibm.com/infocenter/zos/v2r1/index.jsp?topic=%2Fcom.ibm.zos.v2r1.bpxbd00%2Fsetopt.htm
  49. #
  50. XFAIL_TESTS="test_abstract_ipc|test_fork|test_diffserv"
  51. # BUILD_TIPC is not defined, so we skip all these tests
  52. SKIP_TESTS="test_.*_tipc"
  53. # Extract list of all test programs from tests/Makefile.am
  54. #
  55. # Excluding tests we know will fail because of missing functionality
  56. #
  57. noinst_PROGRAMS=$(grep "test_" Makefile.am | egrep -v "_SOURCES|XFAIL" |
  58. sed 's/noinst_PROGRAMS.* test/test/; s/^ *//; s/ *\\ *$//;' |
  59. grep -v "${SKIP_TESTS}" | egrep -v "${XFAIL_TESTS}")
  60. #echo "Found tetsts: ${noinst_PROGRAMS}"
  61. # Run tests on command line, or all tests we found
  62. if [ -n "${1}" ]; then
  63. TESTS="$*" # Run tests on command line
  64. else
  65. TESTS="${noinst_PROGRAMS}"
  66. fi
  67. verbose() {
  68. echo "Starting: $@" >&2
  69. "$@"
  70. }
  71. # Uncomment TESTS_ENVIRONMENT=verbose to see "Starting: TEST" messages
  72. #TESTS_ENVIRONMENT=verbose
  73. TESTS_ENVIRONMENT=
  74. #---------------------------------------------------------------------------
  75. # Explicitly add SRCDIR into library serach path, to make sure we
  76. # use our just-built version
  77. LIBPATH="${SRCDIR}:/lib:/usr/lib"
  78. export LIBPATH
  79. #---------------------------------------------------------------------------
  80. # check-TESTS: target from tests/Makefile, converted from Make syntax to
  81. # shell syntax
  82. failed=0; all=0; xfail=0; xpass=0; skip=0;
  83. srcdir=.; export srcdir;
  84. list="${TESTS}";
  85. red=""; grn=""; lgn=""; blu=""; std="";
  86. if test -n "$list"; then
  87. for tst in $list; do
  88. if test -f ./$tst; then dir=./;
  89. elif test -f $tst; then dir=;
  90. else dir="${srcdir}/"; fi;
  91. if ${TESTS_ENVIRONMENT} ${dir}$tst; then
  92. all=`expr $all + 1`;
  93. case " ${XFAIL_TESTS} " in
  94. *"$tst"*)
  95. xpass=`expr $xpass + 1`;
  96. failed=`expr $failed + 1`;
  97. col=$red; res=XPASS;
  98. ;;
  99. *)
  100. col=$grn; res=PASS;
  101. ;;
  102. esac;
  103. elif test $? -ne 77; then
  104. all=`expr $all + 1`;
  105. case " ${XFAIL_TESTS} " in
  106. *"$tst"*)
  107. xfail=`expr $xfail + 1`;
  108. col=$lgn; res=XFAIL;
  109. ;;
  110. *)
  111. failed=`expr $failed + 1`;
  112. col=$red; res=FAIL;
  113. ;;
  114. esac;
  115. else
  116. skip=`expr $skip + 1`;
  117. col=$blu; res=SKIP;
  118. fi;
  119. echo "${col}$res${std}: $tst";
  120. done;
  121. if test "$all" -eq 1; then
  122. tests="test";
  123. All="";
  124. else
  125. tests="tests";
  126. All="All ";
  127. fi;
  128. if test "$failed" -eq 0; then
  129. if test "$xfail" -eq 0; then
  130. banner="$All$all $tests passed";
  131. else
  132. if test "$xfail" -eq 1; then failures=failure; else failures=failures; fi;
  133. banner="$All$all $tests behaved as expected ($xfail expected $failures)";
  134. fi;
  135. else
  136. if test "$xpass" -eq 0; then
  137. banner="$failed of $all $tests failed";
  138. else
  139. if test "$xpass" -eq 1; then passes=pass; else passes=passes; fi;
  140. banner="$failed of $all $tests did not behave as expected ($xpass unexpected $passes)";
  141. fi;
  142. fi;
  143. dashes="$banner";
  144. skipped="";
  145. if test "$skip" -ne 0; then
  146. if test "$skip" -eq 1; then
  147. skipped="($skip test was not run)";
  148. else
  149. skipped="($skip tests were not run)";
  150. fi;
  151. test `echo "$skipped" | wc -c` -le `echo "$banner" | wc -c` ||
  152. dashes="$skipped"; \
  153. fi;
  154. report="";
  155. if test "$failed" -ne 0 && test -n "${PACKAGE_BUGREPORT}"; then
  156. report="Please report to ${PACKAGE_BUGREPORT}";
  157. test `echo "$report" | wc -c` -le `echo "$banner" | wc -c` ||
  158. dashes="$report";
  159. fi;
  160. dashes=`echo "$dashes" | sed s/./=/g`;
  161. if test "$failed" -eq 0; then
  162. col="$grn";
  163. else
  164. col="$red";
  165. fi;
  166. echo "${col}$dashes${std}";
  167. echo "${col}$banner${std}";
  168. test -z "$skipped" || echo "${col}$skipped${std}";
  169. test -z "$report" || echo "${col}$report${std}";
  170. echo "${col}$dashes${std}";
  171. test "$failed" -eq 0;
  172. else :; fi