Skip to content

Commit

Permalink
sim: Allow slow tests to be skipped
Browse files Browse the repository at this point in the history
The normal simulation test takes several hours to run on most machines. Allow a
few very slow tests to be skipped by setting the environment variable
`MCUBOOT_SKIP_SLOW_TESTS` to some value. For obvious reasons, this shouldn't be
done if these power failure simulation tests are needed.

With this change, on my desktop Linux machine, the test time with the skipping
goes from about 2 hours, to around 5 minutes.

Signed-off-by: David Brown <david.brown@linaro.org>
  • Loading branch information
d3zd3z committed Apr 19, 2024
1 parent 29d97b9 commit 80704f8
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions sim/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,10 @@ impl Images {
let mut fails = 0;
let total_flash_ops = self.total_count.unwrap();

if skip_slow_test() {
return false;
}

// Let's try an image halfway through.
for i in 1 .. total_flash_ops {
info!("Try interruption at {}", i);
Expand Down Expand Up @@ -775,6 +779,10 @@ impl Images {

let mut fails = 0;

if skip_slow_test() {
return false;
}

if self.is_swap_upgrade() {
for i in 1 .. self.total_count.unwrap() {
info!("Try interruption at {}", i);
Expand Down Expand Up @@ -2314,3 +2322,14 @@ fn test_alignments() -> &'static [usize] {
fn test_alignments() -> &'static [usize] {
&[32]
}

/// For testing, some of the tests are quite slow. This will query for an
/// environment variable `MCUBOOT_SKIP_SLOW_TESTS`, which can be set to avoid
/// running these tests.
fn skip_slow_test() -> bool {
if let Ok(_) = std::env::var("MCUBOOT_SKIP_SLOW_TESTS") {
true
} else {
false
}
}

0 comments on commit 80704f8

Please sign in to comment.