Simplify use of config files

Since the exposed API won't support config files:
- Don't use a config file for the demo app.
- Don't use config files for tests that don't need one.

Also, in preparation for removing command line argument support
entirely, remove all arguments from config files. Where we were using
arguments to specify behavior, use different binaries instead.

Tweak: Improve error reporting in the benchmark after I got a (sadly
non-reproducible) failure.

Bug: 250876593
Bug: 243513572
Test: atest MicrodroidTests MicrodroidHostTestCases
Test: atest MicrodroidBenchmarkApp
Test: manual - install & run demo app
Change-Id: I4332b2340bf2e18cdaee5acd9ef3277766b1c0b5
diff --git a/tests/benchmark/Android.bp b/tests/benchmark/Android.bp
index f1aebd2..acd0f09 100644
--- a/tests/benchmark/Android.bp
+++ b/tests/benchmark/Android.bp
@@ -19,6 +19,7 @@
     libs: ["android.system.virtualmachine"],
     jni_libs: [
         "MicrodroidBenchmarkNativeLib",
+        "MicrodroidIdleNativeLib",
         "libiovsock_host_jni",
     ],
     platform_apis: true,
@@ -27,6 +28,14 @@
 }
 
 cc_library_shared {
+    name: "MicrodroidIdleNativeLib",
+    srcs: ["src/native/idlebinary.cpp"],
+    shared_libs: [
+        "libbase",
+    ],
+}
+
+cc_library_shared {
     name: "MicrodroidBenchmarkNativeLib",
     srcs: ["src/native/benchmarkbinary.cpp"],
     static_libs: ["libiobenchmark"],
diff --git a/tests/benchmark/assets/vm_config.json b/tests/benchmark/assets/vm_config.json
index e8f43e0..5a604a9 100644
--- a/tests/benchmark/assets/vm_config.json
+++ b/tests/benchmark/assets/vm_config.json
@@ -4,10 +4,7 @@
   },
   "task": {
     "type": "microdroid_launcher",
-    "command": "MicrodroidBenchmarkNativeLib.so",
-    "args": [
-      "no_io"
-    ]
+    "command": "MicrodroidIdleNativeLib.so"
   },
   "export_tombstones": true
 }
diff --git a/tests/benchmark/assets/vm_config_io.json b/tests/benchmark/assets/vm_config_io.json
index 1a5a9e5..66046ba 100644
--- a/tests/benchmark/assets/vm_config_io.json
+++ b/tests/benchmark/assets/vm_config_io.json
@@ -4,10 +4,7 @@
   },
   "task": {
     "type": "microdroid_launcher",
-    "command": "MicrodroidBenchmarkNativeLib.so",
-    "args": [
-      "io"
-    ]
+    "command": "MicrodroidBenchmarkNativeLib.so"
   },
   "apexes": [
     {
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 e0e2274..b1a1160 100644
--- a/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java
+++ b/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java
@@ -406,7 +406,11 @@
             new Thread(() -> sendRate.set(runVsockClientAndSendData(vm))).start();
             benchmarkService.runVsockServerAndReceiveData(serverFd, NUM_BYTES_TO_TRANSFER);
 
-            mReadRates.add(sendRate.get());
+            Double rate = sendRate.get();
+            if (rate == null) {
+                throw new IllegalStateException("runVsockClientAndSendData() failed");
+            }
+            mReadRates.add(rate);
         }
 
         private double runVsockClientAndSendData(VirtualMachine vm) {
diff --git a/tests/benchmark/src/native/benchmarkbinary.cpp b/tests/benchmark/src/native/benchmarkbinary.cpp
index 58b4cf0..8694ef9 100644
--- a/tests/benchmark/src/native/benchmarkbinary.cpp
+++ b/tests/benchmark/src/native/benchmarkbinary.cpp
@@ -182,17 +182,10 @@
 }
 } // Anonymous namespace
 
-extern "C" int android_native_main([[maybe_unused]] int argc, char* argv[]) {
-    if (strcmp(argv[1], "no_io") == 0) {
-        // do nothing for now; just leave it alive. good night.
-        for (;;) {
-            sleep(1000);
-        }
-    } else if (strcmp(argv[1], "io") == 0) {
-        if (auto res = run_io_benchmark_tests(); !res.ok()) {
-            LOG(ERROR) << "IO benchmark test failed: " << res.error() << "\n";
-            return EXIT_FAILURE;
-        }
+extern "C" int android_native_main(int /* argc */, char* /* argv */[]) {
+    if (auto res = run_io_benchmark_tests(); !res.ok()) {
+        LOG(ERROR) << "IO benchmark test failed: " << res.error() << "\n";
+        return EXIT_FAILURE;
     }
     return EXIT_SUCCESS;
 }
diff --git a/tests/benchmark/src/native/idlebinary.cpp b/tests/benchmark/src/native/idlebinary.cpp
new file mode 100644
index 0000000..a74e7bf
--- /dev/null
+++ b/tests/benchmark/src/native/idlebinary.cpp
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <unistd.h>
+
+extern "C" int android_native_main(int /* argc */, char* /* argv */[]) {
+    // do nothing; just leave it alive. good night.
+    for (;;) {
+        sleep(1000);
+    }
+}