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

Side by Side Diff: ipc/ipc_channel_posix_unittest.cc

Issue 7743001: There are times on the Mac when pipe names of 0 length may occur. Let the caller handle (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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
« no previous file with comments | « 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 channel.Send(message); 274 channel.Send(message);
275 SpinRunLoop(TestTimeouts::action_timeout_ms()); 275 SpinRunLoop(TestTimeouts::action_timeout_ms());
276 EXPECT_TRUE(base::KillProcess(handle, 0, false)); 276 EXPECT_TRUE(base::KillProcess(handle, 0, false));
277 int exit_code = 0; 277 int exit_code = 0;
278 EXPECT_TRUE(base::WaitForExitCode(handle2, &exit_code)); 278 EXPECT_TRUE(base::WaitForExitCode(handle2, &exit_code));
279 EXPECT_EQ(0, exit_code); 279 EXPECT_EQ(0, exit_code);
280 ASSERT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status()); 280 ASSERT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status());
281 ASSERT_FALSE(channel.HasAcceptedConnection()); 281 ASSERT_FALSE(channel.HasAcceptedConnection());
282 } 282 }
283 283
284 TEST_F(IPCChannelPosixTest, BadChannelName) {
285 // Test empty name
286 IPC::ChannelHandle handle("");
287 IPC::Channel channel(handle, IPC::Channel::MODE_NAMED_SERVER, NULL);
288 ASSERT_FALSE(channel.Connect());
289
290 // Test name that is too long.
291 IPC::ChannelHandle handle2("This_is_a_very_long_name_that_must_be_more_than"
Mark Mentovai 2011/08/25 13:11:02 Do “const char kTooLongName[] = This_is_a_very_lon
292 "104_characters_in_length____Proactively_implement"
293 "client-centered_synergy_through_top-line"
294 "platforms_Phosfluorescently_disintermediate_"
295 "clicks-and-mortar_best_practices_without_"
296 "future-proof_growth_strategies_Continually"
297 "pontificate_proactive_potentialities_before"
298 "leading-edge_processes");
jeremy 2011/08/25 07:16:51 _with_a_cherry_on_top :o)
299 IPC::Channel channel2(handle2, IPC::Channel::MODE_NAMED_SERVER, NULL);
300 ASSERT_FALSE(channel2.Connect());
Mark Mentovai 2011/08/25 13:11:02 Note that the suggested size checks could be ASSER
301 }
302
284 TEST_F(IPCChannelPosixTest, MultiConnection) { 303 TEST_F(IPCChannelPosixTest, MultiConnection) {
285 // Test setting up a connection to an external process, and then have 304 // Test setting up a connection to an external process, and then have
286 // another external process attempt to connect to us. 305 // another external process attempt to connect to us.
287 IPCChannelPosixTestListener listener(false); 306 IPCChannelPosixTestListener listener(false);
288 IPC::ChannelHandle chan_handle(kConnectionSocketTestName); 307 IPC::ChannelHandle chan_handle(kConnectionSocketTestName);
289 SetUpSocket(&chan_handle, IPC::Channel::MODE_NAMED_SERVER); 308 SetUpSocket(&chan_handle, IPC::Channel::MODE_NAMED_SERVER);
290 IPC::Channel channel(chan_handle, IPC::Channel::MODE_NAMED_SERVER, &listener); 309 IPC::Channel channel(chan_handle, IPC::Channel::MODE_NAMED_SERVER, &listener);
291 ASSERT_TRUE(channel.Connect()); 310 ASSERT_TRUE(channel.Connect());
292 ASSERT_TRUE(channel.AcceptsConnections()); 311 ASSERT_TRUE(channel.AcceptsConnections());
293 ASSERT_FALSE(channel.HasAcceptedConnection()); 312 ASSERT_FALSE(channel.HasAcceptedConnection());
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 bool connected = channel.Connect(); 399 bool connected = channel.Connect();
381 if (connected) { 400 if (connected) {
382 IPCChannelPosixTest::SpinRunLoop(TestTimeouts::action_max_timeout_ms()); 401 IPCChannelPosixTest::SpinRunLoop(TestTimeouts::action_max_timeout_ms());
383 EXPECT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status()); 402 EXPECT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status());
384 } else { 403 } else {
385 EXPECT_EQ(IPCChannelPosixTestListener::DISCONNECTED, listener.status()); 404 EXPECT_EQ(IPCChannelPosixTestListener::DISCONNECTED, listener.status());
386 } 405 }
387 return 0; 406 return 0;
388 } 407 }
389 408
OLDNEW
« no previous file with comments | « ipc/ipc_channel_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698