1 //===-- Loader test to check the RPC interface with the loader ------------===//
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
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
) {
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]; });
31 port
.send([&](rpc::Buffer
*buffer
) { buffer
->data
[0] = cnt
= cnt
+ 1; });
33 port
.recv([&](rpc::Buffer
*buffer
) { cnt
= buffer
->data
[0]; });
36 ASSERT_TRUE(cnt
== 9 && "Invalid number of increments");
39 TEST_MAIN(int argc
, char **argv
, char **envp
) {
41 test_interface(false);