3 # Script to do testing.
6 # run-testsuite SRC_DIR BUILD_DIR
8 # Pass in build/src directory as parameters.
12 # Now that we've successfully translated the numerical option into
13 # a symbolic one, we can safely ignore it.
16 # Use build compiler/library flags from libstdc++
17 flags_script
=$BUILD_DIR/..
/libstdc
++-v3/scripts
/testsuite_flags
18 INCLUDES
=`$flags_script --build-includes`
19 COMPILER
=`$flags_script --build-cxx`
20 CXX
="$COMPILER $INCLUDES -L$BUILD_DIR/.libs -Wl,--rpath -Wl,$BUILD_DIR/.libs"
22 echo "compiler config is:"
27 LOPT_LEVELS
=${OPT_LEVELS:-"-O0 -O2"}
28 #LDATA_MODELS=${DATA_MODELS:-"32 64"}
29 LDATA_MODELS
=${DATA_MODELS:-"64"}
31 # Check if value of LGCC_LIB_PATH/$1 exists. If it does, save this path.
32 # If it doesn't, use LGCC_LIB_PATH as the library path.
33 # This allows us to check for paths that are of the form <x>/lib32 or <x>/lib64.
36 if [[ -e $LGCC_LIB_PATH$1 ]]; then
37 LLGCC_LIB_PATH
=$LGCC_LIB_PATH$1
39 LLGCC_LIB_PATH
=$LGCC_LIB_PATH
44 LGCC_SRC
=$SRC_DIR/testsuite
46 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 "
48 for M
in $LDATA_MODELS; do
52 for OL
in $LOPT_LEVELS; do
53 CMD
="${CXX} -m${M} -fvtable-verify=std -fpic -rdynamic -Wl,-z,relro ${TSRC} ${OL}"
55 ($CMD && ( .
/a.out
> $T.
$OL.out
2>&1 ) && echo "PASS $T $OL") ||
echo "FAIL $T $OL"
60 TESTS_COMPOUND_parts
="${LGCC_SRC}/parts-test-main.cc ${LGCC_SRC}/parts-test-extra-parts.cc ${LGCC_SRC}/parts-test-extra-parts-views.cc"
61 TESTS_COMPOUND_events
="${LGCC_SRC}/event-main.cc ${LGCC_SRC}/event-definitions.cc ${LGCC_SRC}/event-private.cc"
63 for M
in $LDATA_MODELS; do
65 for OL
in $LOPT_LEVELS; do
66 CMD
="${CXX} -m${M} -fvtable-verify=std -fpic -rdynamic -Wl,-z,relro ${TESTS_COMPOUND_parts} ${OL}"
68 ($CMD && ( .
/a.out
> $T.
$OL.out
2>&1 ) && echo "PASS $T $OL") ||
echo "FAIL $T $OL"
72 for M
in $LDATA_MODELS; do
73 for (( TN
= 0 ; TN
< 100 ; TN
++ )); do
75 if [ -f .
/lib
${M}/$SO_NAME ]; then
76 /bin
/rm .
/lib
${M}/$SO_NAME
78 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"
84 DLOPEN_TESTS
="dlopen.cc dlopen_mt.cc"
86 for M
in $LDATA_MODELS; do
88 for T
in $DLOPEN_TESTS; do
90 for OL
in $LOPT_LEVELS; do
91 CMD
="${CXX} -m${M} -fvtable-verify=std -fpic -rdynamic -Wl,-z,relro -Wl,-R,./lib${M} -I${SRC_DIR} ${TSRC} ${OL} -ldl -lpthread"
93 ($CMD && ( .
/a.out
> $T.
$OL.out
2>&1 ) && echo "PASS $T $OL") ||
echo "FAIL $T $OL"
98 for M
in $LDATA_MODELS; do
101 TSRC
=${LGCC_SRC}/${T}
102 for OL
in $LOPT_LEVELS; do
103 CMD
="${CXX} -m${M} -fvtable-verify=preinit -fpic -rdynamic -Wl,-z,relro ${TSRC} ${OL}"
105 ($CMD && ( .
/a.out
> $T.
$OL.out
2>&1 ) && echo "PASS $T $OL") ||
echo "FAIL $T $OL"
110 for M
in $LDATA_MODELS; do
111 if [ -f .
/lib
${M}/vtv_malloc.o
]; then
112 /bin
/rm .
/lib
${M}/vtv_malloc.o
;
114 CMD
="${CXX} -m${M} -O2 -g -c -fpic ${SRC_DIR}/vtv_malloc.cc -o ./lib${M}/vtv_malloc.o"
118 if [ -f .
/lib
${M}/vtv_utils.o
]; then
119 /bin
/rm .
/lib
${M}/vtv_utils.o
;
121 CMD
="${CXX} -m${M} -O2 -g -c -fpic ${SRC_DIR}/vtv_utils.cc -o ./lib${M}/vtv_utils.o"
126 MEMPOOL_TESTS
="mempool_positive.c mempool_negative.c"
128 for M
in $LDATA_MODELS; do
130 for T
in $MEMPOOL_TESTS; do
131 TSRC
=${LGCC_SRC}/${T}
132 for OL
in $LOPT_LEVELS; do
133 CMD
="${CXX} -m${M} -fpic -rdynamic -I${SRC_DIR} ${TSRC} ${OL} ./lib${M}/vtv_malloc.o ./lib${M}/vtv_utils.o"
135 ($CMD && ( .
/a.out
> $T.
$OL.out
2>&1 ) && echo "PASS $T $OL") ||
echo "FAIL $T $OL"
140 # bkoz not working ATM signature mismatch
141 #MT_TESTS="register_pair_mt.cc register_pair_inserts_mt.cc"
143 for M
in $LDATA_MODELS; do
145 for T
in $MT_TESTS; do
146 TSRC
=${LGCC_SRC}/${T}
147 for OL
in $LOPT_LEVELS; do
148 CMD
="${CXX} -m${M} -fpic -rdynamic -I${SRC_DIR} ${TSRC} ${OL} -lpthread"
150 ($CMD && ( .
/a.out
> $T.
$OL.out
2>&1 ) && echo "PASS $T $OL") ||
echo "FAIL $T $OL"
155 # These test cases were written for performance measurements, not for
156 # correctness but lets run them here so that we dont loose track of
158 # bkoz not working ATM signature mismatch
159 #PERF_TESTS="register_pair.cc register_pair_inserts.cc"
161 for M
in $LDATA_MODELS; do
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} "
168 ($CMD && ( .
/a.out
> $T.
$OL.out
2>&1 ) && echo "PASS $T $OL") ||
echo "FAIL $T $OL"
174 PASS_FAIL_TESTS
="field-test.cc temp_deriv.cc temp_deriv2.cc temp_deriv3.cc"
176 for M
in $LDATA_MODELS; do
178 for T
in $PASS_FAIL_TESTS; do
179 TSRC
=${LGCC_SRC}/${T}
180 for OL
in $LOPT_LEVELS; do
181 CMD
="${CXX} -m${M} -fvtable-verify=std -fpic -rdynamic ${TSRC} ${OL} -Wl,-z,relro -DTPID"
183 ($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"
188 for M
in $LDATA_MODELS; do
190 for T
in $PERF_TESTS; do
191 TSRC
=${LGCC_SRC}/${T}
192 for OL
in $LOPT_LEVELS; do
193 CMD
="${CXX} -m${M} -fpic -rdynamic -I${SRC_DIR} ${TSRC} ${OL} "
195 ($CMD && ( .
/a.out
> $T.
$OL.out
2>&1 ) && echo "PASS $T $OL") ||
echo "FAIL $T $OL"
200 for M
in $LDATA_MODELS; do
202 for OL
in $LOPT_LEVELS; do
204 CMD
="as --${M} -o environment-fail-${M}.o ${LGCC_SRC}/environment-fail-${M}.s"
208 CMD
="${CXX} -m${M} environment-fail-${M}.o -O0 -Wl,-z,relro -o environment-fail-${M}"
211 # (./environment-fail-${M}) || echo "PASS environment-fail-${M} (correctly failed), ${OL}"
213 CMD
="${CXX} -fvtable-verify=std -m${M} environment-fail-${M}.o -O0 -Wl,-z,relro -o environment-fail-${M}"
215 ($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}"
217 CMD="${CXX} -m${M} ${LGCC_SRC}/replace-fail.cc -O0 -c -o replace-fail-${M}.o
"
221 CMD="${CXX} -fvtable-verify=std -m${M} environment-fail-${M}.o replace-fail-${M}.o -O0 -Wl,-z,relro -o environment-fail-${M}"
223 ($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}"