From dc2348d89c97ff2d6e3ef68c2d92163b474c0585 Mon Sep 17 00:00:00 2001 From: Matt Rice Date: Mon, 24 Jul 2017 11:59:23 -0400 Subject: [PATCH 1/4] Added environment variables to test options --- ci/build_setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build_setup.sh b/ci/build_setup.sh index ece8a76234503..d65203dbbc67a 100755 --- a/ci/build_setup.sh +++ b/ci/build_setup.sh @@ -66,7 +66,7 @@ export BAZEL_BUILD_OPTIONS="--strategy=Genrule=standalone --spawn_strategy=stand --verbose_failures ${BAZEL_OPTIONS} --action_env=HOME --action_env=PYTHONUSERBASE \ --jobs=${NUM_CPUS} --show_task_finish" export BAZEL_TEST_OPTIONS="${BAZEL_BUILD_OPTIONS} --test_env=HOME --test_env=PYTHONUSERBASE \ - --cache_test_results=no --test_output=all" + --test_env=HEAPCHECK --test_env=PPROF_PATH --cache_test_results=no --test_output=all" [[ "${BAZEL_EXPUNGE}" == "1" ]] && "${BAZEL}" clean --expunge ln -sf /thirdparty "${ENVOY_SRCDIR}"/ci/prebuilt ln -sf /thirdparty_build "${ENVOY_SRCDIR}"/ci/prebuilt From b1a3ebfb0ea3e4a2c7b713467d91862ebabd55a1 Mon Sep 17 00:00:00 2001 From: Matt Rice Date: Mon, 24 Jul 2017 13:37:05 -0400 Subject: [PATCH 2/4] Moved arguments from ci to bazel.rc --- ci/build_setup.sh | 2 +- tools/bazel.rc | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ci/build_setup.sh b/ci/build_setup.sh index d65203dbbc67a..b3a0802f55b11 100755 --- a/ci/build_setup.sh +++ b/ci/build_setup.sh @@ -66,7 +66,7 @@ export BAZEL_BUILD_OPTIONS="--strategy=Genrule=standalone --spawn_strategy=stand --verbose_failures ${BAZEL_OPTIONS} --action_env=HOME --action_env=PYTHONUSERBASE \ --jobs=${NUM_CPUS} --show_task_finish" export BAZEL_TEST_OPTIONS="${BAZEL_BUILD_OPTIONS} --test_env=HOME --test_env=PYTHONUSERBASE \ - --test_env=HEAPCHECK --test_env=PPROF_PATH --cache_test_results=no --test_output=all" + --test_env=HEAPCHECK --test_output=all" [[ "${BAZEL_EXPUNGE}" == "1" ]] && "${BAZEL}" clean --expunge ln -sf /thirdparty "${ENVOY_SRCDIR}"/ci/prebuilt ln -sf /thirdparty_build "${ENVOY_SRCDIR}"/ci/prebuilt diff --git a/tools/bazel.rc b/tools/bazel.rc index c773e77960f16..81c4a9bf0b43a 100644 --- a/tools/bazel.rc +++ b/tools/bazel.rc @@ -38,3 +38,6 @@ build:clang-msan --copt -fsanitize=memory build:clang-msan --linkopt -fsanitize=memory build:clang-msan --define tcmalloc=disabled build:clang-msan --copt -fsanitize-memory-track-origins=2 + +# Test options +test --test_env=HEAPCHECK --test_env=PPROF_PATH From 647a691a7895e2191c1899d747a32c987151bacd Mon Sep 17 00:00:00 2001 From: Matt Rice Date: Mon, 24 Jul 2017 13:38:31 -0400 Subject: [PATCH 3/4] Fixed typo --- ci/build_setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build_setup.sh b/ci/build_setup.sh index b3a0802f55b11..ece8a76234503 100755 --- a/ci/build_setup.sh +++ b/ci/build_setup.sh @@ -66,7 +66,7 @@ export BAZEL_BUILD_OPTIONS="--strategy=Genrule=standalone --spawn_strategy=stand --verbose_failures ${BAZEL_OPTIONS} --action_env=HOME --action_env=PYTHONUSERBASE \ --jobs=${NUM_CPUS} --show_task_finish" export BAZEL_TEST_OPTIONS="${BAZEL_BUILD_OPTIONS} --test_env=HOME --test_env=PYTHONUSERBASE \ - --test_env=HEAPCHECK --test_output=all" + --cache_test_results=no --test_output=all" [[ "${BAZEL_EXPUNGE}" == "1" ]] && "${BAZEL}" clean --expunge ln -sf /thirdparty "${ENVOY_SRCDIR}"/ci/prebuilt ln -sf /thirdparty_build "${ENVOY_SRCDIR}"/ci/prebuilt From 1f53ecde66ca372fc37b64ecdaf4e4c6bafeb008 Mon Sep 17 00:00:00 2001 From: Matt Rice Date: Mon, 24 Jul 2017 14:25:30 -0400 Subject: [PATCH 4/4] Added heapchecker default setting to bazel rc and docs --- bazel/README.md | 12 ++++++++++++ ci/build_setup.sh | 1 - tools/bazel.rc | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/bazel/README.md b/bazel/README.md index 227c87c9312a6..5817d9cd42555 100644 --- a/bazel/README.md +++ b/bazel/README.md @@ -100,6 +100,18 @@ bazel test //test/... --test_env=ENVOY_IP_TEST_VERSIONS=v4only bazel test //test/... --test_env=ENVOY_IP_TEST_VERSIONS=v6only ``` +By default, tests are run with the [gperftools](https://github.com/gperftools/gperftools) heap +checker enabled in "normal" mode to detect leaks. For other mode options, see the gperftools +heap checker [documentation](https://gperftools.github.io/gperftools/heap_checker.html). To +disable the heap checker or change the mode, set the HEAPCHECK environment variable: + +``` +# Disables the heap checker +bazel test //test/... --test_env=HEAPCHECK= +# Changes the heap checker to "minimal" mode +bazel test //test/... --test_env=HEAPCHECK=minimal +``` + Bazel will by default cache successful test results. To force it to rerun tests: ``` diff --git a/ci/build_setup.sh b/ci/build_setup.sh index ece8a76234503..ed30c98358a81 100755 --- a/ci/build_setup.sh +++ b/ci/build_setup.sh @@ -4,7 +4,6 @@ set -e -export HEAPCHECK=normal export PPROF_PATH=/thirdparty_build/bin/pprof NUM_CPUS=`grep -c ^processor /proc/cpuinfo` diff --git a/tools/bazel.rc b/tools/bazel.rc index 81c4a9bf0b43a..c8ecbbeb5c546 100644 --- a/tools/bazel.rc +++ b/tools/bazel.rc @@ -40,4 +40,4 @@ build:clang-msan --define tcmalloc=disabled build:clang-msan --copt -fsanitize-memory-track-origins=2 # Test options -test --test_env=HEAPCHECK --test_env=PPROF_PATH +test --test_env=HEAPCHECK=normal --test_env=PPROF_PATH