run-testsuite.sh 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. #!/usr/bin/env bash
  2. # Script to do testing.
  3. # Invocation
  4. # run-testsuite SRC_DIR BUILD_DIR
  5. # Pass in build/src directory as parameters.
  6. SRC_DIR=$1
  7. BUILD_DIR=$2
  8. # Now that we've successfully translated the numerical option into
  9. # a symbolic one, we can safely ignore it.
  10. shift
  11. # Use build compiler/library flags from libstdc++
  12. flags_script=$BUILD_DIR/../libstdc++-v3/scripts/testsuite_flags
  13. INCLUDES=`$flags_script --build-includes`
  14. COMPILER=`$flags_script --build-cxx`
  15. CXX="$COMPILER $INCLUDES -L$BUILD_DIR/.libs -Wl,--rpath -Wl,$BUILD_DIR/.libs"
  16. echo "compiler config is:"
  17. echo $CXX
  18. echo ""
  19. # Other constants.
  20. LOPT_LEVELS=${OPT_LEVELS:-"-O0 -O2"}
  21. #LDATA_MODELS=${DATA_MODELS:-"32 64"}
  22. LDATA_MODELS=${DATA_MODELS:-"64"}
  23. # Check if value of LGCC_LIB_PATH/$1 exists. If it does, save this path.
  24. # If it doesn't, use LGCC_LIB_PATH as the library path.
  25. # This allows us to check for paths that are of the form <x>/lib32 or <x>/lib64.
  26. get_lib_path()
  27. {
  28. if [[ -e $LGCC_LIB_PATH$1 ]]; then
  29. LLGCC_LIB_PATH=$LGCC_LIB_PATH$1
  30. else
  31. LLGCC_LIB_PATH=$LGCC_LIB_PATH
  32. fi
  33. return
  34. }
  35. LGCC_SRC=$SRC_DIR/testsuite
  36. TESTS="const_vtable.cc dataentry.cc dup_name.cc environment.cc template-list.cc template-list2.cc template-list-iostream.cc povray-derived.cc thunk.cc thunk_vtable_map_attack.cc virtual_inheritance.cc "
  37. for M in $LDATA_MODELS; do
  38. get_lib_path lib${M}
  39. for T in $TESTS; do
  40. TSRC=${LGCC_SRC}/${T}
  41. for OL in $LOPT_LEVELS; do
  42. CMD="${CXX} -m${M} -fvtable-verify=std -fpic -rdynamic -Wl,-z,relro ${TSRC} ${OL}"
  43. echo $CMD
  44. ($CMD && ( ./a.out > $T.$OL.out 2>&1 ) && echo "PASS $T $OL") || echo "FAIL $T $OL"
  45. done
  46. done
  47. done
  48. TESTS_COMPOUND_parts="${LGCC_SRC}/parts-test-main.cc ${LGCC_SRC}/parts-test-extra-parts.cc ${LGCC_SRC}/parts-test-extra-parts-views.cc"
  49. TESTS_COMPOUND_events="${LGCC_SRC}/event-main.cc ${LGCC_SRC}/event-definitions.cc ${LGCC_SRC}/event-private.cc"
  50. for M in $LDATA_MODELS; do
  51. get_lib_path lib${M}
  52. for OL in $LOPT_LEVELS; do
  53. CMD="${CXX} -m${M} -fvtable-verify=std -fpic -rdynamic -Wl,-z,relro ${TESTS_COMPOUND_parts} ${OL}"
  54. echo $CMD
  55. ($CMD && ( ./a.out > $T.$OL.out 2>&1 ) && echo "PASS $T $OL") || echo "FAIL $T $OL"
  56. done
  57. done
  58. for M in $LDATA_MODELS; do
  59. for (( TN = 0 ; TN < 100 ; TN++ )); do
  60. SO_NAME=so$TN.so
  61. if [ -f ./lib${M}/$SO_NAME ]; then
  62. /bin/rm ./lib${M}/$SO_NAME
  63. fi
  64. CMD="${CXX} -m${M} -fvtable-verify=std -O0 -g -shared -fpic -rdynamic -Wl,-z,relro -DTPID=$TN -I${SRC_DIR} ${LGCC_SRC}/so.cc -o ./lib${M}/$SO_NAME"
  65. echo ${CMD}
  66. ${CMD} || exit 8
  67. done
  68. done
  69. DLOPEN_TESTS="dlopen.cc dlopen_mt.cc"
  70. for M in $LDATA_MODELS; do
  71. get_lib_path lib${M}
  72. for T in $DLOPEN_TESTS; do
  73. TSRC=${LGCC_SRC}/${T}
  74. for OL in $LOPT_LEVELS; do
  75. CMD="${CXX} -m${M} -fvtable-verify=std -fpic -rdynamic -Wl,-z,relro -Wl,-R,./lib${M} -I${SRC_DIR} ${TSRC} ${OL} -ldl -lpthread"
  76. echo $CMD
  77. ($CMD && ( ./a.out > $T.$OL.out 2>&1 ) && echo "PASS $T $OL") || echo "FAIL $T $OL"
  78. done
  79. done
  80. done
  81. for M in $LDATA_MODELS; do
  82. get_lib_path lib${M}
  83. for T in $TESTS; do
  84. TSRC=${LGCC_SRC}/${T}
  85. for OL in $LOPT_LEVELS; do
  86. CMD="${CXX} -m${M} -fvtable-verify=preinit -fpic -rdynamic -Wl,-z,relro ${TSRC} ${OL}"
  87. echo $CMD
  88. ($CMD && ( ./a.out > $T.$OL.out 2>&1 ) && echo "PASS $T $OL") || echo "FAIL $T $OL"
  89. done
  90. done
  91. done
  92. for M in $LDATA_MODELS; do
  93. if [ -f ./lib${M}/vtv_malloc.o ]; then
  94. /bin/rm ./lib${M}/vtv_malloc.o;
  95. fi
  96. CMD="${CXX} -m${M} -O2 -g -c -fpic ${SRC_DIR}/vtv_malloc.cc -o ./lib${M}/vtv_malloc.o"
  97. echo ${CMD}
  98. ${CMD} || exit 3
  99. if [ -f ./lib${M}/vtv_utils.o ]; then
  100. /bin/rm ./lib${M}/vtv_utils.o;
  101. fi
  102. CMD="${CXX} -m${M} -O2 -g -c -fpic ${SRC_DIR}/vtv_utils.cc -o ./lib${M}/vtv_utils.o"
  103. echo ${CMD}
  104. ${CMD} || exit 4
  105. done
  106. MEMPOOL_TESTS="mempool_positive.c mempool_negative.c"
  107. for M in $LDATA_MODELS; do
  108. get_lib_path lib${M}
  109. for T in $MEMPOOL_TESTS; do
  110. TSRC=${LGCC_SRC}/${T}
  111. for OL in $LOPT_LEVELS; do
  112. CMD="${CXX} -m${M} -fpic -rdynamic -I${SRC_DIR} ${TSRC} ${OL} ./lib${M}/vtv_malloc.o ./lib${M}/vtv_utils.o"
  113. echo $CMD
  114. ($CMD && ( ./a.out > $T.$OL.out 2>&1 ) && echo "PASS $T $OL") || echo "FAIL $T $OL"
  115. done
  116. done
  117. done
  118. # bkoz not working ATM signature mismatch
  119. #MT_TESTS="register_pair_mt.cc register_pair_inserts_mt.cc"
  120. MT_TESTS=
  121. for M in $LDATA_MODELS; do
  122. get_lib_path lib${M}
  123. for T in $MT_TESTS; do
  124. TSRC=${LGCC_SRC}/${T}
  125. for OL in $LOPT_LEVELS; do
  126. CMD="${CXX} -m${M} -fpic -rdynamic -I${SRC_DIR} ${TSRC} ${OL} -lpthread"
  127. echo $CMD
  128. ($CMD && ( ./a.out > $T.$OL.out 2>&1 ) && echo "PASS $T $OL") || echo "FAIL $T $OL"
  129. done
  130. done
  131. done
  132. # These test cases were written for performance measurements, not for
  133. # correctness but lets run them here so that we dont loose track of
  134. # them
  135. # bkoz not working ATM signature mismatch
  136. #PERF_TESTS="register_pair.cc register_pair_inserts.cc"
  137. PERF_TESTS=
  138. for M in $LDATA_MODELS; do
  139. get_lib_path lib${M}
  140. for T in $PERF_TESTS; do
  141. TSRC=${LGCC_SRC}/${T}
  142. for OL in $LOPT_LEVELS; do
  143. CMD="${CXX} -m${M} -fpic -rdynamic -I${SRC_DIR} ${TSRC} ${OL} "
  144. echo $CMD
  145. ($CMD && ( ./a.out > $T.$OL.out 2>&1 ) && echo "PASS $T $OL") || echo "FAIL $T $OL"
  146. done
  147. done
  148. done
  149. PASS_FAIL_TESTS="field-test.cc temp_deriv.cc temp_deriv2.cc temp_deriv3.cc"
  150. for M in $LDATA_MODELS; do
  151. get_lib_path lib${M}
  152. for T in $PASS_FAIL_TESTS; do
  153. TSRC=${LGCC_SRC}/${T}
  154. for OL in $LOPT_LEVELS; do
  155. CMD="${CXX} -m${M} -fvtable-verify=std -fpic -rdynamic ${TSRC} ${OL} -Wl,-z,relro -DTPID"
  156. echo $CMD
  157. ($CMD && ( ./a.out > $T.$OL.out 2>&1 )) || (( grep "Pass first attack" $T.$OL.out ) && echo "PASS $T $OL - correctly passed then failed.") || echo "FAIL $T $OL"
  158. done
  159. done
  160. done
  161. for M in $LDATA_MODELS; do
  162. get_lib_path lib${M}
  163. for T in $PERF_TESTS; do
  164. TSRC=${LGCC_SRC}/${T}
  165. for OL in $LOPT_LEVELS; do
  166. CMD="${CXX} -m${M} -fpic -rdynamic -I${SRC_DIR} ${TSRC} ${OL} "
  167. echo $CMD
  168. ($CMD && ( ./a.out > $T.$OL.out 2>&1 ) && echo "PASS $T $OL") || echo "FAIL $T $OL"
  169. done
  170. done
  171. done
  172. for M in $LDATA_MODELS; do
  173. get_lib_path lib${M}
  174. for OL in $LOPT_LEVELS; do
  175. CMD="as --${M} -o environment-fail-${M}.o ${LGCC_SRC}/environment-fail-${M}.s"
  176. echo $CMD
  177. ${CMD} || exit 5
  178. CMD="${CXX} -m${M} environment-fail-${M}.o -O0 -Wl,-z,relro -o environment-fail-${M}"
  179. echo ${CMD}
  180. # ${CMD} || exit 6
  181. # (./environment-fail-${M}) || echo "PASS environment-fail-${M} (correctly failed), ${OL}"
  182. CMD="${CXX} -fvtable-verify=std -m${M} environment-fail-${M}.o -O0 -Wl,-z,relro -o environment-fail-${M}"
  183. echo ${CMD}
  184. ($CMD && ( ./environment-fail-${M} > environment-fail-${M}-stubs.out 2>&1 ) && echo "PASS environment-fail-${M} with libvtv_stubs ${OL}" ) || echo "FAIL environment-fail-${M} with libvtv_stubs ${OL}"
  185. CMD="${CXX} -m${M} ${LGCC_SRC}/replace-fail.cc -O0 -c -o replace-fail-${M}.o"
  186. echo ${CMD}
  187. ${CMD} || exit 7
  188. CMD="${CXX} -fvtable-verify=std -m${M} environment-fail-${M}.o replace-fail-${M}.o -O0 -Wl,-z,relro -o environment-fail-${M}"
  189. echo ${CMD}
  190. ($CMD && ( ./environment-fail-${M} > environment-fail-${M}-stubs.out 2>&1 ) && echo "PASS environment-fail-${M} with replace-fail ${OL}" ) || echo "FAIL environment-fail-${M} with replace-fail ${OL}"
  191. done
  192. done