Merge "Backcompat test check updatable before killing VM" into main am: 5124b29367

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Virtualization/+/3530638

Change-Id: I5e3f45ce2245615a6e15143774a685dc79274191
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/tests/backcompat_test/src/main.rs b/tests/backcompat_test/src/main.rs
index eaf3365..9518c38 100644
--- a/tests/backcompat_test/src/main.rs
+++ b/tests/backcompat_test/src/main.rs
@@ -111,6 +111,7 @@
         .truncate(true)
         .open("dump_dt.dtb")
         .with_context(|| "Failed to open device tree dump file dump_dt.dtb")?;
+    let is_updatable = service.isUpdatableVmSupported()?;
     let vm = VmInstance::create(
         service.as_ref(),
         &config,
@@ -169,7 +170,7 @@
     // Check if Secretkeeper is advertised. If not, check the vendor API level. Secretkeeper is
     // required as of 202504, and if missing, the test should fail.
     // Otherwise, ignore the fields, as they are not required.
-    if service.isUpdatableVmSupported()? {
+    if is_updatable {
         dtcompare_cmd.arg("--ignore-path-value").arg("/avf/secretkeeper_public_key");
     } else if vsr_api_level()? >= 202504 {
         return Err(anyhow!("Secretkeeper support missing on vendor API >= 202504. Secretkeeper needs to be implemented."));
@@ -225,7 +226,8 @@
 }
 
 fn get_sysprop_i32(prop: &str) -> Result<i32> {
-    let res = rustutils::system_properties::read(prop)?;
-    res.map(|val| val.parse::<i32>().with_context(|| format!("Failed to read {prop}")))
-        .unwrap_or(Ok(-1))
+    let Some(val) = rustutils::system_properties::read(prop)? else {
+        return Ok(-1);
+    };
+    val.parse::<i32>().with_context(|| format!("Failed to read {prop}"))
 }