summaryrefslogtreecommitdiff
path: root/libc/test/integration/startup/gpu/rpc_stream_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libc/test/integration/startup/gpu/rpc_stream_test.cpp')
-rw-r--r--libc/test/integration/startup/gpu/rpc_stream_test.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/libc/test/integration/startup/gpu/rpc_stream_test.cpp b/libc/test/integration/startup/gpu/rpc_stream_test.cpp
new file mode 100644
index 000000000000..877ded34b1aa
--- /dev/null
+++ b/libc/test/integration/startup/gpu/rpc_stream_test.cpp
@@ -0,0 +1,50 @@
+//===-- Loader test to check the RPC streaming interface with the loader --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/__support/GPU/utils.h"
+#include "src/__support/RPC/rpc_client.h"
+#include "src/__support/integer_to_string.h"
+#include "src/string/memory_utils/memcmp_implementations.h"
+#include "src/string/memory_utils/memcpy_implementations.h"
+#include "src/string/string_utils.h"
+#include "test/IntegrationTest/test.h"
+
+extern "C" void *malloc(uint64_t);
+
+using namespace __llvm_libc;
+
+static void test_stream() {
+ const char str[] = "ABCDEFGHIJKLMNOPQRSTUVWXYabcdefghijklmnopqrstuvwxy"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYabcdefghijklmnopqrstuvwxy"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYabcdefghijklmnopqrstuvwxy"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYabcdefghijklmnopqrstuvwxy"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYabcdefghijklmnopqrstuvwxy";
+ uint64_t send_size = sizeof(str);
+ void *send_ptr = malloc(send_size);
+ void *recv_ptr;
+ uint64_t recv_size;
+
+ inline_memcpy(send_ptr, str, send_size);
+ ASSERT_TRUE(inline_memcmp(send_ptr, str, send_size) == 0 && "Data mismatch");
+ rpc::Client::Port port = rpc::client.open<rpc::TEST_STREAM>();
+ port.send_n(send_ptr, send_size);
+ port.recv_n(&recv_ptr, &recv_size,
+ [](uint64_t size) { return malloc(size); });
+ port.close();
+ ASSERT_TRUE(inline_memcmp(recv_ptr, str, recv_size) == 0 && "Data mismatch");
+ ASSERT_TRUE(recv_size == send_size && "Data size mismatch");
+
+ free(send_ptr);
+ free(recv_ptr);
+}
+
+TEST_MAIN(int argc, char **argv, char **envp) {
+ test_stream();
+
+ return 0;
+}