Commit Graph

22 Commits

Author SHA1 Message Date
Patrick Roy
e94bff4ff5 coverage: make crate_features key optional
Currently, if a crate wishes to run the coverage test with some cargo
features enabled, it must explicitly list them out in the
`crate_features` key of the coverage json files.

Change this so that if this key is omitted from the json file, then
test_coverage.py passes `--all-features` to cargo.

No functional change, as currently `crate_features` is a mandatory key,
so to opt-in to this new behavior, crates must remove this key from
their coverage json file(s).

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
2025-03-19 09:41:19 +00:00
Patrick Roy
1150c47872 fix: report line coverage instead of function coverage
It seems that the raw output of llvm-cov changed at some point, and we
ended upcomparing functoin coverage instead of line coverage. Fix this
by instead using the new json output, which will hopefully prevent such
goofs in the future.

Fixes #170
Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
2024-10-23 09:07:13 +00:00
Stefano Garzarella
cf9809721d test_coverage: calculate the difference in reverse
If we increase the coverage the message prints a negative value
as the difference from the previous value. This can be confusing
as it looks like the coverage has decreased.

For example if the value in coverage_config_x86_64.json is 73.42,
and the new coverage is 73.96 (increased), we have the following
error:

    ValueError: Current code coverage (73.96%) deviates by -0.54%
    from the previous code co...

Let's calculate the difference in reverse so that we have a
negative value if it decreases and positive otherwise.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2023-11-03 15:43:00 +00:00
Stefano Garzarella
be28ad8e2c test_coverage: fix formatting of --ignore-filename-regex
`black` suggests putting the string between single quotes so
there is no need to escape double quotes.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2023-10-24 09:06:08 +02:00
Stefano Garzarella
9699b4dfe3 test_coverage: put exclude_path value between double quotes
We don't want the shell to interpret the contents of exclude_path,
but we want it all used as a single string for `--ignore-filename-regex`,
so let's put it between double quotes.

An example of failure is when we have | , as in this case:

  $ CARGO_TARGET_DIR=./cov_build cargo llvm-cov test --summary-only \
      --ignore-filename-regex crates/virtio-bindings|crates/virtio-queue/src/mock.rs \
      --workspace  --features=virtio-blk/backend-stdio
  bash: crates/virtio-queue/src/mock.rs: Permission denied
  ...
  error: failed to generate report: process didn't exit successfully: ...
  (exit status: 74)

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2023-10-20 16:06:54 +00:00
Stefano Garzarella
b6483ebe81 test_coverage.py: fix formatting
CI is failing since `black` suggests some reformatting.
Let's apply them.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2023-10-20 15:59:46 +00:00
Patrick Roy
412ecd55f0 Have coverage test use llvm-cov instead of cargo-kcov
cargo-kcov is broken on rust versions >=1.71.0. This is currently
blocking us from upgrading to the new toolchain version (1.72.0), which
is required to compile linux-loader (due to one dependency having a MSRV
policy of "N-2", meaning our current toolchain is no longer supported).

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
2023-09-01 10:21:56 +00:00
Stefano Garzarella
9dfe5b267c Use derivatives of BaseException for exceptions
When the coverage changes, we raise exceptions with simple strings,
this causes the following error:

    TypeError: exceptions must derive from BaseException

Let's use derivatives of BaseException to fix this issue.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2023-06-28 12:44:28 +01:00
Jonathan Woollett-Light
7e9af57588 test: Update code coverage test
Signed-off-by: Jonathan Woollett-Light <jcawl@amazon.co.uk>
2023-06-16 11:46:25 +01:00
Jonathan Woollett-Light
56bfdc97bb test: Format with black
Signed-off-by: Jonathan Woollett-Light <jcawl@amazon.co.uk>
2023-06-16 11:46:25 +01:00
Andreea Florescu
ee6be8ca18 make coverage test less sensitive to changes
Instead of accounting for any difference in coverage, only fail the test
if the difference between the current coverage and the new coverage is
higher than 0.5%.

Signed-off-by: Andreea Florescu <fandree@amazon.com>
2022-02-14 10:36:49 +01:00
Andreea Florescu
b037be3396 update test_coverage to allow running it on crates
The test was assuming that we always want to run all the tests in an
workspace, but that is not the case when we have multiple crates that we
want to publish part of the same workspace.

To address this issue, we can now select to run the coverage test only
on the crate in scope. This can be achieved by passing the parameter
`--test-scope` with the value "crate". By default, tests are still
running as a workspace so that we do not need to update all the other
rust-vmm components that were counting on this feature.

The `test-scope` option can also be reused in other tests that are
making use of `--all`. For example, cargo build.

Signed-off-by: Andreea Florescu <fandree@amazon.com>
2021-10-28 14:14:38 +03:00
Ahmed Abouzied
7931077cdc Assert no spaces in crate features JSON
Spaces in the `crate_features` JSON value can cause errors when running
kcov.

Fixes: https://github.com/rust-vmm/rust-vmm-ci/issues/74

Signed-off-by: Ahmed Abouzied <email@aabouzied.com>
2021-10-11 16:40:34 +03:00
Catalin Dumitru
8901e77522 Leftovers from #79
Added copyright info and fixed typos.

Signed-off-by: Catalin Dumitru <catdum@amazon.com>
2021-08-26 12:34:31 +03:00
Catalin Dumitru
cc6ed996a0 Format integration tests code
Split lines that were too long, adjusted intendation and fixed typos.

Signed-off-by: Catalin Dumitru <catdum@amazon.com>
2021-08-25 16:25:48 +03:00
Catalin Dumitru
0b9d283cff Create local rust crate and update config path
In order to be able to run the CI on rust-vmm-ci we needed to
make it a rust crate. Also the path to the coverage config
file needed to be updated in test_coverage.py so that the path
does not depend on the crate; a breadth-first search was used
to guarantee that the config file belongs to the crate that is
being tested.

Signed-off-by: Catalin Dumitru <catdum@amazon.com>
2021-08-02 17:39:26 +03:00
Henry Wang
02004b5bd1 Add a flag that saves the coverage output dir
This commit adds a pytest command line option `--no-cleanup` for
the coverage test. Running the coverage test with this option will
let users save the `kcov_output` directory so that it is easier to
inspect the coverage report.

Signed-off-by: Henry Wang <henry.wang@arm.com>
2020-10-15 09:40:21 +03:00
Alexandra Iordache
265df53b5c Coverage test: keep stdin open
Pytest closes stdin by default, so any processes
spawned from it won't have it. As some tests in
various rust-vmm crates might need stdin to be
open, we mock it with a (currently empty) byte
stream, which we can extend in the future.

Signed-off-by: Alexandra Iordache <aghecen@amazon.com>
2020-09-25 09:54:34 +03:00
Stefan Hajnoczi
e58ea7445a Fix kcov_ouput_dir typo in test_coverage.py
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2020-08-15 20:20:09 +03:00
Laura Loghin
abd2c90d9f Add test for commit message format
Added test that checks if commits follow the 50/72 git
commit rule and if they are signed (git commit -s).
Fixes: #9, #14.

Signed-off-by: Laura Loghin <lauralg@amazon.com>
2020-07-23 15:27:39 +03:00
mrxinwang
cd7096e7a6 Enable rust-vmm coverage test in CI
1. Enabled the aarch64 coverage test in `test_coverage` script.

2. Seperated the coverage json sample file to two sample files for
different machine achitectures.

3. Updated Buildkite pipeline container version.

4. Updated README for the description of coverage files and container
version.

Signed-off-by: Henry Wang <henry.wang@arm.com>
2020-02-21 09:56:34 +01:00
Andreea Florescu
6c471c6c3a added Buildkite pipeline and integration tests
This pipeline contains the tests that are currently run for
kvm-ioctls. The pipeline also has a step that runs the coverage
test defined in integration_tests/test_coverage.py.

The purpose of this pipeline is to be used by all rust-vmm
repositories to ensure we keep the same quality bar for all crates.

Signed-off-by: Andreea Florescu <fandree@amazon.com>
2019-06-20 18:24:38 +03:00