3 # cryptest.sh - written and placed in public domain by Jeffrey Walton and Uri Blumenthal.
4 # Copyright assigned to Crypto++ project.
6 # This is a test script that can be used on some Linux/Unix/Apple machines
7 # to automate building the library and running the self test with various
8 # combinations of flags, options, and conditions.
10 # Everything is tee'd into cryptest-result.txt. Change it to suite your taste. You
11 # should be able to use `egrep -a "(Error|error|FAILED|Illegal)" cryptest-result.txt`
12 # to quickly find errors and failures.
14 # Set to suite your taste
15 TEST_RESULTS=cryptest-result.txt
16 BENCHMARK_RESULTS=cryptest-bench.txt
17 WARN_TEST_RESULTS=cryptest-warn-result.txt
19 # Respect user's preferred flags, but filter the stuff we expliclty test
20 #if [ ! -z "CXXFLAGS" ]; then
21 # ADD_CXXFLAGS=$(echo "$CXXFLAGS" | sed 's/\(-DDEBUG\|-DNDEBUG\|-O[0-9]\|-Os\|-Og\|-fsanitize=address\|-fsanitize=undefined\|-DDCRYPTOPP_NO_UNALIGNED_DATA_ACCESS\|-DDCRYPTOPP_NO_UNALIGNED_DATA_ACCESS\|-DDCRYPTOPP_NO_BACKWARDS_COMPATIBILITY_562\)//g')
26 # I can't seem to get the expression to work in sed on Apple. It returns the original CXXFLAGS.
27 # If you want to test with additional flags, then put them in ADD_CXXFLAGS below.
28 # ADD_CXXFLAGS="-mrdrnd -mrdseed"
31 IS_DARWIN=$(uname -s | grep -i -c darwin)
32 IS_LINUX=$(uname -s | grep -i -c linux)
33 IS_CYGWIN=$(uname -s | grep -i -c cygwin)
34 IS_MINGW=$(uname -s | grep -i -c mingw)
35 IS_OPENBSD=$(uname -s | grep -i -c openbsd)
37 # We need to use the C++ compiler to determine if c++11 is available. Otherwise
38 # a mis-detection occurs on Mac OS X 10.9 and above. Below, we use the same
39 # Implicit Variables as make. Also see
40 # https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html
41 if [ -z "$CXX" ]; then
42 if [ "$IS_DARWIN" -ne "0" ]; then
45 # Linux, MinGW, Cygwin and fallback ...
51 if [ "$CXX" == "gcc" ]; then
56 if [ "$IS_OPENBSD" -ne "0" ]; then
62 if [ -z "$TMP" ]; then
66 # Use the compiler driver, and not cpp, to tell us if the flag is consumed.
67 $CXX -x c++ -dM -E -std=c++11 - < /dev/null > /dev/null 2>&1
68 if [ "$?" -eq "0" ]; then
74 # OpenBSD 5.7 and OS X 10.5 cannot consume -std=c++03
75 $CXX -x c++ -dM -E -std=c++03 - < /dev/null > /dev/null 2>&1
76 if [ "$?" -eq "0" ]; then
82 # Set to 0 if you don't have UBsan
83 $CXX -x c++ -fsanitize=undefined adhoc.cpp.proto -o $TMP/adhoc > /dev/null 2>&1
84 if [ "$?" -eq "0" ]; then
91 if [ "$IS_CYGWIN" -ne "0" ] || [ "$IS_MINGW" -ne "0" ]; then
95 # Set to 0 if you don't have Asan
96 $CXX -x c++ -fsanitize=undefined adhoc.cpp.proto -o $TMP/adhoc > /dev/null 2>&1
97 if [ "$?" -eq "0" ]; then
104 if [ "$IS_CYGWIN" -ne "0" ] || [ "$IS_MINGW" -ne "0" ]; then
108 #Final fixups for compilers liek GCC on ARM64
109 if [ "$HAVE_UBSAN" -eq "0" ] || [ "$HAVE_ASAN" -eq "0" ]; then
114 # Set to 0 if you don't have Valgrind. Valgrind tests take a long time...
115 HAVE_VALGRIND=$(which valgrind 2>&1 | grep -v "no valgrind" | grep -i -c valgrind)
117 # Echo back to ensure something is not missed.
119 echo "HAVE_CXX03: $HAVE_CXX03"
120 echo "HAVE_CXX11: $HAVE_CXX11"
121 echo "HAVE_ASAN: $HAVE_ASAN"
122 echo "HAVE_UBSAN: $HAVE_UBSAN"
124 if [ "$HAVE_VALGRIND" -ne "0" ]; then
125 echo "HAVE_VALGRIND: $HAVE_VALGRIND"
127 if [ "$IS_DARWIN" -ne "0" ]; then
128 echo "IS_DARWIN: $IS_DARWIN"
129 unset MallocScribble MallocPreScribble MallocGuardEdges
131 if [ "$IS_LINUX" -ne "0" ]; then
132 echo "IS_LINUX: $IS_LINUX"
134 if [ "$IS_CYGWIN" -ne "0" ]; then
135 echo "IS_CYGWIN: $IS_CYGWIN"
137 if [ "$IS_MINGW" -ne "0" ]; then
138 echo "IS_MINGW: $IS_MINGW"
141 echo "User CXXFLAGS: $CXXFLAGS"
142 echo "Retained CXXFLAGS: $ADD_CXXFLAGS"
143 echo "Compiler:" $($CXX --version | head -1)
147 echo "Start time: $TEST_BEGIN"
149 ############################################
150 ############################################
152 # Remove previous test results
153 rm -f "$TEST_RESULTS" > /dev/null 2>&1
154 touch "$TEST_RESULTS"
156 rm -f "$BENCHMARK_RESULTS" > /dev/null 2>&1
157 touch "$BENCHMARK_RESULTS"
159 rm -f "$WARN_RESULTS" > /dev/null 2>&1
160 touch "$WARN_RESULTS"
162 ############################################
165 echo "************************************" | tee -a "$TEST_RESULTS"
166 echo "Testing: debug, default CXXFLAGS" | tee -a "$TEST_RESULTS"
170 "$MAKE" clean > /dev/null 2>&1
171 export CXXFLAGS="-DDEBUG -g2 -O2"
172 "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
173 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
174 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
176 ############################################
177 # Basic release build
179 echo "************************************" | tee -a "$TEST_RESULTS"
180 echo "Testing: release, default CXXFLAGS" | tee -a "$TEST_RESULTS"
184 "$MAKE" clean > /dev/null 2>&1
185 export CXXFLAGS="-DNDEBUG -g2 -O2"
186 "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
187 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
188 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
190 ############################################
191 # Basic debug build, DISABLE_ASM
193 echo "************************************" | tee -a "$TEST_RESULTS"
194 echo "Testing: debug, default CXXFLAGS, DISABLE_ASM" | tee -a "$TEST_RESULTS"
198 "$MAKE" clean > /dev/null 2>&1
199 export CXXFLAGS="-DDEBUG -g2 -O2 -DCRYPTOPP_DISABLE_ASM"
200 "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
201 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
202 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
204 ############################################
205 # Basic release build, DISABLE_ASM
207 echo "************************************" | tee -a "$TEST_RESULTS"
208 echo "Testing: release, default CXXFLAGS, DISABLE_ASM" | tee -a "$TEST_RESULTS"
212 "$MAKE" clean > /dev/null 2>&1
213 export CXXFLAGS="-DNDEBUG -g2 -O2 -DCRYPTOPP_DISABLE_ASM"
214 "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
215 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
216 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
218 ############################################
220 if [ "$HAVE_CXX03" -ne "0" ]; then
222 echo "************************************" | tee -a "$TEST_RESULTS"
223 echo "Testing: debug, c++03" | tee -a "$TEST_RESULTS"
227 "$MAKE" clean > /dev/null 2>&1
228 export CXXFLAGS="-DDEBUG -g2 -O2 -std=c++03 $ADD_CXXFLAGS"
229 "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
230 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
231 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
234 ############################################
235 # c++03 release build
236 if [ "$HAVE_CXX03" -ne "0" ]; then
238 echo "************************************" | tee -a "$TEST_RESULTS"
239 echo "Testing: release, c++03" | tee -a "$TEST_RESULTS"
243 "$MAKE" clean > /dev/null 2>&1
244 export CXXFLAGS="-DNDEBUG -g2 -O2 -std=c++03 $ADD_CXXFLAGS"
245 "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
246 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
247 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
250 ############################################
252 if [ "$HAVE_CXX11" -ne "0" ]; then
254 echo "************************************" | tee -a "$TEST_RESULTS"
255 echo "Testing: debug, c++11" | tee -a "$TEST_RESULTS"
259 "$MAKE" clean > /dev/null 2>&1
260 export CXXFLAGS="-DDEBUG -g2 -O2 -std=c++11 $ADD_CXXFLAGS"
261 "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
262 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
263 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
266 ############################################
267 # c++11 release build
268 if [ "$HAVE_CXX11" -ne "0" ]; then
270 echo "************************************" | tee -a "$TEST_RESULTS"
271 echo "Testing: release, c++11" | tee -a "$TEST_RESULTS"
275 "$MAKE" clean > /dev/null 2>&1
276 export CXXFLAGS="-DNDEBUG -g2 -O2 -std=c++11 $ADD_CXXFLAGS"
277 "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
278 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
279 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
282 ############################################
283 # Debug build, all backwards compatibility.
285 echo "************************************" | tee -a "$TEST_RESULTS"
286 echo "Testing: debug, MAINTAIN_BACKWARDS_COMPATIBILITY" | tee -a "$TEST_RESULTS"
290 "$MAKE" clean > /dev/null 2>&1
291 export CXXFLAGS="-DDEBUG -g2 -O2 -DCRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY $ADD_CXXFLAGS"
292 "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
293 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
294 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
296 ############################################
297 # Release build, all backwards compatibility.
299 echo "************************************" | tee -a "$TEST_RESULTS"
300 echo "Testing: release, MAINTAIN_BACKWARDS_COMPATIBILITY" | tee -a "$TEST_RESULTS"
304 "$MAKE" clean > /dev/null 2>&1
305 export CXXFLAGS="-DNDEBUG -g2 -O2 -DCRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY $ADD_CXXFLAGS"
306 "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
307 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
308 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
310 ############################################
311 # Debug build, init_priority
313 echo "************************************" | tee -a "$TEST_RESULTS"
314 echo "Testing: debug, INIT_PRIORITY" | tee -a "$TEST_RESULTS"
318 "$MAKE" clean > /dev/null 2>&1
319 export CXXFLAGS="-DDEBUG -g2 -O1 -DCRYPTOPP_INIT_PRIORITY=250 $ADD_CXXFLAGS"
320 "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
321 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
322 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
324 ############################################
325 # Release build, init_priority
327 echo "************************************" | tee -a "$TEST_RESULTS"
328 echo "Testing: release, INIT_PRIORITY" | tee -a "$TEST_RESULTS"
332 "$MAKE" clean > /dev/null 2>&1
333 export CXXFLAGS="-DNDEBUG -g2 -O2 -DCRYPTOPP_INIT_PRIORITY=250 $ADD_CXXFLAGS"
334 "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
335 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
336 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
338 ############################################
339 # Release build, no unaligned data access
340 # This test will not be needed in Crypto++ 5.7 and above
342 echo "************************************" | tee -a "$TEST_RESULTS"
343 echo "Testing: release, NO_UNALIGNED_DATA_ACCESS" | tee -a "$TEST_RESULTS"
347 "$MAKE" clean > /dev/null 2>&1
348 export CXXFLAGS="-DNDEBUG -g2 -O2 -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS $ADD_CXXFLAGS"
349 "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
350 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
351 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
353 ############################################
354 # Release build, no backwards compatibility with Crypto++ 5.6.2.
355 # This test will not be needed in Crypto++ 5.7 and above
357 echo "************************************" | tee -a "$TEST_RESULTS"
358 echo "Testing: release, NO_BACKWARDS_COMPATIBILITY_562" | tee -a "$TEST_RESULTS"
362 "$MAKE" clean > /dev/null 2>&1
363 export CXXFLAGS="-DNDEBUG -g2 -O2 -DCRYPTOPP_NO_BACKWARDS_COMPATIBILITY_562 $ADD_CXXFLAGS"
364 "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
365 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
366 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
368 ############################################
369 # Debug build, OS Independence
371 echo "************************************" | tee -a "$TEST_RESULTS"
372 echo "Testing: debug, NO_OS_DEPENDENCE" | tee -a "$TEST_RESULTS"
376 "$MAKE" clean > /dev/null 2>&1
377 export CXXFLAGS="-DDEBUG -g2 -O1 -DNO_OS_DEPENDENCE $ADD_CXXFLAGS"
378 "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
379 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
380 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
382 ############################################
383 # Release build, OS Independence
385 echo "************************************" | tee -a "$TEST_RESULTS"
386 echo "Testing: release, NO_OS_DEPENDENCE" | tee -a "$TEST_RESULTS"
390 "$MAKE" clean > /dev/null 2>&1
391 export CXXFLAGS="-DNDEBUG -g2 -O2 -DNO_OS_DEPENDENCE $ADD_CXXFLAGS"
392 "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
393 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
394 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
396 ############################################
399 echo "************************************" | tee -a "$TEST_RESULTS"
400 echo "Testing: debug, -O3 optimizations" | tee -a "$TEST_RESULTS"
404 "$MAKE" clean > /dev/null 2>&1
405 export CXXFLAGS="-DDEBUG -g2 -O3 $ADD_CXXFLAGS"
406 "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
407 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
408 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
410 ############################################
411 # Release build at -O3
413 echo "************************************" | tee -a "$TEST_RESULTS"
414 echo "Testing: release, -O3 optimizations" | tee -a "$TEST_RESULTS"
418 "$MAKE" clean > /dev/null 2>&1
419 export CXXFLAGS="-DNDEBUG -g2 -O3 $ADD_CXXFLAGS"
420 "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
421 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
422 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
424 ############################################
427 echo "************************************" | tee -a "$TEST_RESULTS"
428 echo "Testing: debug, -Os optimizations" | tee -a "$TEST_RESULTS"
432 "$MAKE" clean > /dev/null 2>&1
433 export CXXFLAGS="-DDEBUG -g2 -Os $ADD_CXXFLAGS"
434 "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
435 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
436 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
438 ############################################
439 # Release build at -Os
441 echo "************************************" | tee -a "$TEST_RESULTS"
442 echo "Testing: release, -Os optimizations" | tee -a "$TEST_RESULTS"
446 "$MAKE" clean > /dev/null 2>&1
447 export CXXFLAGS="-DNDEBUG -g2 -Os $ADD_CXXFLAGS"
448 "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
449 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
450 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
452 ############################################
453 # Debug build, UBSan, c++03
454 if [ "$HAVE_CXX03" -ne "0" ] && [ "$HAVE_UBSAN" -ne "0" ]; then
456 echo "************************************" | tee -a "$TEST_RESULTS"
457 echo "Testing: debug, c++03, UBsan" | tee -a "$TEST_RESULTS"
461 "$MAKE" clean > /dev/null 2>&1
462 export CXXFLAGS="-DDEBUG -g2 -O1 -std=c++03 $ADD_CXXFLAGS"
463 "$MAKE" ubsan | tee -a "$TEST_RESULTS"
464 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
465 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
468 ############################################
469 # Release build, UBSan, c++03
470 if [ "$HAVE_CXX03" -ne "0" ] && [ "$HAVE_UBSAN" -ne "0" ]; then
472 echo "************************************" | tee -a "$TEST_RESULTS"
473 echo "Testing: release, c++03, UBsan" | tee -a "$TEST_RESULTS"
477 "$MAKE" clean > /dev/null 2>&1
478 export CXXFLAGS="-DNDEBUG -g2 -O2 -std=c++03 $ADD_CXXFLAGS"
479 "$MAKE" ubsan | tee -a "$TEST_RESULTS"
480 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
481 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
484 ############################################
485 # Debug build, Asan, c++03
486 if [ "$HAVE_CXX03" -ne "0" ] && [ "$HAVE_ASAN" -ne "0" ]; then
488 echo "************************************" | tee -a "$TEST_RESULTS"
489 echo "Testing: debug, c++03, Asan" | tee -a "$TEST_RESULTS"
493 "$MAKE" clean > /dev/null 2>&1
494 export CXXFLAGS="-DDEBUG -g2 -O1 -std=c++03 $ADD_CXXFLAGS"
495 "$MAKE" asan | tee -a "$TEST_RESULTS"
496 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
497 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
500 ############################################
501 # Release build, Asan, c++03
502 if [ "$HAVE_CXX03" -ne "0" ] && [ "$HAVE_ASAN" -ne "0" ]; then
504 echo "************************************" | tee -a "$TEST_RESULTS"
505 echo "Testing: release, c++03, Asan" | tee -a "$TEST_RESULTS"
509 "$MAKE" clean > /dev/null 2>&1
510 export CXXFLAGS="-DNDEBUG -g2 -O2 -std=c++03 $ADD_CXXFLAGS"
511 "$MAKE" asan | tee -a "$TEST_RESULTS"
512 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
513 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
516 ############################################
517 # Release build, UBSan, c++11
518 if [ "$HAVE_CXX11" -ne "0" ] && [ "$HAVE_UBSAN" -ne "0" ]; then
519 echo "************************************" | tee -a "$TEST_RESULTS"
520 echo "Testing: c++11, UBsan" | tee -a "$TEST_RESULTS"
524 "$MAKE" clean > /dev/null 2>&1
525 export CXXFLAGS="-DNDEBUG -g2 -O2 -std=c++11 $ADD_CXXFLAGS"
526 "$MAKE" ubsan | tee -a "$TEST_RESULTS"
527 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
528 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
531 ############################################
532 # Release build, Asan, c++11
533 if [ "$HAVE_CXX11" -ne "0" ] && [ "$HAVE_ASAN" -ne "0" ]; then
535 echo "************************************" | tee -a "$TEST_RESULTS"
536 echo "Testing: c++11, Asan" | tee -a "$TEST_RESULTS"
540 "$MAKE" clean > /dev/null 2>&1
541 export CXXFLAGS="-DNDEBUG -g2 -O2 -std=c++11 $ADD_CXXFLAGS"
542 "$MAKE" asan | tee -a "$TEST_RESULTS"
543 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
544 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
547 # For Darwin, we need to test both -stdlib=libstdc++ (GNU) and
548 # -stdlib=libc++ (LLVM) crossed with -std=c++03 and -std=c++11.
550 ############################################
551 # Darwin, c++03, libc++
552 if [ "$HAVE_CXX03" -ne "0" ] && [ "$IS_DARWIN" -ne "0" ]; then
554 echo "************************************" | tee -a "$TEST_RESULTS"
555 echo "Testing: Darwin, c++03, libc++ (LLVM)" | tee -a "$TEST_RESULTS"
559 "$MAKE" clean > /dev/null 2>&1
560 export CXXFLAGS="-DNDEBUG -g2 -O2 -std=c++03 -stdlib=libc++ $ADD_CXXFLAGS"
561 "$MAKE" static cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
562 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
563 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
566 ############################################
567 # Darwin, c++03, libstdc++
568 if [ "$HAVE_CXX03" -ne "0" ] && [ "$IS_DARWIN" -ne "0" ]; then
570 echo "************************************" | tee -a "$TEST_RESULTS"
571 echo "Testing: Darwin, c++03, libstdc++ (GNU)" | tee -a "$TEST_RESULTS"
575 "$MAKE" clean > /dev/null 2>&1
576 export CXXFLAGS="-DNDEBUG -g2 -O2 -std=c++03 -stdlib=libstdc++ $ADD_CXXFLAGS"
577 "$MAKE" static cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
578 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
579 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
582 ############################################
583 # Darwin, c++11, libc++
584 if [ "$IS_DARWIN" -ne "0" ] && [ "$HAVE_CXX11" -ne "0" ]; then
586 echo "************************************" | tee -a "$TEST_RESULTS"
587 echo "Testing: Darwin, c++11, libc++ (LLVM)" | tee -a "$TEST_RESULTS"
591 "$MAKE" clean > /dev/null 2>&1
592 export CXXFLAGS="-DNDEBUG -g2 -O2 -std=c++11 -stdlib=libc++ $ADD_CXXFLAGS"
593 "$MAKE" static cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
594 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
595 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
598 ############################################
599 # Darwin, c++11, libstdc++
600 if [ "$IS_DARWIN" -ne "0" ] && [ "$HAVE_CXX11" -ne "0" ]; then
602 echo "************************************" | tee -a "$TEST_RESULTS"
603 echo "Testing: Darwin, c++11, libstdc++ (GNU)" | tee -a "$TEST_RESULTS"
607 "$MAKE" clean > /dev/null 2>&1
608 export CXXFLAGS="-DNDEBUG -g2 -O2 -std=c++11 -stdlib=libstdc++ $ADD_CXXFLAGS"
609 "$MAKE" static cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
610 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
611 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
614 ############################################
615 # Darwin, c++03, Malloc Guards
616 if [ "$IS_DARWIN" -ne "0" ] && [ "$HAVE_CXX03" -ne "0" ]; then
618 echo "************************************" | tee -a "$TEST_RESULTS"
619 echo "Testing: Darwin, c++03, Malloc Guards" | tee -a "$TEST_RESULTS"
623 "$MAKE" clean > /dev/null 2>&1
624 export CXXFLAGS="-DNDEBUG -g2 -O2 -std=c++03 $ADD_CXXFLAGS"
625 "$MAKE" static cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
627 export MallocScribble=1
628 export MallocPreScribble=1
629 export MallocGuardEdges=1
630 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
631 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
632 unset MallocScribble MallocPreScribble MallocGuardEdges
635 ############################################
636 # Darwin, c++11, Malloc Guards
637 if [ "$IS_DARWIN" -ne "0" ] && [ "$HAVE_CXX11" -ne "0" ]; then
639 echo "************************************" | tee -a "$TEST_RESULTS"
640 echo "Testing: Darwin, c++11, Malloc Guards" | tee -a "$TEST_RESULTS"
644 "$MAKE" clean > /dev/null 2>&1
645 export CXXFLAGS="-DNDEBUG -g2 -O2 -std=c++11 $ADD_CXXFLAGS"
646 "$MAKE" static cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
648 export MallocScribble=1
649 export MallocPreScribble=1
650 export MallocGuardEdges=1
651 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
652 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
653 unset MallocScribble MallocPreScribble MallocGuardEdges
656 # Try to locate a Xcode compiler for testing under Darwin
657 XCODE_COMPILER=$(find /Applications/Xcode*.app/Contents/Developer -name clang++ | head -1)
659 ############################################
661 if [ "$IS_DARWIN" -ne "0" ] && [ -z "$XCODE_COMPILER" ]; then
663 echo "************************************" | tee -a "$TEST_RESULTS"
664 echo "Testing: Xcode Clang compiler" | tee -a "$TEST_RESULTS"
668 "$MAKE" clean > /dev/null 2>&1
669 expot CXX="$XCODE_COMPILER"
670 export CXXFLAGS="-DNDEBUG -g2 -O2 -std=c++11 $ADD_CXXFLAGS"
671 "$MAKE" static cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
672 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
673 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
676 ############################################
678 if [ "$HAVE_CXX03" -ne "0" ]; then
680 echo "************************************" | tee -a "$TEST_RESULTS"
681 echo "Testing: Benchmarks, c++03" | tee -a "$TEST_RESULTS"
685 "$MAKE" clean > /dev/null 2>&1
686 export CXXFLAGS="-DNDEBUG -O3 -std=c++03 $ADD_CXXFLAGS"
687 "$MAKE" static cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
688 ./cryptest.exe b 3 2.4+1e9 2>&1 | tee -a "$BENCHMARK_RESULTS"
691 ############################################
693 if [ "$HAVE_CXX11" -ne "0" ]; then
695 echo "************************************" | tee -a "$TEST_RESULTS"
696 echo "Testing: Benchmarks, c++11" | tee -a "$TEST_RESULTS"
700 "$MAKE" clean > /dev/null 2>&1
701 export CXXFLAGS="-DNDEBUG -O3 -std=c++11 $ADD_CXXFLAGS"
702 "$MAKE" static cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
703 ./cryptest.exe b 3 2.4+1e9 2>&1 | tee -a "$BENCHMARK_RESULTS"
706 # For Cygwin, we need to test both PREFER_BERKELEY_STYLE_SOCKETS
707 # and PREFER_WINDOWS_STYLE_SOCKETS
709 ############################################
710 # MinGW and PREFER_BERKELEY_STYLE_SOCKETS
711 if [ "$IS_MINGW" -ne "0" ]; then
713 echo "************************************" | tee -a "$TEST_RESULTS"
714 echo "Testing: MinGW, PREFER_BERKELEY_STYLE_SOCKETS" | tee -a "$TEST_RESULTS"
718 "$MAKE" clean > /dev/null 2>&1
719 export CXXFLAGS="-DNDEBUG -g2 -O2 -DPREFER_BERKELEY_STYLE_SOCKETS -DNO_WINDOWS_STYLE_SOCKETS $ADD_CXXFLAGS"
720 "$MAKE" static cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
721 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
722 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
725 ############################################
726 # MinGW and PREFER_WINDOWS_STYLE_SOCKETS
727 if [ "$IS_MINGW" -ne "0" ]; then
729 echo "************************************" | tee -a "$TEST_RESULTS"
730 echo "Testing: MinGW, PREFER_WINDOWS_STYLE_SOCKETS" | tee -a "$TEST_RESULTS"
734 "$MAKE" clean > /dev/null 2>&1
735 export CXXFLAGS="-DNDEBUG -g2 -O2 -DPREFER_WINDOWS_STYLE_SOCKETS -DNO_BERKELEY_STYLE_SOCKETS $ADD_CXXFLAGS"
736 "$MAKE" static cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
737 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
738 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
741 ############################################
742 # Valgrind, c++03. Requires -O1 for accurate results
743 if [ "$HAVE_CXX03" -ne "0" ] && [ "$HAVE_VALGRIND" -ne "0" ]; then
745 echo "************************************" | tee -a "$TEST_RESULTS"
746 echo "Testing: Valgrind, c++03" | tee -a "$TEST_RESULTS"
750 "$MAKE" clean > /dev/null 2>&1
751 export CXXFLAGS="-DNDEBUG -std=c++03 -g3 -O1 $ADD_CXXFLAGS"
752 "$MAKE" static cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
753 valgrind --track-origins=yes ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
754 valgrind --track-origins=yes ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
757 ############################################
758 # Valgrind, c++11. Requires -O1 for accurate results
759 if [ "$HAVE_VALGRIND" -ne "0" ] && [ "$HAVE_CXX11" -ne "0" ]; then
761 echo "************************************" | tee -a "$TEST_RESULTS"
762 echo "Testing: Valgrind, c++11" | tee -a "$TEST_RESULTS"
766 "$MAKE" clean > /dev/null 2>&1
767 export CXXFLAGS="-DNDEBUG -std=c++11 -g3 -O1 $ADD_CXXFLAGS"
768 "$MAKE" static cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
769 valgrind --track-origins=yes ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
770 valgrind --track-origins=yes ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
773 ############################################
774 ############################################
776 if [ "$CXX" == "g++" ] && [ "$HAVE_CXX11" -ne "0" ]; then
778 ############################################
781 echo "************************************" | tee -a "$WARN_TEST_RESULTS"
782 echo "Testing: debug, c++11, elevated warnings" | tee -a "$WARN_TEST_RESULTS"
786 "$MAKE" clean > /dev/null 2>&1
787 export CXXFLAGS="-DDEBUG -g2 -O2 -std=c++11 -DCRYPTOPP_NO_BACKWARDS_COMPATIBILITY_562 -Wall -Wextra -Wno-unknown-pragmas"
788 "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$WARN_TEST_RESULTS"
790 ############################################
791 # Basic release build
793 echo "************************************" | tee -a "$WARN_TEST_RESULTS"
794 echo "Testing: release, c++11, elevated warnings" | tee -a "$WARN_TEST_RESULTS"
798 "$MAKE" clean > /dev/null 2>&1
799 export CXXFLAGS="-DNDEBUG -g2 -O2 -std=c++11 -DCRYPTOPP_NO_BACKWARDS_COMPATIBILITY_562 -Wall -Wextra -Wno-unknown-pragmas"
800 "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$WARN_TEST_RESULTS"
803 ############################################
804 ############################################
808 echo "************************************************" | tee -a "$TEST_RESULTS"
809 echo "************************************************" | tee -a "$TEST_RESULTS"
810 echo | tee -a "$TEST_RESULTS"
812 echo "Testing started: $TEST_BEGIN" | tee -a "$TEST_RESULTS"
813 echo "Testing finished: $TEST_END" | tee -a "$TEST_RESULTS"
814 echo | tee -a "$TEST_RESULTS"
816 COUNT=$(grep -a "Testing: " cryptest-result.txt | wc -l)
817 if [ "$COUNT" -eq "0" ]; then
818 echo "No configurations tested" | tee -a "$TEST_RESULTS"
820 echo "$COUNT configurations tested" | tee -a "$TEST_RESULTS"
822 echo | tee -a "$TEST_RESULTS"
824 # "FAILED" is from Crypto++
825 # "Error" is from the GNU assembler
826 # "error" is from the sanitizers
827 # "Illegal", "0 errors" and "suppressed errors" are from Valgrind.
828 COUNT=$(egrep -a '(Error|error|FAILED|Illegal)' cryptest-result.txt | egrep -v "( 0 errors|suppressed errors|memory error detector)" | wc -l)
829 if [ "$COUNT" -eq "0" ]; then
830 echo "No failures detected" | tee -a "$TEST_RESULTS"
832 echo "$COUNT errors detected" | tee -a "$TEST_RESULTS"
834 egrep -an "(Error|error|FAILED|Illegal)" cryptest-result.txt
836 echo | tee -a "$TEST_RESULTS"
838 echo "************************************************" | tee -a "$TEST_RESULTS"
839 echo "************************************************" | tee -a "$TEST_RESULTS"