summaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorjcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-27 01:12:24 +0000
committerjcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-27 01:12:24 +0000
commit97c652b98f92e060e3ed3a11d2c808d85a7e1c1c (patch)
tree869d2ba677905ea0cba67f4ee311d15846f97790 /ipc
parent31ad4a24b884526a51f81efa556c019dcc27657d (diff)
downloadchromium_src-97c652b98f92e060e3ed3a11d2c808d85a7e1c1c.zip
chromium_src-97c652b98f92e060e3ed3a11d2c808d85a7e1c1c.tar.gz
chromium_src-97c652b98f92e060e3ed3a11d2c808d85a7e1c1c.tar.bz2
Make GlobalDescriptors::MaybeGet return -1 when the key is not found.
BUG=None TEST=Unit tests should still pass. Review URL: https://chromiumcodereview.appspot.com/10387218 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144350 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc')
-rw-r--r--ipc/ipc.gyp4
-rw-r--r--ipc/ipc_fuzzing_tests.cc3
-rw-r--r--ipc/ipc_multiprocess_test.cc19
-rw-r--r--ipc/ipc_multiprocess_test.h23
-rw-r--r--ipc/ipc_send_fds_test.cc5
-rw-r--r--ipc/ipc_tests.cc5
-rw-r--r--ipc/sync_socket_unittest.cc3
7 files changed, 56 insertions, 6 deletions
diff --git a/ipc/ipc.gyp b/ipc/ipc.gyp
index 5ed8b66..5f1762e 100644
--- a/ipc/ipc.gyp
+++ b/ipc/ipc.gyp
@@ -33,6 +33,7 @@
'type': '<(gtest_target_type)',
'dependencies': [
'ipc',
+ 'test_support_ipc',
'../base/base.gyp:base',
'../base/base.gyp:base_i18n',
'../base/base.gyp:test_support_base',
@@ -83,8 +84,11 @@
'dependencies': [
'ipc',
'../base/base.gyp:base',
+ '../testing/gtest.gyp:gtest',
],
'sources': [
+ 'ipc_multiprocess_test.cc',
+ 'ipc_multiprocess_test.h',
'ipc_test_sink.cc',
'ipc_test_sink.h',
],
diff --git a/ipc/ipc_fuzzing_tests.cc b/ipc/ipc_fuzzing_tests.cc
index 32fe71c..34394bf 100644
--- a/ipc/ipc_fuzzing_tests.cc
+++ b/ipc/ipc_fuzzing_tests.cc
@@ -11,6 +11,7 @@
#include "base/threading/platform_thread.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_channel_proxy.h"
+#include "ipc/ipc_multiprocess_test.h"
#include "ipc/ipc_tests.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/multiprocess_func_list.h"
@@ -246,7 +247,7 @@ class FuzzerClientListener : public SimpleListener {
// Runs the fuzzing server child mode. Returns when the preset number
// of messages have been received.
-MULTIPROCESS_TEST_MAIN(RunFuzzServer) {
+MULTIPROCESS_IPC_TEST_MAIN(RunFuzzServer) {
MessageLoopForIO main_message_loop;
FuzzerServerListener listener;
IPC::Channel chan(kFuzzerChannel, IPC::Channel::MODE_CLIENT, &listener);
diff --git a/ipc/ipc_multiprocess_test.cc b/ipc/ipc_multiprocess_test.cc
new file mode 100644
index 0000000..d3c46df
--- /dev/null
+++ b/ipc/ipc_multiprocess_test.cc
@@ -0,0 +1,19 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "build/build_config.h"
+
+#include "ipc/ipc_multiprocess_test.h"
+
+#if defined(OS_POSIX)
+#include "base/global_descriptors_posix.h"
+#include "ipc/ipc_descriptors.h"
+#endif
+
+void MultiProcessTestIPCSetUp() {
+#if defined(OS_POSIX)
+ base::GlobalDescriptors::GetInstance()->Set(kPrimaryIPCChannel,
+ kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor);
+#endif
+}
diff --git a/ipc/ipc_multiprocess_test.h b/ipc/ipc_multiprocess_test.h
new file mode 100644
index 0000000..5364eeb
--- /dev/null
+++ b/ipc/ipc_multiprocess_test.h
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IPC_IPC_MULTIPROCESS_TEST_H_
+#define IPC_IPC_MULTIPROCESS_TEST_H_
+#pragma once
+
+#include "base/test/multiprocess_test.h"
+
+// Use this macro when your sub-process is using an IPCChannel to communicate
+// with the test process.
+// See comment below for MultiProcessTestIPCSetUp() on why this is needed.
+#define MULTIPROCESS_IPC_TEST_MAIN(test_main) \
+ MULTIPROCESS_TEST_MAIN_WITH_SETUP(test_main, MultiProcessTestIPCSetUp)
+
+// Setup function used by MULTIPROCESS_IPC_TEST_MAIN.
+// Registers the IPC channel as a global descriptor in the child process. This
+// is needed on POSIX as the IPCChannel when created looks for a specific global
+// descriptor to establish the connection to the parent process.
+void MultiProcessTestIPCSetUp();
+
+#endif // IPC_IPC_MULTIPROCESS_TEST_H_
diff --git a/ipc/ipc_send_fds_test.cc b/ipc/ipc_send_fds_test.cc
index 124a3dc..0f587c9a 100644
--- a/ipc/ipc_send_fds_test.cc
+++ b/ipc/ipc_send_fds_test.cc
@@ -18,6 +18,7 @@ extern "C" {
#include "base/message_loop.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_message_utils.h"
+#include "ipc/ipc_multiprocess_test.h"
#include "testing/multiprocess_func_list.h"
#if defined(OS_POSIX)
@@ -132,7 +133,7 @@ int TestDescriptorClient(ino_t expected_inode_num) {
// ---------------------------------------------------------------------------
#if defined(OS_MACOSX)
// TODO(port): Make this test cross-platform.
-MULTIPROCESS_TEST_MAIN(RunTestDescriptorClientSandboxed) {
+MULTIPROCESS_IPC_TEST_MAIN(RunTestDescriptorClientSandboxed) {
struct stat st;
const int fd = open(kDevZeroPath, O_RDONLY);
fstat(fd, &st);
@@ -177,7 +178,7 @@ TEST_F(IPCChannelTest, DescriptorTestSandboxed) {
}
#endif // defined(OS_MACOSX)
-MULTIPROCESS_TEST_MAIN(RunTestDescriptorClient) {
+MULTIPROCESS_IPC_TEST_MAIN(RunTestDescriptorClient) {
struct stat st;
const int fd = open(kDevZeroPath, O_RDONLY);
fstat(fd, &st);
diff --git a/ipc/ipc_tests.cc b/ipc/ipc_tests.cc
index 763a592..fc2de57 100644
--- a/ipc/ipc_tests.cc
+++ b/ipc/ipc_tests.cc
@@ -28,6 +28,7 @@
#include "ipc/ipc_channel.h"
#include "ipc/ipc_channel_proxy.h"
#include "ipc/ipc_message_utils.h"
+#include "ipc/ipc_multiprocess_test.h"
#include "ipc/ipc_sender.h"
#include "ipc/ipc_switches.h"
#include "testing/multiprocess_func_list.h"
@@ -402,7 +403,7 @@ TEST_F(IPCChannelTest, MAYBE_SendMessageInChannelConnected) {
base::CloseProcessHandle(process_handle);
}
-MULTIPROCESS_TEST_MAIN(RunTestClient) {
+MULTIPROCESS_IPC_TEST_MAIN(RunTestClient) {
MessageLoopForIO main_message_loop;
MyChannelListener channel_listener;
@@ -572,7 +573,7 @@ TEST_F(IPCChannelTest, Performance) {
}
// This message loop bounces all messages back to the sender
-MULTIPROCESS_TEST_MAIN(RunReflector) {
+MULTIPROCESS_IPC_TEST_MAIN(RunReflector) {
MessageLoopForIO main_message_loop;
IPC::Channel chan(kReflectorChannel, IPC::Channel::MODE_CLIENT, NULL);
ChannelReflectorListener channel_reflector_listener(&chan);
diff --git a/ipc/sync_socket_unittest.cc b/ipc/sync_socket_unittest.cc
index 6aa3330..c8c8187 100644
--- a/ipc/sync_socket_unittest.cc
+++ b/ipc/sync_socket_unittest.cc
@@ -13,6 +13,7 @@
#include "base/process_util.h"
#include "base/threading/thread.h"
#include "ipc/ipc_channel_proxy.h"
+#include "ipc/ipc_multiprocess_test.h"
#include "ipc/ipc_tests.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/multiprocess_func_list.h"
@@ -108,7 +109,7 @@ class SyncSocketServerListener : public IPC::Channel::Listener {
// Runs the fuzzing server child mode. Returns when the preset number
// of messages have been received.
-MULTIPROCESS_TEST_MAIN(RunSyncSocketServer) {
+MULTIPROCESS_IPC_TEST_MAIN(RunSyncSocketServer) {
MessageLoopForIO main_message_loop;
SyncSocketServerListener listener;
IPC::Channel chan(kSyncSocketChannel, IPC::Channel::MODE_CLIENT, &listener);