[Lldb-commits] [lldb] d2f18e6 - Fix 21555fff4de811309ea7935f9cb65578c957d77f

Walter Erquinigo via lldb-commits lldb-commits at lists.llvm.org
Wed Nov 11 12:30:31 PST 2020


Author: Walter Erquinigo
Date: 2020-11-11T12:30:24-08:00
New Revision: d2f18e6b1e0bed97f5218af499c4e0b88c4dd361

URL: https://github.com/llvm/llvm-project/commit/d2f18e6b1e0bed97f5218af499c4e0b88c4dd361
DIFF: https://github.com/llvm/llvm-project/commit/d2f18e6b1e0bed97f5218af499c4e0b88c4dd361.diff

LOG: 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>>

Added: 
    

Modified: 
    lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
index d4f7b25714fb..adfead6aed98 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.");
   }
 }
 


        


More information about the lldb-commits mailing list