blob: 06c7e9d74b9f4e2ebac9d7d1295e29128b68af35 [file] [log] [blame]
Jiyong Parka7266ac2021-05-17 21:57:24 +09001/*
2 * Copyright (C) 2021 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Alan Stokesd1a30dd2022-11-30 09:39:54 +000016
Inseob Kim06a64d62021-09-07 21:21:45 +090017#include <aidl/com/android/microdroid/testservice/BnTestService.h>
Alan Stokes63fa37b2023-02-22 14:56:57 +000018#include <aidl/com/android/microdroid/testservice/BnVmCallback.h>
19#include <aidl/com/android/microdroid/testservice/IAppCallback.h>
Inseob Kimdb319702022-01-20 13:12:43 +090020#include <android-base/file.h>
Inseob Kim691df6a2022-01-20 12:54:30 +090021#include <android-base/properties.h>
Andrew Scull11cf0902021-06-22 12:08:10 +000022#include <android-base/result.h>
Nikita Ioffe3452ee22022-12-15 00:31:56 +000023#include <android-base/scopeguard.h>
Alan Stokesd1a30dd2022-11-30 09:39:54 +000024#include <android/log.h>
Inseob Kim06a64d62021-09-07 21:21:45 +090025#include <fcntl.h>
Nikita Ioffe29e15c82023-02-25 02:31:51 +000026#include <fstab/fstab.h>
Inseob Kimdb319702022-01-20 13:12:43 +090027#include <fsverity_digests.pb.h>
Inseob Kim06a64d62021-09-07 21:21:45 +090028#include <linux/vm_sockets.h>
29#include <stdint.h>
Jiyong Parka7266ac2021-05-17 21:57:24 +090030#include <stdio.h>
Nikita Ioffe3452ee22022-12-15 00:31:56 +000031#include <sys/capability.h>
Jiyong Park23934392021-06-16 01:59:10 +090032#include <sys/system_properties.h>
Inseob Kim06a64d62021-09-07 21:21:45 +090033#include <unistd.h>
Alan Stokes52d3c722022-10-04 17:27:13 +010034#include <vm_main.h>
Alan Stokesd4ea5a82022-11-10 12:17:42 +000035#include <vm_payload_restricted.h>
Inseob Kim06a64d62021-09-07 21:21:45 +090036
Nikita Ioffed5846dc2024-11-01 18:44:45 +000037#include <cstdint>
Inseob Kim691df6a2022-01-20 12:54:30 +090038#include <string>
Alan Stokesd1a30dd2022-11-30 09:39:54 +000039#include <thread>
Jiyong Parka7266ac2021-05-17 21:57:24 +090040
Alan Stokesd1a30dd2022-11-30 09:39:54 +000041using android::base::borrowed_fd;
Inseob Kim06a64d62021-09-07 21:21:45 +090042using android::base::ErrnoError;
Andrew Scull11cf0902021-06-22 12:08:10 +000043using android::base::Error;
Nikita Ioffe3452ee22022-12-15 00:31:56 +000044using android::base::make_scope_guard;
Andrew Scull11cf0902021-06-22 12:08:10 +000045using android::base::Result;
Alan Stokesd1a30dd2022-11-30 09:39:54 +000046using android::base::unique_fd;
Nikita Ioffe29e15c82023-02-25 02:31:51 +000047using android::fs_mgr::Fstab;
48using android::fs_mgr::FstabEntry;
49using android::fs_mgr::GetEntryForMountPoint;
50using android::fs_mgr::ReadFstabFromFile;
Alan Stokesd1a30dd2022-11-30 09:39:54 +000051
52using aidl::com::android::microdroid::testservice::BnTestService;
Alan Stokes63fa37b2023-02-22 14:56:57 +000053using aidl::com::android::microdroid::testservice::BnVmCallback;
54using aidl::com::android::microdroid::testservice::IAppCallback;
Alan Stokesd1a30dd2022-11-30 09:39:54 +000055using ndk::ScopedAStatus;
Andrew Scull66616612021-06-17 16:41:03 +000056
Jiyong Parkfe5b28e2021-06-24 00:19:02 +090057extern void testlib_sub();
58
Andrew Scull66616612021-06-17 16:41:03 +000059namespace {
60
Alan Stokesd1a30dd2022-11-30 09:39:54 +000061constexpr char TAG[] = "testbinary";
62
Andrew Scull11cf0902021-06-22 12:08:10 +000063template <typename T>
Andrew Sculledbe75e2021-07-06 10:44:31 +000064Result<T> report_test(std::string name, Result<T> result) {
Andrew Scull11cf0902021-06-22 12:08:10 +000065 auto property = "debug.microdroid.test." + name;
66 std::stringstream outcome;
67 if (result.ok()) {
68 outcome << "PASS";
69 } else {
70 outcome << "FAIL: " << result.error();
Alan Stokesd1a30dd2022-11-30 09:39:54 +000071 // Log the error in case the property is truncated.
72 std::string message = name + ": " + outcome.str();
73 __android_log_write(ANDROID_LOG_WARN, TAG, message.c_str());
Andrew Scull11cf0902021-06-22 12:08:10 +000074 }
75 __system_property_set(property.c_str(), outcome.str().c_str());
Andrew Sculledbe75e2021-07-06 10:44:31 +000076 return result;
Andrew Scull66616612021-06-17 16:41:03 +000077}
78
Alan Stokesd1a30dd2022-11-30 09:39:54 +000079Result<void> run_echo_reverse_server(borrowed_fd listening_fd) {
80 struct sockaddr_vm client_sa = {};
81 socklen_t client_sa_len = sizeof(client_sa);
82 unique_fd connect_fd{accept4(listening_fd.get(), (struct sockaddr*)&client_sa, &client_sa_len,
83 SOCK_CLOEXEC)};
84 if (!connect_fd.ok()) {
85 return ErrnoError() << "Failed to accept vsock connection";
86 }
87
88 unique_fd input_fd{fcntl(connect_fd, F_DUPFD_CLOEXEC, 0)};
89 if (!input_fd.ok()) {
90 return ErrnoError() << "Failed to dup";
91 }
92 FILE* input = fdopen(input_fd.release(), "r");
93 if (!input) {
94 return ErrnoError() << "Failed to fdopen";
95 }
96
David Brazdilbcce3512023-02-23 15:32:55 +000097 // Run forever, reverse one line at a time.
98 while (true) {
99 char* line = nullptr;
100 size_t size = 0;
101 if (getline(&line, &size, input) < 0) {
Jiyong Park2ff07882024-12-17 11:30:28 +0900102 if (errno == 0) {
103 return {}; // the input was closed
104 }
David Brazdilbcce3512023-02-23 15:32:55 +0000105 return ErrnoError() << "Failed to read";
106 }
107
108 std::string_view original = line;
109 if (!original.empty() && original.back() == '\n') {
110 original = original.substr(0, original.size() - 1);
111 }
112
113 std::string reversed(original.rbegin(), original.rend());
114 reversed += "\n";
115
116 if (write(connect_fd, reversed.data(), reversed.size()) < 0) {
117 return ErrnoError() << "Failed to write";
118 }
Alan Stokesd1a30dd2022-11-30 09:39:54 +0000119 }
Alan Stokesd1a30dd2022-11-30 09:39:54 +0000120}
121
122Result<void> start_echo_reverse_server() {
123 unique_fd server_fd{TEMP_FAILURE_RETRY(socket(AF_VSOCK, SOCK_STREAM | SOCK_CLOEXEC, 0))};
124 if (!server_fd.ok()) {
125 return ErrnoError() << "Failed to create vsock socket";
126 }
127 struct sockaddr_vm server_sa = (struct sockaddr_vm){
128 .svm_family = AF_VSOCK,
Alan Stokes10c47672022-12-13 17:17:08 +0000129 .svm_port = static_cast<uint32_t>(BnTestService::ECHO_REVERSE_PORT),
Alan Stokesd1a30dd2022-11-30 09:39:54 +0000130 .svm_cid = VMADDR_CID_ANY,
131 };
132 int ret = TEMP_FAILURE_RETRY(bind(server_fd, (struct sockaddr*)&server_sa, sizeof(server_sa)));
133 if (ret < 0) {
134 return ErrnoError() << "Failed to bind vsock socket";
135 }
136 ret = TEMP_FAILURE_RETRY(listen(server_fd, /*backlog=*/1));
137 if (ret < 0) {
138 return ErrnoError() << "Failed to listen";
139 }
140
141 std::thread accept_thread{[listening_fd = std::move(server_fd)] {
Jiyong Park2ff07882024-12-17 11:30:28 +0900142 Result<void> result;
143 while ((result = run_echo_reverse_server(listening_fd)).ok()) {
Alan Stokesd1a30dd2022-11-30 09:39:54 +0000144 }
Jiyong Park2ff07882024-12-17 11:30:28 +0900145 __android_log_write(ANDROID_LOG_ERROR, TAG, result.error().message().c_str());
146 // Make sure the VM exits so the test will fail solidly
147 exit(1);
Alan Stokesd1a30dd2022-11-30 09:39:54 +0000148 }};
149 accept_thread.detach();
150
151 return {};
152}
153
Inseob Kim06a64d62021-09-07 21:21:45 +0900154Result<void> start_test_service() {
Alan Stokes63fa37b2023-02-22 14:56:57 +0000155 class VmCallbackImpl : public BnVmCallback {
156 private:
157 std::shared_ptr<IAppCallback> mAppCallback;
158
159 public:
160 explicit VmCallbackImpl(const std::shared_ptr<IAppCallback>& appCallback)
161 : mAppCallback(appCallback) {}
162
163 ScopedAStatus echoMessage(const std::string& message) override {
164 std::thread callback_thread{[=, appCallback = mAppCallback] {
165 appCallback->onEchoRequestReceived("Received: " + message);
166 }};
167 callback_thread.detach();
168 return ScopedAStatus::ok();
169 }
170 };
171
Alan Stokesd1a30dd2022-11-30 09:39:54 +0000172 class TestService : public BnTestService {
Alan Stokes63fa37b2023-02-22 14:56:57 +0000173 public:
Alan Stokesd1a30dd2022-11-30 09:39:54 +0000174 ScopedAStatus addInteger(int32_t a, int32_t b, int32_t* out) override {
Inseob Kim06a64d62021-09-07 21:21:45 +0900175 *out = a + b;
Alan Stokesd1a30dd2022-11-30 09:39:54 +0000176 return ScopedAStatus::ok();
Inseob Kim06a64d62021-09-07 21:21:45 +0900177 }
Inseob Kim691df6a2022-01-20 12:54:30 +0900178
Alan Stokesd1a30dd2022-11-30 09:39:54 +0000179 ScopedAStatus readProperty(const std::string& prop, std::string* out) override {
Inseob Kim691df6a2022-01-20 12:54:30 +0900180 *out = android::base::GetProperty(prop, "");
181 if (out->empty()) {
182 std::string msg = "cannot find property " + prop;
Alan Stokesd1a30dd2022-11-30 09:39:54 +0000183 return ScopedAStatus::fromExceptionCodeWithMessage(EX_SERVICE_SPECIFIC,
184 msg.c_str());
Inseob Kim691df6a2022-01-20 12:54:30 +0900185 }
186
Alan Stokesd1a30dd2022-11-30 09:39:54 +0000187 return ScopedAStatus::ok();
Inseob Kim691df6a2022-01-20 12:54:30 +0900188 }
Andrew Scull2e6ab792022-01-30 16:04:08 +0000189
Alan Stokesd1a30dd2022-11-30 09:39:54 +0000190 ScopedAStatus insecurelyExposeVmInstanceSecret(std::vector<uint8_t>* out) override {
Andrew Scull102067a2022-10-07 00:34:40 +0000191 const uint8_t identifier[] = {1, 2, 3, 4};
Andrew Scull655e98e2022-10-10 22:24:58 +0000192 out->resize(32);
Alan Stokes65bbb912022-11-23 09:39:34 +0000193 AVmPayload_getVmInstanceSecret(identifier, sizeof(identifier), out->data(),
194 out->size());
Alan Stokesd1a30dd2022-11-30 09:39:54 +0000195 return ScopedAStatus::ok();
Andrew Scull2e6ab792022-01-30 16:04:08 +0000196 }
Andrew Scull1f6ca352022-02-20 22:51:12 +0000197
Alan Stokesd1a30dd2022-11-30 09:39:54 +0000198 ScopedAStatus insecurelyExposeAttestationCdi(std::vector<uint8_t>* out) override {
Alan Stokes65bbb912022-11-23 09:39:34 +0000199 size_t cdi_size = AVmPayload_getDiceAttestationCdi(nullptr, 0);
Andrew Scull655e98e2022-10-10 22:24:58 +0000200 out->resize(cdi_size);
Alan Stokes65bbb912022-11-23 09:39:34 +0000201 AVmPayload_getDiceAttestationCdi(out->data(), out->size());
Alan Stokesd1a30dd2022-11-30 09:39:54 +0000202 return ScopedAStatus::ok();
Andrew Scull1f6ca352022-02-20 22:51:12 +0000203 }
Andrew Scull61892082022-02-21 00:07:25 +0000204
Alan Stokesd1a30dd2022-11-30 09:39:54 +0000205 ScopedAStatus getBcc(std::vector<uint8_t>* out) override {
Alan Stokes65bbb912022-11-23 09:39:34 +0000206 size_t bcc_size = AVmPayload_getDiceAttestationChain(nullptr, 0);
Andrew Scull655e98e2022-10-10 22:24:58 +0000207 out->resize(bcc_size);
Alan Stokes65bbb912022-11-23 09:39:34 +0000208 AVmPayload_getDiceAttestationChain(out->data(), out->size());
Alan Stokesd1a30dd2022-11-30 09:39:54 +0000209 return ScopedAStatus::ok();
Andrew Scull61892082022-02-21 00:07:25 +0000210 }
Alice Wang6bbb6da2022-10-26 12:44:06 +0000211
Alan Stokesd1a30dd2022-11-30 09:39:54 +0000212 ScopedAStatus getApkContentsPath(std::string* out) override {
Alice Wang6bbb6da2022-10-26 12:44:06 +0000213 const char* path_c = AVmPayload_getApkContentsPath();
214 if (path_c == nullptr) {
Alan Stokesd1a30dd2022-11-30 09:39:54 +0000215 return ScopedAStatus::
Alice Wang6bbb6da2022-10-26 12:44:06 +0000216 fromServiceSpecificErrorWithMessage(0, "Failed to get APK contents path");
217 }
Alan Stokesd1a30dd2022-11-30 09:39:54 +0000218 *out = path_c;
219 return ScopedAStatus::ok();
Alice Wang6bbb6da2022-10-26 12:44:06 +0000220 }
Alan Stokes78d24702022-11-21 15:28:31 +0000221
Alan Stokesd1a30dd2022-11-30 09:39:54 +0000222 ScopedAStatus getEncryptedStoragePath(std::string* out) override {
Alan Stokes78d24702022-11-21 15:28:31 +0000223 const char* path_c = AVmPayload_getEncryptedStoragePath();
224 if (path_c == nullptr) {
225 out->clear();
226 } else {
227 *out = path_c;
228 }
Alan Stokesd1a30dd2022-11-30 09:39:54 +0000229 return ScopedAStatus::ok();
230 }
231
Nikita Ioffe3452ee22022-12-15 00:31:56 +0000232 ScopedAStatus getEffectiveCapabilities(std::vector<std::string>* out) override {
233 if (out == nullptr) {
234 return ScopedAStatus::ok();
235 }
236 cap_t cap = cap_get_proc();
237 auto guard = make_scope_guard([&cap]() { cap_free(cap); });
238 for (cap_value_t cap_id = 0; cap_id < CAP_LAST_CAP + 1; cap_id++) {
239 cap_flag_value_t value;
240 if (cap_get_flag(cap, cap_id, CAP_EFFECTIVE, &value) != 0) {
241 return ScopedAStatus::
242 fromServiceSpecificErrorWithMessage(0, "cap_get_flag failed");
243 }
244 if (value == CAP_SET) {
245 // Ideally we would just send back the cap_ids, but I wasn't able to find java
246 // APIs for linux capabilities, hence we transform to the human readable name
247 // here.
248 char* name = cap_to_name(cap_id);
249 out->push_back(std::string(name) + "(" + std::to_string(cap_id) + ")");
250 }
251 }
252 return ScopedAStatus::ok();
253 }
254
Alan Stokes1294f942023-08-21 14:34:12 +0100255 ScopedAStatus getUid(int* out) override {
256 *out = getuid();
257 return ScopedAStatus::ok();
258 }
259
Alan Stokes63fa37b2023-02-22 14:56:57 +0000260 ScopedAStatus runEchoReverseServer() override {
Alan Stokesd1a30dd2022-11-30 09:39:54 +0000261 auto result = start_echo_reverse_server();
262 if (result.ok()) {
263 return ScopedAStatus::ok();
264 } else {
265 std::string message = result.error().message();
266 return ScopedAStatus::fromServiceSpecificErrorWithMessage(-1, message.c_str());
267 }
Alan Stokes78d24702022-11-21 15:28:31 +0000268 }
Shikha Panwardc11b7e2022-12-15 12:24:11 +0000269
270 ScopedAStatus writeToFile(const std::string& content, const std::string& path) override {
271 if (!android::base::WriteStringToFile(content, path)) {
272 std::string msg = "Failed to write " + content + " to file " + path +
273 ". Errono: " + std::to_string(errno);
274 return ScopedAStatus::fromExceptionCodeWithMessage(EX_SERVICE_SPECIFIC,
275 msg.c_str());
276 }
Shikha Panwardc11b7e2022-12-15 12:24:11 +0000277 return ScopedAStatus::ok();
278 }
279
280 ScopedAStatus readFromFile(const std::string& path, std::string* out) override {
281 if (!android::base::ReadFileToString(path, out)) {
282 std::string msg =
283 "Failed to read " + path + " to string. Errono: " + std::to_string(errno);
284 return ScopedAStatus::fromExceptionCodeWithMessage(EX_SERVICE_SPECIFIC,
285 msg.c_str());
286 }
287 return ScopedAStatus::ok();
288 }
Shikha Panwardef7ef92023-01-06 08:35:48 +0000289
Nikita Ioffea7cb3672023-02-24 23:10:34 +0000290 ScopedAStatus getFilePermissions(const std::string& path, int32_t* out) override {
291 struct stat sb;
292 if (stat(path.c_str(), &sb) != -1) {
293 *out = sb.st_mode;
294 } else {
295 std::string msg = "stat " + path + " failed : " + std::strerror(errno);
296 return ScopedAStatus::fromExceptionCodeWithMessage(EX_SERVICE_SPECIFIC,
297 msg.c_str());
298 }
299 return ScopedAStatus::ok();
300 }
301
Nikita Ioffe29e15c82023-02-25 02:31:51 +0000302 ScopedAStatus getMountFlags(const std::string& mount_point, int32_t* out) override {
303 Fstab fstab;
304 if (!ReadFstabFromFile("/proc/mounts", &fstab)) {
305 return ScopedAStatus::fromExceptionCodeWithMessage(EX_SERVICE_SPECIFIC,
306 "Failed to read /proc/mounts");
307 }
308 FstabEntry* entry = GetEntryForMountPoint(&fstab, mount_point);
309 if (entry == nullptr) {
310 std::string msg = mount_point + " not found in /proc/mounts";
311 return ScopedAStatus::fromExceptionCodeWithMessage(EX_SERVICE_SPECIFIC,
312 msg.c_str());
313 }
314 *out = entry->flags;
315 return ScopedAStatus::ok();
316 }
317
Nikita Ioffed5846dc2024-11-01 18:44:45 +0000318 ScopedAStatus getPageSize(int32_t* out) override {
319 *out = getpagesize();
320 return ScopedAStatus::ok();
321 }
322
Alan Stokes63fa37b2023-02-22 14:56:57 +0000323 ScopedAStatus requestCallback(const std::shared_ptr<IAppCallback>& appCallback) {
324 auto vmCallback = ndk::SharedRefBase::make<VmCallbackImpl>(appCallback);
325 std::thread callback_thread{[=] { appCallback->setVmCallback(vmCallback); }};
326 callback_thread.detach();
327 return ScopedAStatus::ok();
328 }
329
Jiyong Park92e34722023-06-27 00:43:39 +0900330 ScopedAStatus readLineFromConsole(std::string* out) {
331 FILE* f = fopen("/dev/console", "r");
332 if (f == nullptr) {
333 return ScopedAStatus::fromExceptionCodeWithMessage(EX_SERVICE_SPECIFIC,
334 "failed to open /dev/console");
335 }
336 char* line = nullptr;
337 size_t len = 0;
338 ssize_t nread = getline(&line, &len, f);
339
340 if (nread == -1) {
341 free(line);
342 return ScopedAStatus::fromExceptionCodeWithMessage(EX_SERVICE_SPECIFIC,
343 "failed to read /dev/console");
344 }
345 out->append(line, nread);
346 free(line);
347 return ScopedAStatus::ok();
348 }
349
Shikha Panwar0c3a2fa2024-12-06 18:38:06 +0000350 ScopedAStatus insecurelyReadPayloadRpData(std::array<uint8_t, 32>* out) override {
351 int32_t ret = AVmPayload_readRollbackProtectedSecret(out->data(), 32);
352 if (ret != 32) {
353 return ScopedAStatus::fromServiceSpecificError(ret);
354 }
355 return ScopedAStatus::ok();
356 }
357
358 ScopedAStatus insecurelyWritePayloadRpData(
359 const std::array<uint8_t, 32>& inputData) override {
360 int32_t ret = AVmPayload_writeRollbackProtectedSecret(inputData.data(), 32);
361 if (ret != 32) {
362 return ScopedAStatus::fromServiceSpecificError(ret);
363 }
364 return ScopedAStatus::ok();
365 }
366
Shikha Panwar5b7b4942024-12-18 15:32:49 +0000367 ScopedAStatus isNewInstance(bool* is_new_instance_out) override {
368 *is_new_instance_out = AVmPayload_isNewInstance();
369 return ScopedAStatus::ok();
370 }
371
Shikha Panwardef7ef92023-01-06 08:35:48 +0000372 ScopedAStatus quit() override { exit(0); }
Inseob Kim06a64d62021-09-07 21:21:45 +0900373 };
374 auto testService = ndk::SharedRefBase::make<TestService>();
375
Alan Stokes65bbb912022-11-23 09:39:34 +0000376 auto callback = []([[maybe_unused]] void* param) { AVmPayload_notifyPayloadReady(); };
Devin Moorecaf7b952023-04-24 20:14:35 +0000377 AVmPayload_runVsockRpcServer(testService->asBinder().get(), testService->PORT, callback,
Alan Stokese0945ad2022-11-24 13:29:57 +0000378 nullptr);
Inseob Kim06a64d62021-09-07 21:21:45 +0900379
380 return {};
381}
382
Alan Stokes4b31a482024-02-01 17:56:06 +0000383Result<void> verify_build_manifest() {
Inseob Kimdb319702022-01-20 13:12:43 +0900384 const char* path = "/mnt/extra-apk/0/assets/build_manifest.pb";
385
386 std::string str;
387 if (!android::base::ReadFileToString(path, &str)) {
388 return ErrnoError() << "failed to read build_manifest.pb";
389 }
390
391 if (!android::security::fsverity::FSVerityDigests().ParseFromString(str)) {
392 return Error() << "invalid build_manifest.pb";
393 }
394
395 return {};
396}
397
Alan Stokes4b31a482024-02-01 17:56:06 +0000398Result<void> verify_vm_share() {
399 const char* path = "/mnt/extra-apk/0/assets/vmshareapp.txt";
400
401 std::string str;
402 if (!android::base::ReadFileToString(path, &str)) {
403 return ErrnoError() << "failed to read vmshareapp.txt";
404 }
405
406 return {};
407}
408
Andrew Scull66616612021-06-17 16:41:03 +0000409} // Anonymous namespace
410
Alan Stokes52d3c722022-10-04 17:27:13 +0100411extern "C" int AVmPayload_main() {
Alan Stokesd1a30dd2022-11-30 09:39:54 +0000412 __android_log_write(ANDROID_LOG_INFO, TAG, "Hello Microdroid");
Inseob Kim06a64d62021-09-07 21:21:45 +0900413
Alan Stokesd1a30dd2022-11-30 09:39:54 +0000414 // Make sure we can call into other shared libraries.
Jiyong Parkfe5b28e2021-06-24 00:19:02 +0900415 testlib_sub();
Jiyong Park23934392021-06-16 01:59:10 +0900416
Alan Stokes4b31a482024-02-01 17:56:06 +0000417 // Report various things that aren't always fatal - these are checked in MicrodroidTests as
418 // appropriate.
419 report_test("extra_apk_build_manifest", verify_build_manifest());
420 report_test("extra_apk_vm_share", verify_vm_share());
Inseob Kimdb319702022-01-20 13:12:43 +0900421
Jiyong Park23934392021-06-16 01:59:10 +0900422 __system_property_set("debug.microdroid.app.run", "true");
Andrew Sculledbe75e2021-07-06 10:44:31 +0000423
Inseob Kim06a64d62021-09-07 21:21:45 +0900424 if (auto res = start_test_service(); res.ok()) {
425 return 0;
426 } else {
Alan Stokesd1a30dd2022-11-30 09:39:54 +0000427 __android_log_write(ANDROID_LOG_ERROR, TAG, res.error().message().c_str());
Inseob Kim06a64d62021-09-07 21:21:45 +0900428 return 1;
429 }
Jiyong Parka7266ac2021-05-17 21:57:24 +0900430}