summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2024-01-18 10:44:06 -0800
committer Colin Cross <ccross@android.com> 2024-01-18 13:23:06 -0800
commitec78a467a55d96377e64bed0cad34073a4700215 (patch)
tree074d6309fe3a9abb136b5d9c3373f8d9b9caf744
parent6ca8d2546e4323a4d7fc20a0388b80f2b1386f3c (diff)
Run soong tests in presubmit with the race detector enabled
Add go test -race -short to run-soong-tests-with-go-tools.sh to make the tests run in presubmit with the race detector enabled. Test: presubmit Change-Id: I3162a46ebef965879915c0b534821d922392f1f8
-rwxr-xr-xscripts/run-soong-tests-with-go-tools.sh7
1 files changed, 7 insertions, 0 deletions
diff --git a/scripts/run-soong-tests-with-go-tools.sh b/scripts/run-soong-tests-with-go-tools.sh
index 50e418b26..9b7d8aaa9 100755
--- a/scripts/run-soong-tests-with-go-tools.sh
+++ b/scripts/run-soong-tests-with-go-tools.sh
@@ -32,6 +32,12 @@ export TMPDIR=${abs_out_dir}/gotemp
mkdir -p ${TMPDIR}
${GOROOT}/bin/go env
+# Building with the race detector enabled uses the host linker, set the
+# path to use the hermetic one.
+CLANG_VERSION=$(build/soong/scripts/get_clang_version.py)
+export CC="${TOP}/prebuilts/clang/host/${OS}-x86/${CLANG_VERSION}/bin/clang"
+export CXX="${TOP}/prebuilts/clang/host/${OS}-x86/${CLANG_VERSION}/bin/clang++"
+
# androidmk_test.go gets confused if ANDROID_BUILD_TOP is set.
unset ANDROID_BUILD_TOP
@@ -66,5 +72,6 @@ for dir in "${go_modules[@]}"; do
(cd "$dir";
eval ${network_jail} -- ${GOROOT}/bin/go build ./...
eval ${network_jail} -- ${GOROOT}/bin/go test ./...
+ eval ${network_jail} -- ${GOROOT}/bin/go test -race -short ./...
)
done