Skip to content

Commit 80704f8

Browse files
committed
sim: Allow slow tests to be skipped
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 <[email protected]>
1 parent 29d97b9 commit 80704f8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

sim/src/image.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,10 @@ impl Images {
689689
let mut fails = 0;
690690
let total_flash_ops = self.total_count.unwrap();
691691

692+
if skip_slow_test() {
693+
return false;
694+
}
695+
692696
// Let's try an image halfway through.
693697
for i in 1 .. total_flash_ops {
694698
info!("Try interruption at {}", i);
@@ -775,6 +779,10 @@ impl Images {
775779

776780
let mut fails = 0;
777781

782+
if skip_slow_test() {
783+
return false;
784+
}
785+
778786
if self.is_swap_upgrade() {
779787
for i in 1 .. self.total_count.unwrap() {
780788
info!("Try interruption at {}", i);
@@ -2314,3 +2322,14 @@ fn test_alignments() -> &'static [usize] {
23142322
fn test_alignments() -> &'static [usize] {
23152323
&[32]
23162324
}
2325+
2326+
/// For testing, some of the tests are quite slow. This will query for an
2327+
/// environment variable `MCUBOOT_SKIP_SLOW_TESTS`, which can be set to avoid
2328+
/// running these tests.
2329+
fn skip_slow_test() -> bool {
2330+
if let Ok(_) = std::env::var("MCUBOOT_SKIP_SLOW_TESTS") {
2331+
true
2332+
} else {
2333+
false
2334+
}
2335+
}

0 commit comments

Comments
 (0)