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

Side by Side Diff: ipc/ipc_channel_posix_unittest.cc

Issue 6596093: Add some bullet proofing to ipc_channel_posix. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/ipc
Patch Set: replace NOTREACHED with LOG(ERROR) Created 9 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 unified diff | Download patch | Annotate | Revision Log
« ipc/ipc_channel_posix.cc ('K') | « ipc/ipc_channel_posix.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 // These tests are POSIX only. 5 // These tests are POSIX only.
6 6
7 #include "ipc/ipc_channel_posix.h" 7 #include "ipc/ipc_channel_posix.h"
8 8
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <sys/socket.h> 10 #include <sys/socket.h>
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 QUIT_MESSAGE, // message type 311 QUIT_MESSAGE, // message type
312 IPC::Message::PRIORITY_NORMAL); 312 IPC::Message::PRIORITY_NORMAL);
313 channel.Send(message); 313 channel.Send(message);
314 SpinRunLoop(TestTimeouts::action_timeout_ms()); 314 SpinRunLoop(TestTimeouts::action_timeout_ms());
315 EXPECT_TRUE(base::WaitForExitCode(handle, &exit_code)); 315 EXPECT_TRUE(base::WaitForExitCode(handle, &exit_code));
316 EXPECT_EQ(exit_code, 0); 316 EXPECT_EQ(exit_code, 0);
317 ASSERT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status()); 317 ASSERT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status());
318 ASSERT_FALSE(channel.HasAcceptedConnection()); 318 ASSERT_FALSE(channel.HasAcceptedConnection());
319 } 319 }
320 320
321 TEST_F(IPCChannelPosixTest, DoubleServer) {
322 // Test setting up two servers with the same name.
323 IPCChannelPosixTestListener listener(false);
324 IPCChannelPosixTestListener listener2(false);
325 IPC::ChannelHandle chan_handle(kConnectionSocketTestName);
326 IPC::Channel channel(chan_handle, IPC::Channel::MODE_SERVER, &listener);
327 IPC::Channel channel2(chan_handle, IPC::Channel::MODE_SERVER, &listener2);
328 ASSERT_TRUE(channel.Connect());
329 ASSERT_FALSE(channel2.Connect());
330 }
331
332 TEST_F(IPCChannelPosixTest, BadMode) {
333 // Test setting up two servers with a bad mode.
334 IPCChannelPosixTestListener listener(false);
335 IPC::ChannelHandle chan_handle(kConnectionSocketTestName);
336 IPC::Channel channel(chan_handle, IPC::Channel::MODE_NONE, &listener);
337 ASSERT_FALSE(channel.Connect());
338 }
339
321 // A long running process that connects to us 340 // A long running process that connects to us
322 MULTIPROCESS_TEST_MAIN(IPCChannelPosixTestConnectionProc) { 341 MULTIPROCESS_TEST_MAIN(IPCChannelPosixTestConnectionProc) {
323 MessageLoopForIO message_loop; 342 MessageLoopForIO message_loop;
324 IPCChannelPosixTestListener listener(true); 343 IPCChannelPosixTestListener listener(true);
325 IPC::ChannelHandle handle(IPCChannelPosixTest::kConnectionSocketTestName); 344 IPC::ChannelHandle handle(IPCChannelPosixTest::kConnectionSocketTestName);
326 IPCChannelPosixTest::SetUpSocket(&handle, IPC::Channel::MODE_NAMED_CLIENT); 345 IPCChannelPosixTest::SetUpSocket(&handle, IPC::Channel::MODE_NAMED_CLIENT);
327 IPC::Channel channel(handle, IPC::Channel::MODE_NAMED_CLIENT, &listener); 346 IPC::Channel channel(handle, IPC::Channel::MODE_NAMED_CLIENT, &listener);
328 EXPECT_TRUE(channel.Connect()); 347 EXPECT_TRUE(channel.Connect());
329 IPCChannelPosixTest::SpinRunLoop(TestTimeouts::action_max_timeout_ms()); 348 IPCChannelPosixTest::SpinRunLoop(TestTimeouts::action_max_timeout_ms());
330 EXPECT_EQ(IPCChannelPosixTestListener::MESSAGE_RECEIVED, listener.status()); 349 EXPECT_EQ(IPCChannelPosixTestListener::MESSAGE_RECEIVED, listener.status());
(...skipping 16 matching lines...) Expand all
347 bool connected = channel.Connect(); 366 bool connected = channel.Connect();
348 if (connected) { 367 if (connected) {
349 IPCChannelPosixTest::SpinRunLoop(TestTimeouts::action_max_timeout_ms()); 368 IPCChannelPosixTest::SpinRunLoop(TestTimeouts::action_max_timeout_ms());
350 EXPECT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status()); 369 EXPECT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status());
351 } else { 370 } else {
352 EXPECT_EQ(IPCChannelPosixTestListener::DISCONNECTED, listener.status()); 371 EXPECT_EQ(IPCChannelPosixTestListener::DISCONNECTED, listener.status());
353 } 372 }
354 return 0; 373 return 0;
355 } 374 }
356 375
OLDNEW
« ipc/ipc_channel_posix.cc ('K') | « ipc/ipc_channel_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698