[Lldb-commits] [lldb] c2fec2f - [lldb] Make RNBSocketTest compile again after socket modernization
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Thu Apr 23 08:00:31 PDT 2020
Author: Raphael Isemann
Date: 2020-04-23T17:00:02+02:00
New Revision: c2fec2fb17787c14e7860a57ef4f03e085cd3a7b
URL: https://github.com/llvm/llvm-project/commit/c2fec2fb17787c14e7860a57ef4f03e085cd3a7b
DIFF: https://github.com/llvm/llvm-project/commit/c2fec2fb17787c14e7860a57ef4f03e085cd3a7b.diff
LOG: [lldb] Make RNBSocketTest compile again after socket modernization
Commit c9e6b7010c6998b6 changed the API but didn't update this
macOS-specific test.
Added:
Modified:
lldb/unittests/debugserver/CMakeLists.txt
lldb/unittests/debugserver/RNBSocketTest.cpp
Removed:
################################################################################
diff --git a/lldb/unittests/debugserver/CMakeLists.txt b/lldb/unittests/debugserver/CMakeLists.txt
index 66c4c639fc89..c216eecd7d8a 100644
--- a/lldb/unittests/debugserver/CMakeLists.txt
+++ b/lldb/unittests/debugserver/CMakeLists.txt
@@ -15,6 +15,7 @@ add_lldb_unittest(debugserverTests
LINK_LIBS
lldbDebugserverCommon
lldbHost
+ LLVMTestingSupport
LINK_COMPONENTS
Support
)
diff --git a/lldb/unittests/debugserver/RNBSocketTest.cpp b/lldb/unittests/debugserver/RNBSocketTest.cpp
index b5a6896f3ba1..7840c48f82b4 100644
--- a/lldb/unittests/debugserver/RNBSocketTest.cpp
+++ b/lldb/unittests/debugserver/RNBSocketTest.cpp
@@ -17,6 +17,7 @@
#include "lldb/Host/Socket.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Host/common/TCPSocket.h"
+#include "llvm/Testing/Support/Error.h"
using namespace lldb_private;
@@ -26,15 +27,16 @@ std::string goodbye = "Goodbye!";
static void ServerCallbackv4(const void *baton, in_port_t port) {
auto child_pid = fork();
if (child_pid == 0) {
- Socket *client_socket;
char addr_buffer[256];
sprintf(addr_buffer, "%s:%d", baton, port);
- Status err = Socket::TcpConnect(addr_buffer, false, client_socket);
- if (err.Fail())
- abort();
+ llvm::Expected<std::unique_ptr<Socket>> socket_or_err =
+ Socket::TcpConnect(addr_buffer, false);
+ ASSERT_THAT_EXPECTED(socket_or_err, llvm::Succeeded());
+ Socket *client_socket = socket_or_err->get();
+
char buffer[32];
size_t read_size = 32;
- err = client_socket->Read((void *)&buffer[0], read_size);
+ Status err = client_socket->Read((void *)&buffer[0], read_size);
if (err.Fail())
abort();
std::string Recv(&buffer[0], read_size);
@@ -102,9 +104,10 @@ void TestSocketConnect(const char *addr) {
Socket *server_socket;
Predicate<uint16_t> port_predicate;
port_predicate.SetValue(0, eBroadcastNever);
- Status err =
- Socket::TcpListen(addr_wrap, false, server_socket, &port_predicate);
- ASSERT_FALSE(err.Fail());
+ llvm::Expected<std::unique_ptr<Socket>> socket_or_err =
+ Socket::TcpListen(addr_wrap, false, &port_predicate);
+ ASSERT_THAT_EXPECTED(socket_or_err, llvm::Succeeded());
+ server_socket = socket_or_err->get();
auto port = ((TCPSocket *)server_socket)->GetLocalPortNumber();
auto child_pid = fork();
@@ -120,7 +123,7 @@ void TestSocketConnect(const char *addr) {
ASSERT_EQ(bye, goodbye);
} else {
Socket *connected_socket;
- err = server_socket->Accept(connected_socket);
+ Status err = server_socket->Accept(connected_socket);
if (err.Fail()) {
llvm::errs() << err.AsCString();
abort();
More information about the lldb-commits
mailing list