Merge "Don't stop the echo server when input is closed" into main am: 19666641c2
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Virtualization/+/3418219
Change-Id: Ieea13f0981ffabe30470c8b04fe803c5154a5c16
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/tests/testapk/src/native/testbinary.cpp b/tests/testapk/src/native/testbinary.cpp
index 632f648..7edabfd 100644
--- a/tests/testapk/src/native/testbinary.cpp
+++ b/tests/testapk/src/native/testbinary.cpp
@@ -99,6 +99,9 @@
char* line = nullptr;
size_t size = 0;
if (getline(&line, &size, input) < 0) {
+ if (errno == 0) {
+ return {}; // the input was closed
+ }
return ErrnoError() << "Failed to read";
}
@@ -136,12 +139,12 @@
}
std::thread accept_thread{[listening_fd = std::move(server_fd)] {
- auto result = run_echo_reverse_server(listening_fd);
- if (!result.ok()) {
- __android_log_write(ANDROID_LOG_ERROR, TAG, result.error().message().c_str());
- // Make sure the VM exits so the test will fail solidly
- exit(1);
+ Result<void> result;
+ while ((result = run_echo_reverse_server(listening_fd)).ok()) {
}
+ __android_log_write(ANDROID_LOG_ERROR, TAG, result.error().message().c_str());
+ // Make sure the VM exits so the test will fail solidly
+ exit(1);
}};
accept_thread.detach();