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

Side by Side Diff: base/posix/unix_domain_socket_linux_unittest.cc

Issue 2032603002: Migrate WaitableEvent to enum-based constructor in base/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@WEvent_enums
Patch Set: undo incorrect template change Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <sys/socket.h> 7 #include <sys/socket.h>
8 #include <sys/types.h> 8 #include <sys/types.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 uint8_t buffer[16]; 45 uint8_t buffer[16];
46 ASSERT_EQ(static_cast<int>(request.size()), 46 ASSERT_EQ(static_cast<int>(request.size()),
47 UnixDomainSocket::RecvMsg(fds[0], buffer, sizeof(buffer), 47 UnixDomainSocket::RecvMsg(fds[0], buffer, sizeof(buffer),
48 &message_fds)); 48 &message_fds));
49 ASSERT_EQ(1U, message_fds.size()); 49 ASSERT_EQ(1U, message_fds.size());
50 50
51 // Close the reply FD. 51 // Close the reply FD.
52 message_fds.clear(); 52 message_fds.clear();
53 53
54 // Check that the thread didn't get blocked. 54 // Check that the thread didn't get blocked.
55 WaitableEvent event(false, false); 55 WaitableEvent event(WaitableEvent::ResetPolicy::AUTOMATIC,
56 WaitableEvent::InitialState::NOT_SIGNALED);
56 message_thread.task_runner()->PostTask( 57 message_thread.task_runner()->PostTask(
57 FROM_HERE, Bind(&WaitableEvent::Signal, Unretained(&event))); 58 FROM_HERE, Bind(&WaitableEvent::Signal, Unretained(&event)));
58 ASSERT_TRUE(event.TimedWait(TimeDelta::FromMilliseconds(5000))); 59 ASSERT_TRUE(event.TimedWait(TimeDelta::FromMilliseconds(5000)));
59 } 60 }
60 61
61 TEST(UnixDomainSocketTest, SendRecvMsgAvoidsSIGPIPE) { 62 TEST(UnixDomainSocketTest, SendRecvMsgAvoidsSIGPIPE) {
62 // Make sure SIGPIPE isn't being ignored. 63 // Make sure SIGPIPE isn't being ignored.
63 struct sigaction act = {}, oldact; 64 struct sigaction act = {}, oldact;
64 act.sa_handler = SIG_DFL; 65 act.sa_handler = SIG_DFL;
65 ASSERT_EQ(0, sigaction(SIGPIPE, &act, &oldact)); 66 ASSERT_EQ(0, sigaction(SIGPIPE, &act, &oldact));
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 const ssize_t nread = UnixDomainSocket::RecvMsgWithPid( 154 const ssize_t nread = UnixDomainSocket::RecvMsgWithPid(
154 recv_sock.get(), &ch, sizeof(ch), &recv_fds, &sender_pid); 155 recv_sock.get(), &ch, sizeof(ch), &recv_fds, &sender_pid);
155 ASSERT_EQ(0, nread); 156 ASSERT_EQ(0, nread);
156 ASSERT_EQ(-1, sender_pid); 157 ASSERT_EQ(-1, sender_pid);
157 ASSERT_EQ(0U, recv_fds.size()); 158 ASSERT_EQ(0U, recv_fds.size());
158 } 159 }
159 160
160 } // namespace 161 } // namespace
161 162
162 } // namespace base 163 } // namespace base
OLDNEW
« no previous file with comments | « base/message_loop/message_pump_libevent_unittest.cc ('k') | base/profiler/stack_sampling_profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698