[flang] Fix length handling in character kind implicit conversion (#74586)
[llvm-project.git] / libc / test / integration / startup / gpu / rpc_interface_test.cpp
blob674e2cc1ed7499f93271b8afbd81ea7e448f88d8
1 //===-- Loader test to check the RPC interface with the loader ------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "include/llvm-libc-types/test_rpc_opcodes_t.h"
10 #include "src/__support/GPU/utils.h"
11 #include "src/__support/RPC/rpc_client.h"
12 #include "test/IntegrationTest/test.h"
14 using namespace LIBC_NAMESPACE;
16 // Test to ensure that we can use aribtrary combinations of sends and recieves
17 // as long as they are mirrored.
18 static void test_interface(bool end_with_send) {
19 uint64_t cnt = 0;
20 rpc::Client::Port port = rpc::client.open<RPC_TEST_INTERFACE>();
21 port.send([&](rpc::Buffer *buffer) { buffer->data[0] = end_with_send; });
22 port.send([&](rpc::Buffer *buffer) { buffer->data[0] = cnt = cnt + 1; });
23 port.recv([&](rpc::Buffer *buffer) { cnt = buffer->data[0]; });
24 port.send([&](rpc::Buffer *buffer) { buffer->data[0] = cnt = cnt + 1; });
25 port.recv([&](rpc::Buffer *buffer) { cnt = buffer->data[0]; });
26 port.send([&](rpc::Buffer *buffer) { buffer->data[0] = cnt = cnt + 1; });
27 port.send([&](rpc::Buffer *buffer) { buffer->data[0] = cnt = cnt + 1; });
28 port.recv([&](rpc::Buffer *buffer) { cnt = buffer->data[0]; });
29 port.recv([&](rpc::Buffer *buffer) { cnt = buffer->data[0]; });
30 if (end_with_send)
31 port.send([&](rpc::Buffer *buffer) { buffer->data[0] = cnt = cnt + 1; });
32 else
33 port.recv([&](rpc::Buffer *buffer) { cnt = buffer->data[0]; });
34 port.close();
36 ASSERT_TRUE(cnt == 9 && "Invalid number of increments");
39 TEST_MAIN(int argc, char **argv, char **envp) {
40 test_interface(true);
41 test_interface(false);
43 return 0;