From 100bb74b540a9985e9cda7b20701791ef5ab0ece Mon Sep 17 00:00:00 2001 From: Fabio Utzig Date: Wed, 13 Sep 2017 17:18:36 -0300 Subject: [PATCH] Enable overwrite-only testing on sim Adds the feature to enable testing of overwrite-only functionality. While running with this feature enabled, disable tests that try to revert and disables trailer verification, since overwrite-only doesn't rely on status writing. Signed-off-by: Fabio Utzig --- .travis.yml | 9 ++++++--- sim/Cargo.toml | 1 + sim/src/main.rs | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index ee26d390..489b83dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,12 @@ language: rust script: - - cd sim; cargo build --release - - cd sim; cargo run --release -- runall - - cd sim; cargo run --release --features sig-rsa -- runall + - set -e + - cd sim + - cargo build --release + - cargo run --release -- runall + - cargo run --release --features sig-rsa -- runall + - cargo run --release --features overwrite-only -- runall notifications: slack: diff --git a/sim/Cargo.toml b/sim/Cargo.toml index 1466589a..6bca65db 100644 --- a/sim/Cargo.toml +++ b/sim/Cargo.toml @@ -7,6 +7,7 @@ authors = ["David Brown "] default = [] sig-rsa = ["mcuboot-sys/sig-rsa"] +overwrite-only = ["mcuboot-sys/overwrite-only"] [build-dependencies] gcc = "0.3.38" diff --git a/sim/src/main.rs b/sim/src/main.rs index 713bb52e..3c9f8835 100644 --- a/sim/src/main.rs +++ b/sim/src/main.rs @@ -315,6 +315,13 @@ fn run_basic_upgrade(flash: &SimFlash, areadesc: &AreaDesc, images: &Images) } } +#[cfg(feature = "overwrite-only")] +#[allow(unused_variables)] +fn run_basic_revert(flash: &SimFlash, areadesc: &AreaDesc, images: &Images) -> bool { + false +} + +#[cfg(not(feature = "overwrite-only"))] fn run_basic_revert(flash: &SimFlash, areadesc: &AreaDesc, images: &Images) -> bool { let mut fails = 0; @@ -413,6 +420,14 @@ fn run_perm_with_random_fails(flash: &SimFlash, areadesc: &AreaDesc, fails > 0 } +#[cfg(feature = "overwrite-only")] +#[allow(unused_variables)] +fn run_revert_with_fails(flash: &SimFlash, areadesc: &AreaDesc, images: &Images, + total_count: i32) -> bool { + false +} + +#[cfg(not(feature = "overwrite-only"))] fn run_revert_with_fails(flash: &SimFlash, areadesc: &AreaDesc, images: &Images, total_count: i32) -> bool { let mut fails = 0; @@ -430,6 +445,13 @@ fn run_revert_with_fails(flash: &SimFlash, areadesc: &AreaDesc, images: &Images, fails > 0 } +#[cfg(feature = "overwrite-only")] +#[allow(unused_variables)] +fn run_norevert(flash: &SimFlash, areadesc: &AreaDesc, images: &Images) -> bool { + false +} + +#[cfg(not(feature = "overwrite-only"))] fn run_norevert(flash: &SimFlash, areadesc: &AreaDesc, images: &Images) -> bool { let mut fl = flash.clone(); let mut fails = 0; @@ -612,6 +634,7 @@ fn try_upgrade(flash: &SimFlash, areadesc: &AreaDesc, images: &Images, (fl, count - c::get_flash_counter()) } +#[cfg(not(feature = "overwrite-only"))] fn try_revert(flash: &SimFlash, areadesc: &AreaDesc, count: usize) -> SimFlash { let mut fl = flash.clone(); c::set_flash_counter(0); @@ -624,6 +647,7 @@ fn try_revert(flash: &SimFlash, areadesc: &AreaDesc, count: usize) -> SimFlash { fl } +#[cfg(not(feature = "overwrite-only"))] fn try_revert_with_fail_at(flash: &SimFlash, areadesc: &AreaDesc, images: &Images, stop: i32) -> bool { let mut fl = flash.clone(); @@ -834,6 +858,16 @@ fn verify_image(flash: &Flash, offset: usize, buf: &[u8]) -> bool { } } +#[cfg(feature = "overwrite-only")] +#[allow(unused_variables)] +// overwrite-only doesn't employ trailer management +fn verify_trailer(flash: &Flash, offset: usize, + magic: Option<&[u8]>, image_ok: Option, + copy_done: Option) -> bool { + true +} + +#[cfg(not(feature = "overwrite-only"))] fn verify_trailer(flash: &Flash, offset: usize, magic: Option<&[u8]>, image_ok: Option, copy_done: Option) -> bool {