summaryrefslogtreecommitdiffstats
path: root/chrome/common/ipc_send_fds_test.cc
diff options
context:
space:
mode:
authorjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-11 00:45:57 +0000
committerjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-11 00:45:57 +0000
commit953c31f80f9d0b896e2e756e82791d88406dd8bb (patch)
treed4e575d6fe8877dc7c4eda3b6ecc62240d7a435d /chrome/common/ipc_send_fds_test.cc
parent0815b6de5c6a8f079d149067d265c6bf0c5c2604 (diff)
downloadchromium_src-953c31f80f9d0b896e2e756e82791d88406dd8bb.zip
chromium_src-953c31f80f9d0b896e2e756e82791d88406dd8bb.tar.gz
chromium_src-953c31f80f9d0b896e2e756e82791d88406dd8bb.tar.bz2
* Fix error checking for mmap() for POSIX shared memory.
* Make fd-over-IPC test send multiple FDs. Review URL: http://codereview.chromium.org/21238 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9537 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/ipc_send_fds_test.cc')
-rw-r--r--chrome/common/ipc_send_fds_test.cc36
1 files changed, 22 insertions, 14 deletions
diff --git a/chrome/common/ipc_send_fds_test.cc b/chrome/common/ipc_send_fds_test.cc
index ca22bd5..d99082b 100644
--- a/chrome/common/ipc_send_fds_test.cc
+++ b/chrome/common/ipc_send_fds_test.cc
@@ -21,6 +21,7 @@ extern "C" {
namespace {
+const int kNumFDsToSend = 200;
const char* kDevRandomPath = "/dev/random";
static void VerifyAndCloseDescriptor(int fd, ino_t inode_num) {
@@ -42,18 +43,22 @@ static void VerifyAndCloseDescriptor(int fd, ino_t inode_num) {
class MyChannelDescriptorListener : public IPC::Channel::Listener {
public:
MyChannelDescriptorListener(ino_t expected_inode_num)
- : expected_inode_num_(expected_inode_num) {}
+ : expected_inode_num_(expected_inode_num),
+ num_fds_received_(0) {}
virtual void OnMessageReceived(const IPC::Message& message) {
void* iter = NULL;
+ ++num_fds_received_;
FileDescriptor descriptor;
-
ASSERT_TRUE(
IPC::ParamTraits<FileDescriptor>::Read(&message, &iter, &descriptor));
VerifyAndCloseDescriptor(descriptor.fd, expected_inode_num_);
- MessageLoop::current()->Quit();
+
+ if (num_fds_received_ == kNumFDsToSend) {
+ MessageLoop::current()->Quit();
+ }
}
virtual void OnChannelError() {
@@ -61,23 +66,26 @@ class MyChannelDescriptorListener : public IPC::Channel::Listener {
}
private:
ino_t expected_inode_num_;
+ int num_fds_received_;
};
void TestDescriptorServer(IPC::Channel &chan,
base::ProcessHandle process_handle) {
ASSERT_TRUE(process_handle);
- FileDescriptor descriptor;
- const int fd = open(kDevRandomPath, O_RDONLY);
- ASSERT_GE(fd, 0);
- descriptor.auto_close = true;
- descriptor.fd = fd;
-
- IPC::Message* message = new IPC::Message(0, // routing_id
- 3, // message type
- IPC::Message::PRIORITY_NORMAL);
- IPC::ParamTraits<FileDescriptor>::Write(message, descriptor);
- chan.Send(message);
+ for (int i = 0; i < kNumFDsToSend; ++i) {
+ FileDescriptor descriptor;
+ const int fd = open(kDevRandomPath, O_RDONLY);
+ ASSERT_GE(fd, 0);
+ descriptor.auto_close = true;
+ descriptor.fd = fd;
+
+ IPC::Message* message = new IPC::Message(0, // routing_id
+ 3, // message type
+ IPC::Message::PRIORITY_NORMAL);
+ IPC::ParamTraits<FileDescriptor>::Write(message, descriptor);
+ chan.Send(message);
+ }
// Run message loop.
MessageLoop::current()->Run();