From ee871706da1a91a9ca9588562865567e35dcda39 Mon Sep 17 00:00:00 2001 From: Privacy Sandbox Team Date: Thu, 25 Jan 2024 02:19:54 +0000 Subject: [PATCH] Release 0.53.0 (2024-01-25) ### Features * Add support to collect-coverage tool for custom lcov report ### Bug Fixes * Improve --cmd-profiler support Bug: N/A Change-Id: I53e847f14e4bff5224b537364b8da5939d328085 GitOrigin-RevId: c9923c9eec318b465b176a64714dcc5503db3509 --- CHANGELOG.md | 12 ++++++++ images/build-debian/install_apps | 1 + tests/data/hashes/build-debian | 2 +- tools/cbuild | 29 +++++++++++++----- tools/collect-coverage | 50 ++++++++++++++++++++++++++------ version.txt | 2 +- 6 files changed, 77 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d64a03..4ab43b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,18 @@ All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines. +## 0.53.0 (2024-01-25) + + +### Features + +* Add support to collect-coverage tool for custom lcov report + + +### Bug Fixes + +* Improve --cmd-profiler support + ## 0.52.0 (2023-12-02) diff --git a/images/build-debian/install_apps b/images/build-debian/install_apps index 3d76489..8734f01 100755 --- a/images/build-debian/install_apps +++ b/images/build-debian/install_apps @@ -74,6 +74,7 @@ function install_misc() { gettext="0.19.*" \ git="1:2.25.*" \ gnupg="2.2.*" \ + google-perftools="2.*" \ locales="2.31-*" \ lsb-release="11.1.*" \ openssh-client="1:8.2*" \ diff --git a/tests/data/hashes/build-debian b/tests/data/hashes/build-debian index 77b86a4..0e9a76c 100644 --- a/tests/data/hashes/build-debian +++ b/tests/data/hashes/build-debian @@ -1 +1 @@ -5d35b75b008dc13b64cfdd3e9f49ff8b77a6fb8f7851d653b17c078214299c08 +a99a8af64d61e3eb635aecfb81d229437890693cd6f6d33bd269e9f1c55ca760 diff --git a/tools/cbuild b/tools/cbuild index f0e4255..6a3f5e1 100755 --- a/tools/cbuild +++ b/tools/cbuild @@ -134,13 +134,6 @@ if ! [[ " ${IMAGE_LIST[*]} " =~ " ${IMAGE} " ]]; then usage 1 fi -if [[ ${WITH_CMD_PROFILER} -eq 1 ]]; then - if [[ ${IMAGE} != build-debian ]]; then - printf "error: --cmd-profiler is only compatible with build-debian\n" &>/dev/stderr - usage 1 - fi - CMD_PROFILER="LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libprofiler.so " -fi TOOLS_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" readonly TOOLS_DIR # shellcheck disable=SC1090 @@ -160,6 +153,9 @@ if [[ ${VERBOSE} -eq 1 ]]; then printf "mounting workspace into container: %s\n" "${WORKSPACE_MOUNT}" &>/dev/stderr fi +TOOLS_RELDIR="$(realpath "${TOOLS_DIR}" --relative-to="${WORKSPACE}")" +readonly TOOLS_RELDIR + if [[ -n ${CBUILD_IMAGE} ]]; then IMAGE_TAGGED=${CBUILD_IMAGE} else @@ -181,6 +177,17 @@ if [[ ${DOCKER_SECCOMP_UNCONFINED} -eq 1 ]]; then DOCKER_RUN_ARGS+=("--security-opt=seccomp=unconfined") fi +if [[ ${WITH_CMD_PROFILER} -eq 1 ]]; then + if [[ ${IMAGE} != build-debian ]]; then + printf "error: --cmd-profiler is only compatible with build-debian\n" &>/dev/stderr + usage 1 + fi + DOCKER_RUN_ARGS+=( + "--env=CMD_PROFILER=LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libprofiler.so" + "--env=CPUPROFILE=benchmark.prof" + ) +fi + # inside the docker build images, /bazel_root is the bazel cache dir, per the system-wide bazelrc readonly BAZEL_ROOT=/bazel_root if [[ ${WITH_SHARED_CACHE} -eq 0 ]]; then @@ -222,10 +229,16 @@ if [[ -z ${CMD} ]]; then ${DOCKER_RUN_ARGS[@]} \ "${IMAGE_TAGGED}" \ --login +elif [[ ${WITH_CMD_PROFILER} -eq 1 ]]; then + # shellcheck disable=SC2068 + docker run \ + ${DOCKER_RUN_ARGS[@]} \ + "${IMAGE_TAGGED}" \ + --login -c "'${TOOLS_RELDIR}'/normalize-bazel-symlinks; env \${CMD_PROFILER} ${CMD}" else # shellcheck disable=SC2068 docker run \ ${DOCKER_RUN_ARGS[@]} \ "${IMAGE_TAGGED}" \ - --login -c "${CMD_PROFILER}${CMD}" + --login -c "'${TOOLS_RELDIR}'/normalize-bazel-symlinks; ${CMD}" fi diff --git a/tools/collect-coverage b/tools/collect-coverage index 2083fbd..746185c 100755 --- a/tools/collect-coverage +++ b/tools/collect-coverage @@ -14,12 +14,50 @@ # See the License for the specific language governing permissions and # limitations under the License. -# environment variables (all optional): +# environment variables: # WORKSPACE Set the path to the workspace (repo root) set -o pipefail set -o errexit +declare LCOV_REPORT="${WORKSPACE}/bazel-out/_coverage/_coverage_report.dat" +declare COVERAGE_FILENAME=coverage.zip + +function usage() { + local exitval=${1-1} + cat &>/dev/stderr << USAGE +usage: + $0 + --lcov_report path to lcov report relative to the WORKSPACE + --coverage_output_filename name of ZIP file that will contain artifacts from coverage collection +USAGE + # shellcheck disable=SC2086 + exit ${exitval} +} + +while [[ $# -gt 0 ]]; do + case "$1" in + --lcov_report) + LCOV_REPORT="${WORKSPACE}/$2" + shift 2 || usage + ;; + --coverage_output_filename) + COVERAGE_FILENAME="$2" + shift 2 || usage + if [[ ${COVERAGE_FILENAME##*.} != zip ]]; then + printf "error: --coverage_output_filename must be a ZIP file\n" &>/dev/stderr + exit 1 + fi + ;; + -h | --help) + usage 0 + ;; + *) + usage + ;; + esac +done + trap _cleanup EXIT function _cleanup() { declare -r -i status=$? @@ -33,10 +71,9 @@ function _cleanup() { function generate_coverage_report() { local -r cov_dir="$(mktemp --tmpdir="${WORKSPACE}" --directory coverage-XXXX)" trap 'rm -rf "${cov_dir}"' RETURN EXIT - local -r cov_dat="${WORKSPACE}/bazel-out/_coverage/_coverage_report.dat" - cp "${cov_dat}" "${cov_dir}" + cp "${LCOV_REPORT}" "${cov_dir}"/_coverage_report.dat local -r dist_dir="${WORKSPACE}"/dist - cp "${cov_dat}" "${dist_dir}" + cp "${LCOV_REPORT}" "${dist_dir}"/_coverage_report.dat chmod -x {"${cov_dir}","${dist_dir}"}/_coverage_report.dat "${TOOLS_DIR}"/lcov --list dist/_coverage_report.dat >"${dist_dir}"/coverage_report.txt @@ -64,10 +101,5 @@ source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/builder.sh TOOLS_DIR="$(builder::get_tools_dir)" readonly TOOLS_DIR -declare COVERAGE_FILENAME="$1" -if [[ ${COVERAGE_FILENAME##*.} != zip ]]; then - COVERAGE_FILENAME=coverage.zip -fi - generate_coverage_report "${TOOLS_DIR}"/normalize-dist diff --git a/version.txt b/version.txt index 655b900..328047e 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.52.0 \ No newline at end of file +0.53.0 \ No newline at end of file