sim: Fix upgrade check
Instead of allowing a preliminary error if the first image is marked to
be held, allow this error if any of the images are marked to be held.
The error doesn't return which image caused the failure, so just check
if any are supposed to be held.
Signed-off-by: David Brown <david.brown@linaro.org>
Signed-off-by: Fabio Utzig <utzig@apache.org>
diff --git a/sim/src/image.rs b/sim/src/image.rs
index fd9fdfe..82cd729 100644
--- a/sim/src/image.rs
+++ b/sim/src/image.rs
@@ -192,10 +192,11 @@
let total_count = match images.run_basic_upgrade(permanent) {
Ok(v) => v,
Err(_) =>
- match deps.upgrades[0] {
- UpgradeInfo::Held => 0,
- UpgradeInfo::Upgraded => panic!("Unable to perform basic upgrade"),
- },
+ if deps.upgrades.iter().any(|u| *u == UpgradeInfo::Held) {
+ 0
+ } else {
+ panic!("Unable to perform basic upgrade");
+ }
};
images.total_count = Some(total_count);