Skip to content

CDRIVER-3620 Remove Valgrind tests from Evergreen #1177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .evergreen/bypass-dlclose.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash

# bypass_dlclose
#
# Usage:
# bypass_dlclose command args...
#
# Parameters:
# "$@": command and arguments to evaluate.
# "$CC": compiler to use to compile and link the bypass_dlclose library.
#
# Evaluates the provided command and arguments with LD_PRELOAD defined to
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incomplete sentence?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops. Will fix.

# preload a `bypass_dlclose.so` library defining a no-op `dlclose()`.
# If necessary, also preloads the `libasan.so` library to satisfy linker
# requirements.
bypass_dlclose() {
: "${1:?'bypass_dlclose expects at least one argument to run as command!'}"
: "${CC:?'bypass_dlclose expects environment variable CC to be defined!'}"

declare tmp

if ! tmp="$(mktemp -d)"; then
echo "Could not create temporary directory for bypass_dlclose library!" 1>&2
return 1
fi
trap 'rm -rf "$tmp"' EXIT

declare ld_preload

echo "int dlclose (void *handle) {(void) handle; return 0; }" >|"$tmp/bypass_dlclose.c"

"$CC" -o "$tmp/bypass_dlclose.so" -shared "$tmp/bypass_dlclose.c" || return

ld_preload="$tmp/bypass_dlclose.so"

# Clang uses its own libasan.so; do not preload it!
if [ "$CC" != "clang" ]; then
declare asan_path
asan_path="$($CC -print-file-name=libasan.so)" || return
ld_preload="$asan_path:$ld_preload"
fi

LD_PRELOAD="$ld_preload:${LD_PRELOAD:-}" "$@"
}
29 changes: 12 additions & 17 deletions .evergreen/compile-unix.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
#!/usr/bin/env bash

set -o errexit # Exit the script with error if any of the commands fail

# Supported/used environment variables:
Expand All @@ -9,7 +10,6 @@ set -o errexit # Exit the script with error if any of the commands fail
# RELEASE Use the fully qualified release archive
# DEBUG Use debug configure flags
# TRACING Use function tracing
# VALGRIND Run the test suite through valgrind
# CC Which compiler to use
# ANALYZE Run the build through clangs scan-build
# COVERAGE Produce code coverage reports
Expand All @@ -33,7 +33,6 @@ C_STD_VERSION=${CSTD_VERSION:-99}
RELEASE=${RELEASE:-OFF}
DEBUG=${DEBUG:-OFF}
TRACING=${TRACING:-OFF}
VALGRIND=${VALGRIND:-OFF}
ANALYZE=${ANALYZE:-OFF}
COVERAGE=${COVERAGE:-OFF}
RDTSCP=${RDTSCP:-OFF}
Expand All @@ -54,7 +53,6 @@ echo "MARCH: $MARCH"
echo "RELEASE: $RELEASE"
echo "DEBUG: $DEBUG"
echo "TRACING: $TRACING"
echo "VALGRIND: $VALGRIND"
echo "CC: $CC"
echo "ANALYZE: $ANALYZE"
echo "COVERAGE: $COVERAGE"
Expand Down Expand Up @@ -126,6 +124,14 @@ fi

. $DIR/find-cmake.sh

if [[ "${SANITIZE}" =~ "address" ]]; then
echo "Bypassing dlclose to workaround <unknown module> ASAN warnings"
. "$DIR/bypass-dlclose.sh"
else
# Disable bypass otherwise.
bypass_dlclose() { "$@"; }
fi

# --strip-components is an GNU tar extension. Check if the platform
# has GNU tar installed as `gtar`, otherwise we assume to be on
# platform that supports it
Expand Down Expand Up @@ -289,17 +295,6 @@ if [ "$SKIP_MOCK_TESTS" = "ON" ]; then
exit 0
fi

if [ "$VALGRIND" = "ON" ]; then
# Defines "run_valgrind" shell function.
. $DIR/valgrind.sh
else
# Define a no-op function.
run_valgrind ()
{
$@
}
fi

export MONGOC_TEST_SERVER_LOG=stdout

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

# Check if the error.log exists, and is more than 0 byte
Expand Down
3 changes: 2 additions & 1 deletion .evergreen/compile-windows.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
#!/usr/bin/env bash

set -o igncr # Ignore CR in this script
set -o errexit # Exit the script with error if any of the commands fail

Expand Down
7 changes: 4 additions & 3 deletions .evergreen/compile.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/bin/sh
#!/usr/bin/env bash

set -o errexit # Exit the script with error if any of the commands fail

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

case "$OS" in
cygwin*)
sh ./.evergreen/compile-windows.sh
bash ./.evergreen/compile-windows.sh
;;

*)
sh ./.evergreen/compile-unix.sh
bash ./.evergreen/compile-unix.sh
;;
esac
Loading