mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-05 18:20:34 +00:00
831b11e869
One script to run coverage for the whole smoke test suite, the resulting file can be uploaded to codecov.io for consumption: https://codecov.io/gh/denniskempin/crosvm Another script to run tests + coverage for a single crate, which is useful during development to keep track of coverage while adding tests (IDEs can display the generated lcov.info file) BUG=b:171082843 TEST=Manual testing of both scripts Change-Id: I52384762400a146cb0e7deb3d54dccf59b6134db Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2492914 Reviewed-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Dennis Kempin <denniskempin@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Auto-Submit: Dennis Kempin <denniskempin@google.com>
39 lines
1.1 KiB
Bash
Executable file
39 lines
1.1 KiB
Bash
Executable file
#!/bin/bash
|
|
# Copyright 2020 The Chromium OS Authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
#
|
|
# Calculates test coverage of all unit tests in crosvm.
|
|
# Requirements:
|
|
# $ apt install jq
|
|
# $ rustup toolchain install nightly
|
|
# $ cargo install grcov rust-covfix
|
|
set -ex
|
|
cd "${0%/*}/../"
|
|
|
|
target_dir=$(
|
|
cargo metadata --no-deps --format-version 1 |
|
|
jq -r ".target_directory"
|
|
)
|
|
|
|
# Delete old coverage profiles
|
|
find "$target_dir/debug" -name "*.gcda" -delete
|
|
|
|
# Run --all tests with coverage profiling options enabled.
|
|
CARGO_INCREMENTAL=0 \
|
|
RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Coverflow-checks=off \
|
|
-Zpanic_abort_tests" \
|
|
cargo +nightly test \
|
|
--no-fail-fast --features default-no-sandbox,wl-dmabuf,gpu,tpm \
|
|
--all --exclude aarch64 \
|
|
-- \
|
|
--test-threads=1
|
|
|
|
# Calculate code coverage
|
|
grcov "$target_dir/debug" -s . \
|
|
--ignore "/*" --ignore-not-existing \
|
|
-t lcov --llvm --branch \
|
|
-o /tmp/lcov.info
|
|
|
|
# Apply code coverage fixes
|
|
rust-covfix /tmp/lcov.info >lcov.info
|