Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Unified Diff: mojo/embedder/platform_channel_pair_posix_unittest.cc

Issue 226263005: Mojo: Abstract out write/writev vs send/sendmsg (for Unix domain sockets). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/embedder/platform_channel_pair.h ('k') | mojo/embedder/platform_channel_utils_posix.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/embedder/platform_channel_pair_posix_unittest.cc
diff --git a/mojo/embedder/platform_channel_pair_posix_unittest.cc b/mojo/embedder/platform_channel_pair_posix_unittest.cc
index e03c05384285f7cb2f27575cf6113946e53b08bc..7b09e314a2b7452ef472e6cf32802a5d606dc257 100644
--- a/mojo/embedder/platform_channel_pair_posix_unittest.cc
+++ b/mojo/embedder/platform_channel_pair_posix_unittest.cc
@@ -8,11 +8,12 @@
#include <signal.h>
#include <sys/socket.h>
#include <sys/types.h>
+#include <sys/uio.h>
#include <unistd.h>
#include "base/logging.h"
#include "base/macros.h"
-#include "build/build_config.h"
+#include "mojo/embedder/platform_channel_utils_posix.h"
#include "mojo/embedder/scoped_platform_handle.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -70,15 +71,18 @@ TEST_F(PlatformChannelPairPosixTest, NoSigPipe) {
if (result == -1)
PLOG(WARNING) << "read (expected 0 for EOF)";
- // However, |write()|/|send()| should fail outright.
- // On Mac, |SIGPIPE| needs to be suppressed on the socket itself and we can
- // use |write()|/|writev()|. On Linux, we have to suppress it by using
- // |send()|/|sendmsg()| with |MSG_NOSIGNAL|.
-#if defined(OS_MACOSX)
- result = write(server_handle.get().fd, kHello, sizeof(kHello));
-#else
- result = send(server_handle.get().fd, kHello, sizeof(kHello), MSG_NOSIGNAL);
-#endif
+ // Test our replacement for |write()|/|send()|.
+ result = PlatformChannelWrite(server_handle.get(), kHello, sizeof(kHello));
+ EXPECT_EQ(-1, result);
+ if (errno != EPIPE)
+ PLOG(WARNING) << "write (expected EPIPE)";
+
+ // Test our replacement for |writev()|/|sendv()|.
+ struct iovec iov[2] = {
+ { const_cast<char*>(kHello), sizeof(kHello) },
+ { const_cast<char*>(kHello), sizeof(kHello) }
+ };
+ result = PlatformChannelWritev(server_handle.get(), iov, 2);
EXPECT_EQ(-1, result);
if (errno != EPIPE)
PLOG(WARNING) << "write (expected EPIPE)";
« no previous file with comments | « mojo/embedder/platform_channel_pair.h ('k') | mojo/embedder/platform_channel_utils_posix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698