Cleaner error messages on failure
If the VM fails to start, report that as the test failure instead of
an NPE.
Test: Builds
Bug: 286007149
Change-Id: I296483cf073544d3e08c88988c0c5d82c4f30b83
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;