Skip to content

Commit

Permalink
coverage: Use upstream coverage collect script (envoyproxy#28802)
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Northey <ryan@synca.io>
  • Loading branch information
phlax committed Aug 13, 2023
1 parent 5fde158 commit 8004b60
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 188 deletions.
7 changes: 4 additions & 3 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ build --test_env=HEAPCHECK=normal --test_env=PPROF_PATH
# Coverage options
coverage --config=coverage
coverage --build_tests_only

build:coverage --action_env=BAZEL_USE_LLVM_NATIVE_COVERAGE=1
build:coverage --action_env=GCOV=llvm-profdata
build:coverage --copt=-DNDEBUG
Expand All @@ -201,15 +202,15 @@ build:coverage --test_timeout=390,750,1500,5700
build:coverage --define=dynamic_link_tests=true
build:coverage --define=ENVOY_CONFIG_COVERAGE=1
build:coverage --cxxopt="-DENVOY_CONFIG_COVERAGE=1"
build:coverage --coverage_support=@envoy//bazel/coverage:coverage_support
build:coverage --test_env=CC_CODE_COVERAGE_SCRIPT=bazel/coverage/collect_cc_coverage.sh
build:coverage --test_env=HEAPCHECK=
build:coverage --combined_report=lcov
build:coverage --strategy=TestRunner=sandboxed,local
build:coverage --strategy=CoverageReport=sandboxed,local
build:coverage --experimental_use_llvm_covmap
build:coverage --experimental_generate_llvm_lcov
build:coverage --collect_code_coverage
build:coverage --instrumentation_filter="//source(?!/common/quic/platform)[/:],//envoy[/:],//contrib(?!/.*/test)[/:]"
build:coverage --instrumentation_filter="^//source(?!/common/quic/platform)[/:],^//envoy[/:],^//contrib(?!/.*/test)[/:]"
build:coverage --remote_download_toplevel

build:test-coverage --test_arg="-l trace"
build:test-coverage --test_arg="--log-path /dev/null"
Expand Down
6 changes: 0 additions & 6 deletions bazel/coverage/BUILD
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
licenses(["notice"]) # Apache 2

# TODO(lizan): Add test for this and upstream to upstream Bazel.
filegroup(
name = "coverage_support",
srcs = ["collect_cc_coverage.sh"],
)

exports_files(["fuzz_coverage_wrapper.sh"])
175 changes: 0 additions & 175 deletions bazel/coverage/collect_cc_coverage.sh

This file was deleted.

3 changes: 0 additions & 3 deletions mobile/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,7 @@ build:mobile-remote-ci-linux-coverage --strategy=CoverageReport=local,remote
# Bazel remote caching is incompatible with C++ LLVM coverage so we need to deactivate it for coverage builds
# TODO(lfpino): Reference upstream Bazel issue here on the incompatibility of remote caching and LLVM coverage.
build:mobile-remote-ci-linux-coverage --noremote_accept_cached
build:mobile-remote-ci-linux-coverage --remote_download_toplevel
build:mobile-remote-ci-linux-coverage --build_runfile_links
build:mobile-remote-ci-linux-coverage --legacy_important_outputs=false
build:mobile-remote-ci-linux-coverage --test_env=CC_CODE_COVERAGE_SCRIPT=external/envoy/bazel/coverage/collect_cc_coverage.sh
build:mobile-remote-ci-linux-coverage --nocache_test_results
build:mobile-remote-ci-linux-coverage --config=ci
build:mobile-remote-ci-linux-coverage --config=remote
Expand Down
2 changes: 2 additions & 0 deletions test/extensions/tracers/dynamic_ot/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ envoy_package()

envoy_extension_cc_test(
name = "dynamic_opentracing_driver_impl_test",
size = "large",
srcs = [
"dynamic_opentracing_driver_impl_test.cc",
],
Expand All @@ -35,6 +36,7 @@ envoy_extension_cc_test(

envoy_extension_cc_test(
name = "config_test",
size = "large",
srcs = ["config_test.cc"],
data = [
"@io_opentracing_cpp//mocktracer:libmocktracer_plugin.so",
Expand Down
2 changes: 1 addition & 1 deletion test/integration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ envoy_cc_test(
srcs = [
"http2_flood_integration_test.cc",
],
shard_count = 4,
shard_count = 6,
tags = [
"cpu:3",
],
Expand Down
8 changes: 8 additions & 0 deletions test/run_envoy_bazel_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ BAZEL_OUTPUT_BASE="$(bazel "${BAZEL_STARTUP_OPTIONS[@]}" info "${BAZEL_BUILD_OPT
echo "Running bazel coverage with:"
echo " Options: ${BAZEL_BUILD_OPTIONS[*]} ${BAZEL_COVERAGE_OPTIONS[*]}"
echo " Targets: ${COVERAGE_TARGETS[*]}"

bazel "${BAZEL_STARTUP_OPTIONS[@]}" coverage "${BAZEL_BUILD_OPTIONS[@]}" "${BAZEL_COVERAGE_OPTIONS[@]}" "${COVERAGE_TARGETS[@]}"

echo "Collecting profile and testlogs"
Expand All @@ -80,6 +81,9 @@ if [[ -n "${ENVOY_BUILD_PROFILE}" ]]; then
fi

if [[ -n "${ENVOY_BUILD_DIR}" ]]; then
if [[ -e "${ENVOY_BUILD_DIR}/testlogs.tar.zst" ]]; then
rm -f "${ENVOY_BUILD_DIR}/testlogs.tar.zst"
fi
find bazel-testlogs/ -name test.log \
| tar cf - -T - \
| bazel "${BAZEL_STARTUP_OPTIONS[@]}" run "${BAZEL_BUILD_OPTIONS[@]}" //tools/zstd -- \
Expand Down Expand Up @@ -117,6 +121,10 @@ if [[ "${FUZZ_COVERAGE}" == "true" ]]; then
- -T0 -o "${ENVOY_FUZZ_COVERAGE_ARTIFACT}"
fi
elif [[ -n "${ENVOY_COVERAGE_ARTIFACT}" ]]; then
if [[ -e "${ENVOY_COVERAGE_ARTIFACT}" ]]; then
rm "${ENVOY_COVERAGE_ARTIFACT}"
fi

tar cf - -C "${COVERAGE_DIR}" --transform 's/^\./coverage/' . \
| bazel "${BAZEL_STARTUP_OPTIONS[@]}" run "${BAZEL_BUILD_OPTIONS[@]}" //tools/zstd -- \
- -T0 -o "${ENVOY_COVERAGE_ARTIFACT}"
Expand Down
1 change: 1 addition & 0 deletions test/server/config_validation/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ envoy_cc_test_library(

envoy_cc_fuzz_test(
name = "xds_fuzz_test",
size = "large",
srcs = ["xds_fuzz_test.cc"],
corpus = "xds_corpus",
deps = [
Expand Down

0 comments on commit 8004b60

Please sign in to comment.