Skip to content

Commit c796edd

Browse files
authored
CDRIVER-3620 Remove Valgrind tests from Evergreen (#1177)
* Remove Valgrind tests from Evergreen * Add bypass-dlclose.sh * Silence LSAN "unknown module" leak warnings when running test executables * Ensure ENABLE_EXTRA_ALIGNMENT=OFF for authentication-tests-memcheck * Move authentication-tests-memcheck with Clang from 3.8 to 6.0 * Rename authentication-tests-memcheck to authentication-tests-asan-memcheck
1 parent da25cca commit c796edd

27 files changed

+387
-2047
lines changed

.evergreen/bypass-dlclose.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
3+
# bypass_dlclose
4+
#
5+
# Usage:
6+
# bypass_dlclose command args...
7+
#
8+
# Parameters:
9+
# "$@": command and arguments to evaluate.
10+
# "$CC": compiler to use to compile and link the bypass_dlclose library.
11+
#
12+
# Evaluates the provided command and arguments with LD_PRELOAD defined to
13+
# preload a `bypass_dlclose.so` library defining a no-op `dlclose()`.
14+
# If necessary, also preloads the `libasan.so` library to satisfy linker
15+
# requirements.
16+
bypass_dlclose() {
17+
: "${1:?'bypass_dlclose expects at least one argument to run as command!'}"
18+
: "${CC:?'bypass_dlclose expects environment variable CC to be defined!'}"
19+
20+
declare tmp
21+
22+
if ! tmp="$(mktemp -d)"; then
23+
echo "Could not create temporary directory for bypass_dlclose library!" 1>&2
24+
return 1
25+
fi
26+
trap 'rm -rf "$tmp"' EXIT
27+
28+
declare ld_preload
29+
30+
echo "int dlclose (void *handle) {(void) handle; return 0; }" >|"$tmp/bypass_dlclose.c"
31+
32+
"$CC" -o "$tmp/bypass_dlclose.so" -shared "$tmp/bypass_dlclose.c" || return
33+
34+
ld_preload="$tmp/bypass_dlclose.so"
35+
36+
# Clang uses its own libasan.so; do not preload it!
37+
if [ "$CC" != "clang" ]; then
38+
declare asan_path
39+
asan_path="$($CC -print-file-name=libasan.so)" || return
40+
ld_preload="$asan_path:$ld_preload"
41+
fi
42+
43+
LD_PRELOAD="$ld_preload:${LD_PRELOAD:-}" "$@"
44+
}

.evergreen/compile-unix.sh

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
2+
23
set -o errexit # Exit the script with error if any of the commands fail
34

45
# Supported/used environment variables:
@@ -9,7 +10,6 @@ set -o errexit # Exit the script with error if any of the commands fail
910
# RELEASE Use the fully qualified release archive
1011
# DEBUG Use debug configure flags
1112
# TRACING Use function tracing
12-
# VALGRIND Run the test suite through valgrind
1313
# CC Which compiler to use
1414
# ANALYZE Run the build through clangs scan-build
1515
# COVERAGE Produce code coverage reports
@@ -33,7 +33,6 @@ C_STD_VERSION=${CSTD_VERSION:-99}
3333
RELEASE=${RELEASE:-OFF}
3434
DEBUG=${DEBUG:-OFF}
3535
TRACING=${TRACING:-OFF}
36-
VALGRIND=${VALGRIND:-OFF}
3736
ANALYZE=${ANALYZE:-OFF}
3837
COVERAGE=${COVERAGE:-OFF}
3938
RDTSCP=${RDTSCP:-OFF}
@@ -54,7 +53,6 @@ echo "MARCH: $MARCH"
5453
echo "RELEASE: $RELEASE"
5554
echo "DEBUG: $DEBUG"
5655
echo "TRACING: $TRACING"
57-
echo "VALGRIND: $VALGRIND"
5856
echo "CC: $CC"
5957
echo "ANALYZE: $ANALYZE"
6058
echo "COVERAGE: $COVERAGE"
@@ -126,6 +124,14 @@ fi
126124

127125
. $DIR/find-cmake.sh
128126

127+
if [[ "${SANITIZE}" =~ "address" ]]; then
128+
echo "Bypassing dlclose to workaround <unknown module> ASAN warnings"
129+
. "$DIR/bypass-dlclose.sh"
130+
else
131+
# Disable bypass otherwise.
132+
bypass_dlclose() { "$@"; }
133+
fi
134+
129135
# --strip-components is an GNU tar extension. Check if the platform
130136
# has GNU tar installed as `gtar`, otherwise we assume to be on
131137
# platform that supports it
@@ -289,17 +295,6 @@ if [ "$SKIP_MOCK_TESTS" = "ON" ]; then
289295
exit 0
290296
fi
291297

292-
if [ "$VALGRIND" = "ON" ]; then
293-
# Defines "run_valgrind" shell function.
294-
. $DIR/valgrind.sh
295-
else
296-
# Define a no-op function.
297-
run_valgrind ()
298-
{
299-
$@
300-
}
301-
fi
302-
303298
export MONGOC_TEST_SERVER_LOG=stdout
304299

305300
# Write stderr to error.log and to console. Turn off tracing to avoid spurious
@@ -308,10 +303,10 @@ mkfifo pipe || true
308303
if [ -e pipe ]; then
309304
set +o xtrace
310305
tee error.log < pipe &
311-
run_valgrind ./src/libmongoc/test-libmongoc --no-fork -d -F test-results.json --skip-tests $DIR/skip-tests.txt 2>pipe
306+
bypass_dlclose ./src/libmongoc/test-libmongoc --no-fork -d -F test-results.json --skip-tests $DIR/skip-tests.txt 2>pipe
312307
rm pipe
313308
else
314-
run_valgrind ./src/libmongoc/test-libmongoc --no-fork -d -F test-results.json --skip-tests $DIR/skip-tests.txt
309+
bypass_dlclose ./src/libmongoc/test-libmongoc --no-fork -d -F test-results.json --skip-tests $DIR/skip-tests.txt
315310
fi
316311

317312
# Check if the error.log exists, and is more than 0 byte

.evergreen/compile-windows.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
2+
23
set -o igncr # Ignore CR in this script
34
set -o errexit # Exit the script with error if any of the commands fail
45

.evergreen/compile.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
2+
23
set -o errexit # Exit the script with error if any of the commands fail
34

45
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
56

67
case "$OS" in
78
cygwin*)
8-
sh ./.evergreen/compile-windows.sh
9+
bash ./.evergreen/compile-windows.sh
910
;;
1011

1112
*)
12-
sh ./.evergreen/compile-unix.sh
13+
bash ./.evergreen/compile-unix.sh
1314
;;
1415
esac

0 commit comments

Comments
 (0)