diff options
author | Lang Hames <lhames@gmail.com> | 2017-02-24 20:56:43 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2017-02-24 20:56:43 +0000 |
commit | 630d2639f91e505d59a2c8d90f93aac9bbfc87d8 (patch) | |
tree | 3eacbad1b7989960f9cf62c81b41e36a0ce25cf4 /llvm/unittests/ExecutionEngine | |
parent | c12a5a7595d30996804dc41e7150aec4e19e7c0a (diff) | |
download | bcm5719-llvm-630d2639f91e505d59a2c8d90f93aac9bbfc87d8.tar.gz bcm5719-llvm-630d2639f91e505d59a2c8d90f93aac9bbfc87d8.zip |
[Orc][RPC] Accept both const char* and char* arguments for string serialization.
llvm-svn: 296168
Diffstat (limited to 'llvm/unittests/ExecutionEngine')
-rw-r--r-- | llvm/unittests/ExecutionEngine/Orc/RPCUtilsTest.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/llvm/unittests/ExecutionEngine/Orc/RPCUtilsTest.cpp b/llvm/unittests/ExecutionEngine/Orc/RPCUtilsTest.cpp index f1fce9d6f21..355d20b4f78 100644 --- a/llvm/unittests/ExecutionEngine/Orc/RPCUtilsTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/RPCUtilsTest.cpp @@ -120,6 +120,11 @@ namespace DummyRPCAPI { static const char* getName() { return "IntInt"; } }; + class VoidString : public Function<VoidString, void(std::string)> { + public: + static const char* getName() { return "VoidString"; } + }; + class AllTheTypes : public Function<AllTheTypes, void(int8_t, uint8_t, int16_t, uint16_t, int32_t, @@ -340,6 +345,46 @@ TEST(DummyRPC, TestAsyncIntIntHandlerMethod) { ServerThread.join(); } +TEST(DummyRPC, TestCallAsyncVoidString) { + Queue Q1, Q2; + DummyRPCEndpoint Client(Q1, Q2); + DummyRPCEndpoint Server(Q2, Q1); + + std::thread ServerThread([&]() { + Server.addHandler<DummyRPCAPI::VoidString>( + [](const std::string &S) { + EXPECT_EQ(S, "hello") + << "Server void(std::string) received unexpected result"; + }); + + // Poke the server to handle the negotiate call. + for (int I = 0; I < 4; ++I) { + auto Err = Server.handleOne(); + EXPECT_FALSE(!!Err) << "Server failed to handle call"; + } + }); + + { + // Make an call using a std::string. + auto Err = Client.callB<DummyRPCAPI::VoidString>(std::string("hello")); + EXPECT_FALSE(!!Err) << "Client.callAsync failed for void(std::string)"; + } + + { + // Make an call using a std::string. + auto Err = Client.callB<DummyRPCAPI::VoidString>(StringRef("hello")); + EXPECT_FALSE(!!Err) << "Client.callAsync failed for void(std::string)"; + } + + { + // Make an call using a std::string. + auto Err = Client.callB<DummyRPCAPI::VoidString>("hello"); + EXPECT_FALSE(!!Err) << "Client.callAsync failed for void(string)"; + } + + ServerThread.join(); +} + TEST(DummyRPC, TestSerialization) { Queue Q1, Q2; DummyRPCEndpoint Client(Q1, Q2); |