Merge "Cleaner error messages on failure" am: 56d81872ce am: 8b4a6fd708

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

Change-Id: I6a96e0903b2c3c18837818c19ff115eb46675b89
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java b/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java
index c210ea6..aed28a8 100644
--- a/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java
+++ b/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java
@@ -24,6 +24,7 @@
 import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
 
 import static com.google.common.truth.Truth.assertThat;
+import static com.google.common.truth.Truth.assertWithMessage;
 import static com.google.common.truth.TruthJUnit.assume;
 
 import android.app.Instrumentation;
@@ -467,6 +468,8 @@
 
         BenchmarkVmListener.create(listener).runToFinish(TAG, vm);
 
+        assertWithMessage("VM failed to start").that(listener.mCrosvm).isNotNull();
+
         double mem_overall = 256.0;
         double mem_total = (double) listener.mMemTotal / 1024.0;
         double mem_free = (double) listener.mMemFree / 1024.0;
@@ -548,6 +551,8 @@
         VirtualMachine vm = forceCreateNewVirtualMachine(vmName, config);
         MemoryReclaimListener listener = new MemoryReclaimListener(this::executeCommand);
         BenchmarkVmListener.create(listener).runToFinish(TAG, vm);
+        assertWithMessage("VM failed to start").that(listener.mPreCrosvm).isNotNull();
+        assertWithMessage("Post trim stats not available").that(listener.mPostCrosvm).isNotNull();
 
         double mem_pre_crosvm_host_rss = (double) listener.mPreCrosvm.mHostRss / 1024.0;
         double mem_pre_crosvm_host_pss = (double) listener.mPreCrosvm.mHostPss / 1024.0;