Skip to content

Commit fc07eab

Browse files
utzigccollins476ad
authored andcommitted
Add interruption at revert step of a test+revert
This extends the test+revert case with an interruption on the revert stage, as it was previously only interrupted on the test stage. For simplicity the interruption happens on the same interruption point for both test and revert stages. Signed-off-by: Fabio Utzig <[email protected]> Signed-off-by: Christopher Collins <[email protected]>
1 parent 28d012c commit fc07eab

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

sim/src/image.rs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ impl Images {
824824
let mut counter = stop;
825825
let (x, _) = c::boot_go(&mut flash, &self.areadesc, Some(&mut counter), false);
826826
if x != -0x13579 {
827-
warn!("Should have stopped at interruption point");
827+
warn!("Should have stopped test at interruption point");
828828
fails += 1;
829829
}
830830

@@ -835,7 +835,7 @@ impl Images {
835835

836836
let (x, _) = c::boot_go(&mut flash, &self.areadesc, None, false);
837837
if x != 0 {
838-
warn!("Should have finished upgrade");
838+
warn!("Should have finished test upgrade");
839839
fails += 1;
840840
}
841841

@@ -861,9 +861,16 @@ impl Images {
861861
}
862862

863863
// Do Revert
864+
let mut counter = stop;
865+
let (x, _) = c::boot_go(&mut flash, &self.areadesc, Some(&mut counter), false);
866+
if x != -0x13579 {
867+
warn!("Should have stopped revert at interruption point");
868+
fails += 1;
869+
}
870+
864871
let (x, _) = c::boot_go(&mut flash, &self.areadesc, None, false);
865872
if x != 0 {
866-
warn!("Should have finished a revert");
873+
warn!("Should have finished revert upgrade");
867874
fails += 1;
868875
}
869876

@@ -877,9 +884,10 @@ impl Images {
877884
stop);
878885
fails += 1;
879886
}
887+
880888
if !self.verify_trailers(&flash, 0, BOOT_MAGIC_GOOD,
881889
BOOT_FLAG_SET, BOOT_FLAG_SET) {
882-
warn!("Mismatched trailer for the secondary slot after revert");
890+
warn!("Mismatched trailer for the primary slot after revert");
883891
fails += 1;
884892
}
885893
if !self.verify_trailers(&flash, 1, BOOT_MAGIC_UNSET,
@@ -888,9 +896,25 @@ impl Images {
888896
fails += 1;
889897
}
890898

899+
let (x, _) = c::boot_go(&mut flash, &self.areadesc, None, false);
900+
if x != 0 {
901+
warn!("Should have finished 3rd boot");
902+
fails += 1;
903+
}
904+
905+
if !self.verify_images(&flash, 0, 0) {
906+
warn!("Image in the primary slot is invalid on 1st boot after revert");
907+
fails += 1;
908+
}
909+
if !self.verify_images(&flash, 1, 1) {
910+
warn!("Image in the secondary slot is invalid on 1st boot after revert");
911+
fails += 1;
912+
}
913+
891914
fails > 0
892915
}
893916

917+
894918
fn try_random_fails(&self, total_ops: i32, count: usize) -> (SimMultiFlash, Vec<i32>) {
895919
let mut flash = self.flash.clone();
896920

0 commit comments

Comments
 (0)