sim: Add OldCorrect and NoUpgrade dependency types
Add two additional dependency types. The NoUpgrade type indicates that
this slot should not contain an upgrade at all. The OldCorrect
indicates a dependency on the old version of the other slot.
Signed-off-by: David Brown <david.brown@linaro.org>
Signed-off-by: Fabio Utzig <utzig@apache.org>
diff --git a/sim/src/depends.rs b/sim/src/depends.rs
index d1ea8a1..eecee08 100644
--- a/sim/src/depends.rs
+++ b/sim/src/depends.rs
@@ -54,9 +54,14 @@
Nothing,
/// Provide dependency information that matches the other image.
Correct,
+ /// Provide a dependency that matches the old version of the other
+ /// image.
+ OldCorrect,
/// Provide dependency information describing something newer than the
/// other image.
Newer,
+ /// Don't provide an upgrade image at all for this image
+ NoUpgrade,
}
/// Describes what our expectation is for an upgrade.
@@ -101,14 +106,24 @@
}
fn my_deps(&self, _offset: usize, slot: usize) -> Vec<ImageVersion> {
- match self.test.depends[self.number] {
- DepType::Nothing => vec![],
- DepType::Correct => vec![
- ImageVersion::new_synthetic(self.other_id(), slot as u8, 0)
- ],
- DepType::Newer => vec![
- ImageVersion::new_synthetic(self.other_id(), slot as u8, 1)
- ],
+ // For now, don't put any dependencies in slot zero. They could be
+ // added here if we someday implement checking these.
+ if slot == 0 {
+ vec![]
+ } else {
+ match self.test.depends[self.number] {
+ DepType::Nothing => vec![],
+ DepType::NoUpgrade => panic!("Shouldn't get to this point"),
+ DepType::Correct => vec![
+ ImageVersion::new_synthetic(self.other_id(), slot as u8, 0)
+ ],
+ DepType::OldCorrect => vec![
+ ImageVersion::new_synthetic(self.other_id(), 0, 0)
+ ],
+ DepType::Newer => vec![
+ ImageVersion::new_synthetic(self.other_id(), slot as u8, 1)
+ ],
+ }
}
}