From d2f18e6b1e0bed97f5218af499c4e0b88c4dd361 Mon Sep 17 00:00:00 2001 From: Walter Erquinigo Date: Wed, 11 Nov 2020 12:28:45 -0800 Subject: [PATCH] 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 instead of std::future> --- .../GDBRemoteCommunicationClientTest.cpp | 55 ++++++++++++---------- 1 file 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 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> result = std::async( - std::launch::async, [&] { return client.SendGetSupportedTraceType(); }); + std::future result = std::async(std::launch::async, callback); HandlePacket( server, "jLLDBTraceSupportedType", R"({"name":"intel-pt","description":"Intel Processor Trace"}])"); - llvm::Expected 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> result = std::async( - std::launch::async, [&] { return client.SendGetSupportedTraceType(); }); + std::future result = std::async(std::launch::async, callback); HandlePacket(server, "jLLDBTraceSupportedType", R"({"type":"intel-pt"}])"); - llvm::Expected trace_type_or_err = result.get(); - ASSERT_THAT_EXPECTED( - trace_type_or_err, - llvm::Failed(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> result = std::async( - std::launch::async, [&] { return client.SendGetSupportedTraceType(); }); + std::future result = std::async(std::launch::async, callback); HandlePacket(server, "jLLDBTraceSupportedType", "E23"); - llvm::Expected 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> result = std::async( - std::launch::async, [&] { return client.SendGetSupportedTraceType(); }); + std::future result = std::async(std::launch::async, callback); HandlePacket(server, "jLLDBTraceSupportedType", "E23;50726F63657373206E6F742072756E6E696E672E"); - llvm::Expected trace_type_or_err = result.get(); - ASSERT_THAT_EXPECTED(trace_type_or_err, - llvm::Failed(testing::Property( - &StringError::getMessage, - testing::HasSubstr("Process not running.")))); + + EXPECT_FALSE(result.get()); + ASSERT_STREQ(error_message.c_str(), "Process not running."); } } -- 2.7.4