Commit 80704f87 authored by David Brown's avatar David Brown Committed by David Brown
Browse files

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: default avatarDavid Brown <david.brown@linaro.org>
parent 29d97b94
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -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);
@@ -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);
@@ -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
    }
}