From f90e9fcfc3067cc9349d958acc84ab90753f0c51 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Thu, 11 Jul 2019 10:51:42 +0000 Subject: [PATCH 01/10] coverage: use LLVM coverage Signed-off-by: Lizan Zhou --- bazel/BUILD | 5 +++ bazel/envoy_binary.bzl | 6 ++++ bazel/envoy_library.bzl | 8 ++++- bazel/envoy_test.bzl | 6 ++++ ci/do_ci.sh | 18 ++-------- test/coverage/lcov_fix_filename.py | 13 +++++++ test/run_envoy_bazel_coverage.sh | 8 ++--- test/run_envoy_bazel_llvm_coverage.sh | 51 +++++++++++++++++++++++++++ 8 files changed, 94 insertions(+), 21 deletions(-) create mode 100755 test/coverage/lcov_fix_filename.py create mode 100755 test/run_envoy_bazel_llvm_coverage.sh diff --git a/bazel/BUILD b/bazel/BUILD index c288f351054fd..3964708254862 100755 --- a/bazel/BUILD +++ b/bazel/BUILD @@ -85,6 +85,11 @@ config_setting( values = {"define": "ENVOY_CONFIG_COVERAGE=1"}, ) +config_setting( + name = "coverage_llvm_build", + values = {"define": "ENVOY_CONFIG_COVERAGE=llvm"}, +) + config_setting( name = "disable_tcmalloc", values = {"define": "tcmalloc=disabled"}, diff --git a/bazel/envoy_binary.bzl b/bazel/envoy_binary.bzl index a7a369e8c16be..68f35a6479c09 100644 --- a/bazel/envoy_binary.bzl +++ b/bazel/envoy_binary.bzl @@ -67,6 +67,12 @@ def _envoy_linkopts(): "-ldl", "-Wl,--hash-style=gnu", ], + }) + select({ + "//bazel:coverage_llvm_build": [ + "-fprofile-instr-generate", + "-fcoverage-mapping", + ], + "//conditions:default": [], }) + envoy_static_link_libstdcpp_linkopts() + \ _envoy_select_exported_symbols(["-Wl,-E"]) diff --git a/bazel/envoy_library.bzl b/bazel/envoy_library.bzl index 33e9e93fc0491..cc3f00755a014 100644 --- a/bazel/envoy_library.bzl +++ b/bazel/envoy_library.bzl @@ -47,7 +47,13 @@ def envoy_cc_library( name = name, srcs = srcs, hdrs = hdrs, - copts = envoy_copts(repository) + copts, + copts = envoy_copts(repository) + copts + select({ + repository + "//bazel:coverage_llvm_build": [ + "-fprofile-instr-generate", + "-fcoverage-mapping", + ], + "//conditions:default": [], + }), visibility = visibility, tags = tags, textual_hdrs = textual_hdrs, diff --git a/bazel/envoy_test.bzl b/bazel/envoy_test.bzl index ea564d619fa83..b521feb29eae7 100644 --- a/bazel/envoy_test.bzl +++ b/bazel/envoy_test.bzl @@ -60,6 +60,12 @@ def _envoy_test_linkopts(): # TODO(mattklein123): It's not great that we universally link against the following libs. # In particular, -latomic and -lrt are not needed on all platforms. Make this more granular. "//conditions:default": ["-pthread", "-lrt", "-ldl"], + }) + select({ + "@envoy//bazel:coverage_llvm_build": [ + "-fprofile-instr-generate", + "-fcoverage-mapping", + ], + "//conditions:default": [], }) + envoy_select_force_libcpp([], ["-lstdc++fs", "-latomic"]) # Envoy C++ fuzz test targets. These are not included in coverage runs. diff --git a/ci/do_ci.sh b/ci/do_ci.sh index ec4d05496390f..c0541e87a5f69 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -241,24 +241,10 @@ elif [[ "$CI_TARGET" == "bazel.api" ]]; then @envoy_api//tools:tap2pcap_test exit 0 elif [[ "$CI_TARGET" == "bazel.coverage" ]]; then - setup_gcc_toolchain + setup_clang_toolchain echo "bazel coverage build with tests ${TEST_TARGETS}" - # gcovr is a pain to run with `bazel run`, so package it up into a - # relocatable and hermetic-ish .par file. - bazel build --python_version=PY2 @com_github_gcovr_gcovr//:gcovr.par - export GCOVR="/tmp/gcovr.par" - cp -f "${ENVOY_SRCDIR}/bazel-bin/external/com_github_gcovr_gcovr/gcovr.par" ${GCOVR} - - # Reduce the amount of memory and number of cores Bazel tries to use to - # prevent it from launching too many subprocesses. This should prevent the - # system from running out of memory and killing tasks. See discussion on - # https://github.com/envoyproxy/envoy/pull/5611. - # TODO(akonradi): use --local_cpu_resources flag once Bazel has a release - # after 0.21. - [ -z "$CIRCLECI" ] || export BAZEL_BUILD_OPTIONS="${BAZEL_BUILD_OPTIONS} --local_resources=12288,4,1" - - test/run_envoy_bazel_coverage.sh ${TEST_TARGETS} + test/run_envoy_bazel_llvm_coverage.sh ${TEST_TARGETS} collect_build_profile coverage exit 0 elif [[ "$CI_TARGET" == "bazel.clang_tidy" ]]; then diff --git a/test/coverage/lcov_fix_filename.py b/test/coverage/lcov_fix_filename.py new file mode 100755 index 0000000000000..58b4cfaf678be --- /dev/null +++ b/test/coverage/lcov_fix_filename.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 + +import sys +import os.path + +while True: + line = sys.stdin.readline() + if not line: + break + if line.startswith("SF:"): + filename = line[3:-1] + line = "SF:" + os.path.relpath(os.path.realpath(filename)) + "\n" + sys.stdout.write(line) diff --git a/test/run_envoy_bazel_coverage.sh b/test/run_envoy_bazel_coverage.sh index 12632254f1f46..02a116decaead 100755 --- a/test/run_envoy_bazel_coverage.sh +++ b/test/run_envoy_bazel_coverage.sh @@ -77,8 +77,8 @@ BAZEL_BUILD_OPTIONS="${BAZEL_BUILD_OPTIONS} -c dbg --copt=-DNDEBUG" # stats. The #foo# pattern is because gcov produces files such as # bazel-out#local-fastbuild#bin#external#spdlog_git#_virtual_includes#spdlog#spdlog#details#pattern_formatter_impl.h.gcov. # To find these while modifying this regex, perform a gcov run with -k set. -[[ -z "${GCOVR_EXCLUDE_REGEX}" ]] && GCOVR_EXCLUDE_REGEX=".*pb.h.gcov|.*#k8-dbg#bin#.*|test#.*|external#.*|.*#external#.*|.*#prebuilt#.*|.*#config_validation#.*|.*#chromium_url#.*" -[[ -z "${GCOVR_EXCLUDE_DIR}" ]] && GCOVR_EXCLUDE_DIR=".*/external/.*" +[[ -z "${LCOV_EXCLUDE_REGEX}" ]] && LCOV_EXCLUDE_REGEX=".*pb.h.gcov|.*#k8-dbg#bin#.*|test#.*|external#.*|.*#external#.*|.*#prebuilt#.*|.*#config_validation#.*|.*#chromium_url#.*" +[[ -z "${LCOV_EXCLUDE_DIR}" ]] && LCOV_EXCLUDE_DIR=".*/external/.*" COVERAGE_DIR="${SRCDIR}"/generated/coverage mkdir -p "${COVERAGE_DIR}" @@ -100,8 +100,8 @@ echo "OK: copied ${NUM_GCNO_FILES} .gcno files" # original source are relative to its execution location. cd -P "${GCOVR_DIR}" echo "Running gcovr in $(pwd)..." -time "${GCOVR}" -v --gcov-exclude="${GCOVR_EXCLUDE_REGEX}" \ - --exclude-directories="${GCOVR_EXCLUDE_DIR}" -r . \ +time "${GCOVR}" -v --gcov-exclude="${LCOV_EXCLUDE_REGEX}" \ + --exclude-directories="${LCOV_EXCLUDE_DIR}" -r . \ --html --html-details --exclude-unreachable-branches --print-summary \ -o "${COVERAGE_DIR}"/coverage.html > "${COVERAGE_SUMMARY}" diff --git a/test/run_envoy_bazel_llvm_coverage.sh b/test/run_envoy_bazel_llvm_coverage.sh new file mode 100755 index 0000000000000..47aac74e038a4 --- /dev/null +++ b/test/run_envoy_bazel_llvm_coverage.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +set -e + +[[ -z "${SRCDIR}" ]] && SRCDIR="${PWD}" +[[ -z "${BAZEL_COVERAGE}" ]] && BAZEL_COVERAGE=bazel +[[ -z "${WORKSPACE}" ]] && WORKSPACE=envoy + +echo "Starting run_envoy_bazel_coverage.sh..." +echo " PWD=$(pwd)" +echo " SRCDIR=${SRCDIR}" +echo " GCOVR_DIR=${GCOVR_DIR}" +echo " TESTLOGS_DIR=${TESTLOGS_DIR}" +echo " BAZEL_COVERAGE=${BAZEL_COVERAGE}" +echo " GCOVR=${GCOVR}" +echo " WORKSPACE=${WORKSPACE}" +echo " VALIDATE_COVERAGE=${VALIDATE_COVERAGE}" + +# This is the target that will be run to generate coverage data. It can be overridden by consumer +# projects that want to run coverage on a different/combined target. +[[ -z "${COVERAGE_TARGET}" ]] && COVERAGE_TARGET="//test/..." + +rm -rf $(find -L bazel-bin -name "test-*.profraw") + +"${BAZEL_COVERAGE}" test "${COVERAGE_TARGET}" ${BAZEL_TEST_OPTIONS} -c dbg --copt=-DNDEBUG \ + --cache_test_results=no --define ENVOY_CONFIG_COVERAGE=llvm --test_output=all \ + --strategy=Genrule=local --strategy=TestRunner=local \ + --test_filter='-QuicPlatformTest.QuicStackTraceTest:IpVersions/ClusterMemoryTestRunner.*' \ + --test_env=LLVM_PROFILE_FILE=test-%p.profraw + +COVERAGE_DIR="${SRCDIR}"/generated/coverage +mkdir -p "${COVERAGE_DIR}" + +echo "Merging profile data..." +llvm-profdata merge -sparse $(find -L bazel-bin -name "test-*.profraw") -o ${COVERAGE_DIR}/coverage.profdata + +echo "Generating report..." +llvm-cov show bazel-bin/source/exe/envoy-static -instr-profile=${COVERAGE_DIR}/coverage.profdata \ + -ignore-filename-regex='(/external/|/k8-dbg/bin/|/chromium_url/)' -output-dir=${COVERAGE_DIR}/llvm-cov -format=html +sed -i -e 's|>bazel-out/[^/]*/bin/\([^/]*\)/[^<]*/_virtual_includes/[^/]*|>\1|g' "${COVERAGE_DIR}/llvm-cov/index.html" + +echo "Generating lcov report..." +llvm-cov export bazel-bin/source/exe/envoy-static -instr-profile=${COVERAGE_DIR}/coverage.profdata \ + -ignore-filename-regex='(/external/|/k8-dbg/bin/|/chromium_url/)' -format=lcov | \ + test/coverage/lcov_fix_filename.py > ${COVERAGE_DIR}/envoy.lcov + +echo "Generating HTML report from lcov..." +genhtml ${COVERAGE_DIR}/envoy.lcov --output-directory=${COVERAGE_DIR}/lcov + + +[[ -z "${ENVOY_COVERAGE_DIR}" ]] || rsync -av "${COVERAGE_DIR}"/ "${ENVOY_COVERAGE_DIR}" From 78747812dd7842090358e697ddbe98101bdb8a7a Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Thu, 11 Jul 2019 19:31:39 +0000 Subject: [PATCH 02/10] format Signed-off-by: Lizan Zhou --- test/coverage/lcov_fix_filename.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/coverage/lcov_fix_filename.py b/test/coverage/lcov_fix_filename.py index 58b4cfaf678be..7eaf5eda0ed27 100755 --- a/test/coverage/lcov_fix_filename.py +++ b/test/coverage/lcov_fix_filename.py @@ -4,10 +4,10 @@ import os.path while True: - line = sys.stdin.readline() - if not line: - break - if line.startswith("SF:"): - filename = line[3:-1] - line = "SF:" + os.path.relpath(os.path.realpath(filename)) + "\n" - sys.stdout.write(line) + line = sys.stdin.readline() + if not line: + break + if line.startswith("SF:"): + filename = line[3:-1] + line = "SF:" + os.path.relpath(os.path.realpath(filename)) + "\n" + sys.stdout.write(line) From fe04f99bf109813ea12bcffc454d5123b71b8730 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Thu, 11 Jul 2019 19:41:57 +0000 Subject: [PATCH 03/10] fastbuild Signed-off-by: Lizan Zhou --- test/run_envoy_bazel_llvm_coverage.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/run_envoy_bazel_llvm_coverage.sh b/test/run_envoy_bazel_llvm_coverage.sh index 47aac74e038a4..8bb78ef154e09 100755 --- a/test/run_envoy_bazel_llvm_coverage.sh +++ b/test/run_envoy_bazel_llvm_coverage.sh @@ -22,7 +22,7 @@ echo " VALIDATE_COVERAGE=${VALIDATE_COVERAGE}" rm -rf $(find -L bazel-bin -name "test-*.profraw") -"${BAZEL_COVERAGE}" test "${COVERAGE_TARGET}" ${BAZEL_TEST_OPTIONS} -c dbg --copt=-DNDEBUG \ +"${BAZEL_COVERAGE}" test "${COVERAGE_TARGET}" ${BAZEL_TEST_OPTIONS} -c fastbuild --copt=-DNDEBUG \ --cache_test_results=no --define ENVOY_CONFIG_COVERAGE=llvm --test_output=all \ --strategy=Genrule=local --strategy=TestRunner=local \ --test_filter='-QuicPlatformTest.QuicStackTraceTest:IpVersions/ClusterMemoryTestRunner.*' \ @@ -36,12 +36,12 @@ llvm-profdata merge -sparse $(find -L bazel-bin -name "test-*.profraw") -o ${COV echo "Generating report..." llvm-cov show bazel-bin/source/exe/envoy-static -instr-profile=${COVERAGE_DIR}/coverage.profdata \ - -ignore-filename-regex='(/external/|/k8-dbg/bin/|/chromium_url/)' -output-dir=${COVERAGE_DIR}/llvm-cov -format=html + -ignore-filename-regex='(/external/|/k8-fastbuild/bin/|/chromium_url/)' -output-dir=${COVERAGE_DIR}/llvm-cov -format=html sed -i -e 's|>bazel-out/[^/]*/bin/\([^/]*\)/[^<]*/_virtual_includes/[^/]*|>\1|g' "${COVERAGE_DIR}/llvm-cov/index.html" echo "Generating lcov report..." llvm-cov export bazel-bin/source/exe/envoy-static -instr-profile=${COVERAGE_DIR}/coverage.profdata \ - -ignore-filename-regex='(/external/|/k8-dbg/bin/|/chromium_url/)' -format=lcov | \ + -ignore-filename-regex='(/external/|/k8-fastbuild/bin/|/chromium_url/)' -format=lcov | \ test/coverage/lcov_fix_filename.py > ${COVERAGE_DIR}/envoy.lcov echo "Generating HTML report from lcov..." From 06aba8a34a4ba9b991cd62f4428bad1436dc9636 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Thu, 11 Jul 2019 20:09:18 +0000 Subject: [PATCH 04/10] memory hog Signed-off-by: Lizan Zhou --- ci/do_ci.sh | 3 +++ test/run_envoy_bazel_llvm_coverage.sh | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ci/do_ci.sh b/ci/do_ci.sh index c0541e87a5f69..877bc252188ec 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -244,6 +244,9 @@ elif [[ "$CI_TARGET" == "bazel.coverage" ]]; then setup_clang_toolchain echo "bazel coverage build with tests ${TEST_TARGETS}" + # LLVM coverage is a memory hog too. + [ -z "$CIRCLECI" ] || export BAZEL_BUILD_OPTIONS="${BAZEL_BUILD_OPTIONS} --local_cpu_resources=6" + test/run_envoy_bazel_llvm_coverage.sh ${TEST_TARGETS} collect_build_profile coverage exit 0 diff --git a/test/run_envoy_bazel_llvm_coverage.sh b/test/run_envoy_bazel_llvm_coverage.sh index 8bb78ef154e09..35dad07b5f41f 100755 --- a/test/run_envoy_bazel_llvm_coverage.sh +++ b/test/run_envoy_bazel_llvm_coverage.sh @@ -22,9 +22,8 @@ echo " VALIDATE_COVERAGE=${VALIDATE_COVERAGE}" rm -rf $(find -L bazel-bin -name "test-*.profraw") -"${BAZEL_COVERAGE}" test "${COVERAGE_TARGET}" ${BAZEL_TEST_OPTIONS} -c fastbuild --copt=-DNDEBUG \ - --cache_test_results=no --define ENVOY_CONFIG_COVERAGE=llvm --test_output=all \ - --strategy=Genrule=local --strategy=TestRunner=local \ +"${BAZEL_COVERAGE}" test "${COVERAGE_TARGET}" ${BAZEL_BUILD_OPTIONS} -c fastbuild --copt=-DNDEBUG \ + --cache_test_results=no --define ENVOY_CONFIG_COVERAGE=llvm --test_output=all --strategy=TestRunner=local \ --test_filter='-QuicPlatformTest.QuicStackTraceTest:IpVersions/ClusterMemoryTestRunner.*' \ --test_env=LLVM_PROFILE_FILE=test-%p.profraw From 34885f39c91eb50986f126dd2e5938b5a37ac55f Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Thu, 11 Jul 2019 21:20:13 +0000 Subject: [PATCH 05/10] no lcov report Signed-off-by: Lizan Zhou --- test/coverage/lcov_fix_filename.py | 13 ------------- test/run_envoy_bazel_llvm_coverage.sh | 27 ++++++++++----------------- 2 files changed, 10 insertions(+), 30 deletions(-) delete mode 100755 test/coverage/lcov_fix_filename.py diff --git a/test/coverage/lcov_fix_filename.py b/test/coverage/lcov_fix_filename.py deleted file mode 100755 index 7eaf5eda0ed27..0000000000000 --- a/test/coverage/lcov_fix_filename.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import os.path - -while True: - line = sys.stdin.readline() - if not line: - break - if line.startswith("SF:"): - filename = line[3:-1] - line = "SF:" + os.path.relpath(os.path.realpath(filename)) + "\n" - sys.stdout.write(line) diff --git a/test/run_envoy_bazel_llvm_coverage.sh b/test/run_envoy_bazel_llvm_coverage.sh index 35dad07b5f41f..009b4a9423c2d 100755 --- a/test/run_envoy_bazel_llvm_coverage.sh +++ b/test/run_envoy_bazel_llvm_coverage.sh @@ -4,21 +4,23 @@ set -e [[ -z "${SRCDIR}" ]] && SRCDIR="${PWD}" [[ -z "${BAZEL_COVERAGE}" ]] && BAZEL_COVERAGE=bazel -[[ -z "${WORKSPACE}" ]] && WORKSPACE=envoy echo "Starting run_envoy_bazel_coverage.sh..." echo " PWD=$(pwd)" echo " SRCDIR=${SRCDIR}" -echo " GCOVR_DIR=${GCOVR_DIR}" -echo " TESTLOGS_DIR=${TESTLOGS_DIR}" echo " BAZEL_COVERAGE=${BAZEL_COVERAGE}" -echo " GCOVR=${GCOVR}" -echo " WORKSPACE=${WORKSPACE}" echo " VALIDATE_COVERAGE=${VALIDATE_COVERAGE}" # This is the target that will be run to generate coverage data. It can be overridden by consumer # projects that want to run coverage on a different/combined target. -[[ -z "${COVERAGE_TARGET}" ]] && COVERAGE_TARGET="//test/..." +# Command-line arguments take precedence over ${COVERAGE_TARGET}. +if [[ $# -gt 0 ]]; then + COVERAGE_TARGETS=$* +elif [[ -n "${COVERAGE_TARGET}" ]]; then + COVERAGE_TARGETS=${COVERAGE_TARGET} +else + COVERAGE_TARGETS=//test/... +fi rm -rf $(find -L bazel-bin -name "test-*.profraw") @@ -35,16 +37,7 @@ llvm-profdata merge -sparse $(find -L bazel-bin -name "test-*.profraw") -o ${COV echo "Generating report..." llvm-cov show bazel-bin/source/exe/envoy-static -instr-profile=${COVERAGE_DIR}/coverage.profdata \ - -ignore-filename-regex='(/external/|/k8-fastbuild/bin/|/chromium_url/)' -output-dir=${COVERAGE_DIR}/llvm-cov -format=html -sed -i -e 's|>bazel-out/[^/]*/bin/\([^/]*\)/[^<]*/_virtual_includes/[^/]*|>\1|g' "${COVERAGE_DIR}/llvm-cov/index.html" - -echo "Generating lcov report..." -llvm-cov export bazel-bin/source/exe/envoy-static -instr-profile=${COVERAGE_DIR}/coverage.profdata \ - -ignore-filename-regex='(/external/|/k8-fastbuild/bin/|/chromium_url/)' -format=lcov | \ - test/coverage/lcov_fix_filename.py > ${COVERAGE_DIR}/envoy.lcov - -echo "Generating HTML report from lcov..." -genhtml ${COVERAGE_DIR}/envoy.lcov --output-directory=${COVERAGE_DIR}/lcov - + -ignore-filename-regex='(/external/|/k8-fastbuild/bin/|/chromium_url/)' -output-dir=${COVERAGE_DIR} -format=html +sed -i -e 's|>bazel-out/[^/]*/bin/\([^/]*\)/[^<]*/_virtual_includes/[^/]*|>\1|g' "${COVERAGE_DIR}/index.html" [[ -z "${ENVOY_COVERAGE_DIR}" ]] || rsync -av "${COVERAGE_DIR}"/ "${ENVOY_COVERAGE_DIR}" From 7d6bab7c3539462c575a468901c6bd666738e63d Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Thu, 11 Jul 2019 21:56:53 +0000 Subject: [PATCH 06/10] typo Signed-off-by: Lizan Zhou --- test/run_envoy_bazel_llvm_coverage.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/run_envoy_bazel_llvm_coverage.sh b/test/run_envoy_bazel_llvm_coverage.sh index 009b4a9423c2d..85ed19a4d5537 100755 --- a/test/run_envoy_bazel_llvm_coverage.sh +++ b/test/run_envoy_bazel_llvm_coverage.sh @@ -24,7 +24,7 @@ fi rm -rf $(find -L bazel-bin -name "test-*.profraw") -"${BAZEL_COVERAGE}" test "${COVERAGE_TARGET}" ${BAZEL_BUILD_OPTIONS} -c fastbuild --copt=-DNDEBUG \ +"${BAZEL_COVERAGE}" test "${COVERAGE_TARGETS}" ${BAZEL_BUILD_OPTIONS} -c fastbuild --copt=-DNDEBUG \ --cache_test_results=no --define ENVOY_CONFIG_COVERAGE=llvm --test_output=all --strategy=TestRunner=local \ --test_filter='-QuicPlatformTest.QuicStackTraceTest:IpVersions/ClusterMemoryTestRunner.*' \ --test_env=LLVM_PROFILE_FILE=test-%p.profraw From 8e4a01cf6b49eed2c7360629be3959cc02c95b86 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Thu, 11 Jul 2019 22:43:59 +0000 Subject: [PATCH 07/10] headers back Signed-off-by: Lizan Zhou --- test/run_envoy_bazel_llvm_coverage.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/run_envoy_bazel_llvm_coverage.sh b/test/run_envoy_bazel_llvm_coverage.sh index 85ed19a4d5537..9dc56ea8554d5 100755 --- a/test/run_envoy_bazel_llvm_coverage.sh +++ b/test/run_envoy_bazel_llvm_coverage.sh @@ -37,7 +37,7 @@ llvm-profdata merge -sparse $(find -L bazel-bin -name "test-*.profraw") -o ${COV echo "Generating report..." llvm-cov show bazel-bin/source/exe/envoy-static -instr-profile=${COVERAGE_DIR}/coverage.profdata \ - -ignore-filename-regex='(/external/|/k8-fastbuild/bin/|/chromium_url/)' -output-dir=${COVERAGE_DIR} -format=html + -ignore-filename-regex='(/external/|pb\.(validate\.)?(h|cc)|/chromium_url/)' -output-dir=${COVERAGE_DIR} -format=html sed -i -e 's|>bazel-out/[^/]*/bin/\([^/]*\)/[^<]*/_virtual_includes/[^/]*|>\1|g' "${COVERAGE_DIR}/index.html" [[ -z "${ENVOY_COVERAGE_DIR}" ]] || rsync -av "${COVERAGE_DIR}"/ "${ENVOY_COVERAGE_DIR}" From 0e997797895719eac691ce83493c37b8183a4331 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Thu, 11 Jul 2019 22:45:07 +0000 Subject: [PATCH 08/10] revert Signed-off-by: Lizan Zhou --- test/run_envoy_bazel_coverage.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/run_envoy_bazel_coverage.sh b/test/run_envoy_bazel_coverage.sh index 02a116decaead..12632254f1f46 100755 --- a/test/run_envoy_bazel_coverage.sh +++ b/test/run_envoy_bazel_coverage.sh @@ -77,8 +77,8 @@ BAZEL_BUILD_OPTIONS="${BAZEL_BUILD_OPTIONS} -c dbg --copt=-DNDEBUG" # stats. The #foo# pattern is because gcov produces files such as # bazel-out#local-fastbuild#bin#external#spdlog_git#_virtual_includes#spdlog#spdlog#details#pattern_formatter_impl.h.gcov. # To find these while modifying this regex, perform a gcov run with -k set. -[[ -z "${LCOV_EXCLUDE_REGEX}" ]] && LCOV_EXCLUDE_REGEX=".*pb.h.gcov|.*#k8-dbg#bin#.*|test#.*|external#.*|.*#external#.*|.*#prebuilt#.*|.*#config_validation#.*|.*#chromium_url#.*" -[[ -z "${LCOV_EXCLUDE_DIR}" ]] && LCOV_EXCLUDE_DIR=".*/external/.*" +[[ -z "${GCOVR_EXCLUDE_REGEX}" ]] && GCOVR_EXCLUDE_REGEX=".*pb.h.gcov|.*#k8-dbg#bin#.*|test#.*|external#.*|.*#external#.*|.*#prebuilt#.*|.*#config_validation#.*|.*#chromium_url#.*" +[[ -z "${GCOVR_EXCLUDE_DIR}" ]] && GCOVR_EXCLUDE_DIR=".*/external/.*" COVERAGE_DIR="${SRCDIR}"/generated/coverage mkdir -p "${COVERAGE_DIR}" @@ -100,8 +100,8 @@ echo "OK: copied ${NUM_GCNO_FILES} .gcno files" # original source are relative to its execution location. cd -P "${GCOVR_DIR}" echo "Running gcovr in $(pwd)..." -time "${GCOVR}" -v --gcov-exclude="${LCOV_EXCLUDE_REGEX}" \ - --exclude-directories="${LCOV_EXCLUDE_DIR}" -r . \ +time "${GCOVR}" -v --gcov-exclude="${GCOVR_EXCLUDE_REGEX}" \ + --exclude-directories="${GCOVR_EXCLUDE_DIR}" -r . \ --html --html-details --exclude-unreachable-branches --print-summary \ -o "${COVERAGE_DIR}"/coverage.html > "${COVERAGE_SUMMARY}" From de1e087fb6073563209a4d640c9e19e1c0054c28 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Fri, 12 Jul 2019 01:03:33 +0000 Subject: [PATCH 09/10] ci_fix Signed-off-by: Lizan Zhou --- bazel/envoy_binary.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bazel/envoy_binary.bzl b/bazel/envoy_binary.bzl index 68f35a6479c09..27ac5f6a5ea5e 100644 --- a/bazel/envoy_binary.bzl +++ b/bazel/envoy_binary.bzl @@ -68,7 +68,7 @@ def _envoy_linkopts(): "-Wl,--hash-style=gnu", ], }) + select({ - "//bazel:coverage_llvm_build": [ + "@envoy//bazel:coverage_llvm_build": [ "-fprofile-instr-generate", "-fcoverage-mapping", ], From 9d635c545ce89c4cf45f0b76f2ffc093572edc45 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Fri, 12 Jul 2019 18:41:07 +0000 Subject: [PATCH 10/10] more coverage Signed-off-by: Lizan Zhou --- test/run_envoy_bazel_llvm_coverage.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/run_envoy_bazel_llvm_coverage.sh b/test/run_envoy_bazel_llvm_coverage.sh index 9dc56ea8554d5..26b68b1e90b17 100755 --- a/test/run_envoy_bazel_llvm_coverage.sh +++ b/test/run_envoy_bazel_llvm_coverage.sh @@ -19,15 +19,15 @@ if [[ $# -gt 0 ]]; then elif [[ -n "${COVERAGE_TARGET}" ]]; then COVERAGE_TARGETS=${COVERAGE_TARGET} else - COVERAGE_TARGETS=//test/... + COVERAGE_TARGETS="//test/... @com_googlesource_quiche//:all" fi rm -rf $(find -L bazel-bin -name "test-*.profraw") "${BAZEL_COVERAGE}" test "${COVERAGE_TARGETS}" ${BAZEL_BUILD_OPTIONS} -c fastbuild --copt=-DNDEBUG \ - --cache_test_results=no --define ENVOY_CONFIG_COVERAGE=llvm --test_output=all --strategy=TestRunner=local \ - --test_filter='-QuicPlatformTest.QuicStackTraceTest:IpVersions/ClusterMemoryTestRunner.*' \ - --test_env=LLVM_PROFILE_FILE=test-%p.profraw + --cache_test_results=no --define ENVOY_CONFIG_COVERAGE=llvm --cxxopt="-DENVOY_CONFIG_COVERAGE=1" \ + --test_output=all --strategy=TestRunner=local --test_filter='-QuicPlatformTest.QuicStackTraceTest' \ + --test_env=LLVM_PROFILE_FILE=test-%p.profraw --test_arg="--log-path /dev/null" --test_arg="-l trace" COVERAGE_DIR="${SRCDIR}"/generated/coverage mkdir -p "${COVERAGE_DIR}"