X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=folly%2Fio%2Fasync%2Ftest%2FAsyncSocketTest2.cpp;h=e90bca5c728c5788c1038b547118b7abbcf35459;hp=cbca3d348844522270f184e6dc1144b2cd78818d;hb=873d451128cf4aee2b8a7b7c460e24ed8e42c334;hpb=3ffa8cf0d790a265ad7cfc172276eb09de26b30f diff --git a/folly/io/async/test/AsyncSocketTest2.cpp b/folly/io/async/test/AsyncSocketTest2.cpp index cbca3d34..e90bca5c 100644 --- a/folly/io/async/test/AsyncSocketTest2.cpp +++ b/folly/io/async/test/AsyncSocketTest2.cpp @@ -3085,38 +3085,21 @@ TEST(AsyncSocketTest, SendMessageFlags) { } TEST(AsyncSocketTest, SendMessageAncillaryData) { - struct sockaddr_un addr = {AF_UNIX, - "AsyncSocketTest.SendMessageAncillaryData\0"}; + int fds[2]; + EXPECT_EQ(socketpair(AF_UNIX, SOCK_STREAM, 0, fds), 0); - // Clean up the name in the name space we're going to use - ASSERT_FALSE(remove(addr.sun_path) == -1 && errno != ENOENT); + // "Client" socket + int cfd = fds[0]; + ASSERT_NE(cfd, -1); - // Set up listening socket - int lfd = fsp::socket(AF_UNIX, SOCK_STREAM, 0); - ASSERT_NE(lfd, -1); - SCOPE_EXIT { close(lfd); }; - ASSERT_NE(bind(lfd, (struct sockaddr*)&addr, sizeof(addr)), -1) - << "Bind failed: " << errno; - - // Create the connecting socket - int csd = fsp::socket(AF_UNIX, SOCK_STREAM, 0); - ASSERT_NE(csd, -1); - - // Listen for incoming connect - ASSERT_NE(listen(lfd, 5), -1); - - // Connect to the listening socket - ASSERT_NE(fsp::connect(csd, (struct sockaddr*)&addr, sizeof(addr)), -1) - << "Connect request failed: " << errno; - - // Accept the connection - int sfd = accept(lfd, nullptr, nullptr); + // "Server" socket + int sfd = fds[1]; ASSERT_NE(sfd, -1); SCOPE_EXIT { close(sfd); }; // Instantiate AsyncSocket object for the connected socket EventBase evb; - std::shared_ptr socket = AsyncSocket::newSocket(&evb, csd); + std::shared_ptr socket = AsyncSocket::newSocket(&evb, cfd); // Open a temporary file and write a magic string to it // We'll transfer the file handle to test the message parameters