diff options
author | Walter Erquinigo <a20012251@gmail.com> | 2020-11-11 12:28:45 -0800 |
---|---|---|
committer | Walter Erquinigo <a20012251@gmail.com> | 2020-11-11 12:30:24 -0800 |
commit | d2f18e6b1e0bed97f5218af499c4e0b88c4dd361 (patch) | |
tree | 0a1e7a8951a1a9bab41b93a6f788f168ec15049e /lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp | |
parent | 9f310bec34a2d4175ab0d33ca4f380f4f0c00557 (diff) | |
download | llvm-d2f18e6b1e0bed97f5218af499c4e0b88c4dd361.zip llvm-d2f18e6b1e0bed97f5218af499c4e0b88c4dd361.tar.gz llvm-d2f18e6b1e0bed97f5218af499c4e0b88c4dd361.tar.bz2 |
Fix 21555fff4de811309ea7935f9cb65578c957d77f
Buildbot failed on Windows
http://lab.llvm.org:8011/#/builders/83/builds/693
Error: On Windows, std::future can't hold an Expected, as it doesn't have a default
constructor.
Solution: Use std::future<bool> instead of std::future<Expected<T>>
Diffstat (limited to 'lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp')
-rw-r--r-- | lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp | 55 |
1 files changed, 29 insertions, 26 deletions
diff --git a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp index d4f7b25..adfead6 100644 --- a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp +++ b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp @@ -363,59 +363,62 @@ TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfoInvalidResponse) { } TEST_F(GDBRemoteCommunicationClientTest, SendTraceSupportedTypePacket) { + TraceTypeInfo trace_type; + std::string error_message; + auto callback = [&] { + if (llvm::Expected<TraceTypeInfo> trace_type_or_err = + client.SendGetSupportedTraceType()) { + trace_type = *trace_type_or_err; + error_message = ""; + return true; + } else { + trace_type = {}; + error_message = llvm::toString(trace_type_or_err.takeError()); + return false; + } + }; + // Success response { - std::future<llvm::Expected<TraceTypeInfo>> result = std::async( - std::launch::async, [&] { return client.SendGetSupportedTraceType(); }); + std::future<bool> result = std::async(std::launch::async, callback); HandlePacket( server, "jLLDBTraceSupportedType", R"({"name":"intel-pt","description":"Intel Processor Trace"}])"); - llvm::Expected<TraceTypeInfo> trace_type_or_err = result.get(); - EXPECT_THAT_EXPECTED(trace_type_or_err, llvm::Succeeded()); - ASSERT_STREQ(trace_type_or_err->name.c_str(), "intel-pt"); - ASSERT_STREQ(trace_type_or_err->description.c_str(), - "Intel Processor Trace"); + EXPECT_TRUE(result.get()); + ASSERT_STREQ(trace_type.name.c_str(), "intel-pt"); + ASSERT_STREQ(trace_type.description.c_str(), "Intel Processor Trace"); } // Error response - wrong json { - std::future<llvm::Expected<TraceTypeInfo>> result = std::async( - std::launch::async, [&] { return client.SendGetSupportedTraceType(); }); + std::future<bool> result = std::async(std::launch::async, callback); HandlePacket(server, "jLLDBTraceSupportedType", R"({"type":"intel-pt"}])"); - llvm::Expected<TraceTypeInfo> trace_type_or_err = result.get(); - ASSERT_THAT_EXPECTED( - trace_type_or_err, - llvm::Failed<StringError>(testing::Property( - &StringError::getMessage, - testing::HasSubstr("missing value at (root).name")))); + EXPECT_FALSE(result.get()); + ASSERT_STREQ(error_message.c_str(), "missing value at (root).name"); } // Error response { - std::future<llvm::Expected<TraceTypeInfo>> result = std::async( - std::launch::async, [&] { return client.SendGetSupportedTraceType(); }); + std::future<bool> result = std::async(std::launch::async, callback); HandlePacket(server, "jLLDBTraceSupportedType", "E23"); - llvm::Expected<TraceTypeInfo> trace_type_or_err = result.get(); - ASSERT_THAT_EXPECTED(trace_type_or_err, llvm::Failed()); + + EXPECT_FALSE(result.get()); } // Error response with error message { - std::future<llvm::Expected<TraceTypeInfo>> result = std::async( - std::launch::async, [&] { return client.SendGetSupportedTraceType(); }); + std::future<bool> result = std::async(std::launch::async, callback); HandlePacket(server, "jLLDBTraceSupportedType", "E23;50726F63657373206E6F742072756E6E696E672E"); - llvm::Expected<TraceTypeInfo> trace_type_or_err = result.get(); - ASSERT_THAT_EXPECTED(trace_type_or_err, - llvm::Failed<StringError>(testing::Property( - &StringError::getMessage, - testing::HasSubstr("Process not running.")))); + + EXPECT_FALSE(result.get()); + ASSERT_STREQ(error_message.c_str(), "Process not running."); } } |