From c8e13300e11b5ca06d864778d6bd7183e1562e45 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Sat, 15 Aug 2020 17:27:45 +0900 Subject: [PATCH] Add script to run tests using sanitizers These currently show several kinds of errors. --- test/integration-test-common.sh | 4 ++-- test/run_tests_using_sanitizers.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100755 test/run_tests_using_sanitizers.sh diff --git a/test/integration-test-common.sh b/test/integration-test-common.sh index ddbe9ee..bc09c7c 100644 --- a/test/integration-test-common.sh +++ b/test/integration-test-common.sh @@ -213,7 +213,7 @@ function start_s3fs { if [ `uname` = "Darwin" ]; then set +o errexit TRYCOUNT=0 - while [ $TRYCOUNT -le 20 ]; do + while [ $TRYCOUNT -le ${RETRIES:=20} ]; do df | grep -q $TEST_BUCKET_MOUNT_POINT_1 if [ $? -eq 0 ]; then break; @@ -226,7 +226,7 @@ function start_s3fs { fi set -o errexit else - retry 20 grep -q $TEST_BUCKET_MOUNT_POINT_1 /proc/mounts || exit 1 + retry ${RETRIES:=20} grep -q $TEST_BUCKET_MOUNT_POINT_1 /proc/mounts || exit 1 fi # Quick way to start system up for manual testing with options under test diff --git a/test/run_tests_using_sanitizers.sh b/test/run_tests_using_sanitizers.sh new file mode 100755 index 0000000..8ff85e5 --- /dev/null +++ b/test/run_tests_using_sanitizers.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +set -o errexit +set -o nounset +set -o pipefail + +# run tests with libstc++ debug mode, https://gcc.gnu.org/onlinedocs/libstdc++/manual/debug_mode.html +make clean +./configure CXXFLAGS='-D_GLIBCXX_DEBUG -g' +make +DBGLEVEL=debug make check -C test/ + +# run tests under AddressSanitizer, https://clang.llvm.org/docs/AddressSanitizer.html +make clean +./configure CXX=clang++ CXXFLAGS='-fsanitize=address -fsanitize-address-use-after-scope -g' +make +ASAN_OPTIONS='detect_stack_use_after_return=1' make check -C test/ + +# run tests under ThreadSanitizer, https://clang.llvm.org/docs/ThreadSanitizer.html +make clean +./configure CXX=clang++ CXXFLAGS='-fsanitize=thread -g' +make +TSAN_OPTIONS='halt_on_error=1' make check -C test/ + +# run tests under Valgrind +make clean +./configure CXXFLAGS='-O1 -g' +make +RETRIES=200 VALGRIND='--error-exitcode=1 --leak-check=full' make check -C test/