[C++ PATCH] hash-table for extern-c fns.
[official-gcc.git] / libvtv / scripts / run-testsuite.sh
bloba02ce1562e63b717f96f783a63e3b9ffd42876a7
1 #!/usr/bin/env bash
3 # Script to do testing.
5 # Invocation
6 # run-testsuite SRC_DIR BUILD_DIR
8 # Pass in build/src directory as parameters.
9 SRC_DIR=$1
10 BUILD_DIR=$2
12 # Now that we've successfully translated the numerical option into
13 # a symbolic one, we can safely ignore it.
14 shift
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:"
23 echo $CXX
24 echo ""
26 # Other constants.
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.
34 get_lib_path()
36 if [[ -e $LGCC_LIB_PATH$1 ]]; then
37 LLGCC_LIB_PATH=$LGCC_LIB_PATH$1
38 else
39 LLGCC_LIB_PATH=$LGCC_LIB_PATH
41 return
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
49 get_lib_path lib${M}
50 for T in $TESTS; do
51 TSRC=${LGCC_SRC}/${T}
52 for OL in $LOPT_LEVELS; do
53 CMD="${CXX} -m${M} -fvtable-verify=std -fpic -rdynamic -Wl,-z,relro ${TSRC} ${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 done
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
64 get_lib_path lib${M}
65 for OL in $LOPT_LEVELS; do
66 CMD="${CXX} -m${M} -fvtable-verify=std -fpic -rdynamic -Wl,-z,relro ${TESTS_COMPOUND_parts} ${OL}"
67 echo $CMD
68 ($CMD && ( ./a.out > $T.$OL.out 2>&1 ) && echo "PASS $T $OL") || echo "FAIL $T $OL"
69 done
70 done
72 for M in $LDATA_MODELS; do
73 for (( TN = 0 ; TN < 100 ; TN++ )); do
74 SO_NAME=so$TN.so
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"
79 echo ${CMD}
80 ${CMD} || exit 8
81 done
82 done
84 DLOPEN_TESTS="dlopen.cc dlopen_mt.cc"
86 for M in $LDATA_MODELS; do
87 get_lib_path lib${M}
88 for T in $DLOPEN_TESTS; do
89 TSRC=${LGCC_SRC}/${T}
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"
92 echo $CMD
93 ($CMD && ( ./a.out > $T.$OL.out 2>&1 ) && echo "PASS $T $OL") || echo "FAIL $T $OL"
94 done
95 done
96 done
98 for M in $LDATA_MODELS; do
99 get_lib_path lib${M}
100 for T in $TESTS; 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}"
104 echo $CMD
105 ($CMD && ( ./a.out > $T.$OL.out 2>&1 ) && echo "PASS $T $OL") || echo "FAIL $T $OL"
106 done
107 done
108 done
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"
115 echo ${CMD}
116 ${CMD} || exit 3
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"
122 echo ${CMD}
123 ${CMD} || exit 4
124 done
126 MEMPOOL_TESTS="mempool_positive.c mempool_negative.c"
128 for M in $LDATA_MODELS; do
129 get_lib_path lib${M}
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"
134 echo $CMD
135 ($CMD && ( ./a.out > $T.$OL.out 2>&1 ) && echo "PASS $T $OL") || echo "FAIL $T $OL"
136 done
137 done
138 done
140 # bkoz not working ATM signature mismatch
141 #MT_TESTS="register_pair_mt.cc register_pair_inserts_mt.cc"
142 MT_TESTS=
143 for M in $LDATA_MODELS; do
144 get_lib_path lib${M}
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"
149 echo $CMD
150 ($CMD && ( ./a.out > $T.$OL.out 2>&1 ) && echo "PASS $T $OL") || echo "FAIL $T $OL"
151 done
152 done
153 done
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
157 # them
158 # bkoz not working ATM signature mismatch
159 #PERF_TESTS="register_pair.cc register_pair_inserts.cc"
160 PERF_TESTS=
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
174 PASS_FAIL_TESTS="field-test.cc temp_deriv.cc temp_deriv2.cc temp_deriv3.cc"
176 for M in $LDATA_MODELS; do
177 get_lib_path lib${M}
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"
182 echo $CMD
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"
184 done
185 done
186 done
188 for M in $LDATA_MODELS; do
189 get_lib_path lib${M}
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} "
194 echo $CMD
195 ($CMD && ( ./a.out > $T.$OL.out 2>&1 ) && echo "PASS $T $OL") || echo "FAIL $T $OL"
196 done
197 done
198 done
200 for M in $LDATA_MODELS; do
201 get_lib_path lib${M}
202 for OL in $LOPT_LEVELS; do
204 CMD="as --${M} -o environment-fail-${M}.o ${LGCC_SRC}/environment-fail-${M}.s"
205 echo $CMD
206 ${CMD} || exit 5
208 CMD="${CXX} -m${M} environment-fail-${M}.o -O0 -Wl,-z,relro -o environment-fail-${M}"
209 echo ${CMD}
210 # ${CMD} || exit 6
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}"
214 echo ${CMD}
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"
218 echo ${CMD}
219 ${CMD} || exit 7
221 CMD="${CXX} -fvtable-verify=std -m${M} environment-fail-${M}.o replace-fail-${M}.o -O0 -Wl,-z,relro -o environment-fail-${M}"
222 echo ${CMD}
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}"
224 done
225 done