39 Commits

Author SHA1 Message Date
Stefano Garzarella
94e2492e36 chore: fix formatting issues
New `black` is complaining about reformatting some of our files,
let's make it happy:

    $ black . --check
    would reformat rust-vmm-ci/test_run.py
    would reformat rust-vmm-ci/integration_tests/conftest.py
    would reformat rust-vmm-ci/.buildkite/autogenerate_pipeline.py

    Oh no! 💥 💔 💥
    3 files would be reformatted, 5 files would be left unchanged.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2026-03-01 13:03:41 +01:00
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
Patrick Roy
212241789d fix: have benchmark test clean working directory
Before checking out different commits, clean the working directory to
avoid checkout failures to to temporary files created during benchmark
execution (as is done by linux-loader)

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
2024-10-17 15:32:28 +01: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
Erik Schilling
7c1057e9bc test_commit_format: no longer check body length
There are quite a few, genuine useful cases where one wants to overflow
the recommended 75 (some use 72) character rule.

Breaking long lines or manually breaking long compiler or other
tool-generated outputs is just confusing and error-prone.

This does not mean that we should stop wrapping manually written text
at a sane length, but enforcing the rule with a script seems to yield
questionable results while creating quite a bit of friction.

Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
2023-07-14 11:42:08 +01: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
1401badaaf fix test benchmark
With newer versions of git we need to add an exception
for the `workdir` which is owned by a different user
then the one that is running the git commands.

Signed-off-by: Andreea Florescu <fandree@amazon.com>
2022-09-12 12:20:15 +03:00
Andreea Florescu
6fbd7c7355 fix test commit format
The newer versions of git are checking the ownership of directories.
Since the `/workdir` is a shared directory with ownership of buildkite,
we need to add an exception for it.

Signed-off-by: Andreea Florescu <fandree@amazon.com>
2022-08-26 19:48:52 +03:00
Mathieu Poirier
99fe2eb2e0 Relax 50/72 rule for more descriptive titles
Expand the title and changelog description lines to 60 and 75
respectively.  That is in line with what other projects do and
allows for better narratives.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
2022-02-22 10:06:54 +02: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
ae7db2d98a Rename master to main
Updated occurrences of "master" with "main".

Signed-off-by: Catalin Dumitru <catdum@amazon.com>
2021-09-02 12:33:44 +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
Catalin Dumitru
7693628035 Update commit format test to work locally
Set default values for the remote name and
base branch when the test is run locally and
the Buildkite variables are not available and
the variables BASE_BRANCH and REMOTE are not set.

Signed-off-by: Catalin Dumitru <catdum@amazon.com>
2021-07-21 15:59:49 +03:00
Keiichi Watanabe
9f7b0d9069 check commit authors for each commit
Although we check commit authors in test_commit_format.py to skip tests
for dependabot's commits, the current code only checks the author of the
head commit.
This PR make it check each commit's author so that we can test branches
where both a dependabot's commit and other commits exist.

Signed-off-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-06-22 11:18:24 +03:00
Andreea Florescu
ebc701641f exclude dependabot from the 50/72 commit rule
When dependabot updates the rust-vmm-ci submodule, the git commit
sumamry is over 50 chars. To be able to merge PR, exclude the dependabot
user from this checks.

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

Signed-off-by: Andreea Florescu <fandree@amazon.com>
2021-02-23 12:50:55 +02: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
Laura Loghin
3ea5f2b1f1 improve a bit error messages for commit test
Made the messages for some error cases clearer.

Signed-off-by: Laura Loghin <lauralg@amazon.com>
2020-10-08 15:18:08 +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
Andreea Florescu
0fc8cede37 refactor test_benchmark.py
- Added defines for PR branch, result files
- Updated variables & function names to be more explicit about what
  they do

Signed-off-by: Andreea Florescu <fandree@amazon.com>
2020-07-31 11:08:50 +03:00
Andreea Florescu
741b894e28 checkout to PR branch before finishing test_bench
This cleanup is needed because otherwise all subsequent tests are
going to run on the master branch.

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

Signed-off-by: Andreea Florescu <fandree@amazon.com>
2020-07-31 11:08:50 +03:00
Andreea Florescu
645a5c3a74 test_bench: don't crash when no bench on master
When there are no benchmarks on the master branch, instead of
crashing first check if the error. Pass the test in case
cargo bench failed due to main bench not being present.

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

Signed-off-by: Andreea Florescu <fandree@amazon.com>
2020-07-31 11:08:50 +03:00
Laura Loghin
bd32544c00 Fetch origin in benchmark test
Before running `git checkout` on the upstream
master branch, we should also fetch that branch.

Signed-off-by: Laura Loghin <lauralg@amazon.com>
2020-07-29 12:05:33 +03:00
Laura Loghin
35beb918b7 Fix commit message test
The test that was checking the commit message format
was not comparing the PR's HEAD to the right master,
even though `origin` was set to the pipeline repository.
Fixed this by fetching that repo. This way, `FETCH_HEAD`
points to the latest upstream master.

Signed-off-by: Laura Loghin <lauralg@amazon.com>
2020-07-29 12:05:33 +03:00
Alexandra Iordache
53427aa758 benchmarks: add test that can run at every PR
Related to #24

Signed-off-by: Alexandra Iordache <aghecen@amazon.com>
2020-07-23 16:17:32 +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