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

Unified Diff: mojo/edk/embedder/platform_channel_pair_posix_unittest.cc

Issue 830593003: Update mojo sdk to rev 9fbbc4f0fef1187312316c0ed992342474e139f1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cherry-pick mojo 9d3b8dd17f12d20035a14737fdc38dd926890ff8 Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/embedder/entrypoints.cc ('k') | mojo/edk/js/test/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/embedder/platform_channel_pair_posix_unittest.cc
diff --git a/mojo/edk/embedder/platform_channel_pair_posix_unittest.cc b/mojo/edk/embedder/platform_channel_pair_posix_unittest.cc
index c3b1ef1936091f46f8d684bf41a29bbf37b1240a..56540d79c106a835d349d29fbac2e6670b14b8dc 100644
--- a/mojo/edk/embedder/platform_channel_pair_posix_unittest.cc
+++ b/mojo/edk/embedder/platform_channel_pair_posix_unittest.cc
@@ -138,17 +138,19 @@ TEST_F(PlatformChannelPairPosixTest, SendReceiveFDs) {
ScopedPlatformHandle client_handle = channel_pair.PassClientHandle().Pass();
for (size_t i = 1; i < kPlatformChannelMaxNumHandles; i++) {
- // Make |i| files, with the j-th file consisting of j copies of the digit i.
- PlatformHandleVector platform_handles;
+ // Make |i| files, with the j-th file consisting of j copies of the digit
+ // |c|.
+ const char c = '0' + (i % 10);
+ ScopedPlatformHandleVectorPtr platform_handles(new PlatformHandleVector);
for (size_t j = 1; j <= i; j++) {
base::FilePath unused;
base::ScopedFILE fp(
base::CreateAndOpenTemporaryFileInDir(temp_dir.path(), &unused));
ASSERT_TRUE(fp);
- ASSERT_EQ(j, fwrite(std::string(j, '0' + i).data(), 1, j, fp.get()));
- platform_handles.push_back(
+ ASSERT_EQ(j, fwrite(std::string(j, c).data(), 1, j, fp.get()));
+ platform_handles->push_back(
test::PlatformHandleFromFILE(fp.Pass()).release());
- ASSERT_TRUE(platform_handles.back().is_valid());
+ ASSERT_TRUE(platform_handles->back().is_valid());
}
// Send the FDs (+ "hello").
@@ -156,12 +158,12 @@ TEST_F(PlatformChannelPairPosixTest, SendReceiveFDs) {
// We assume that the |sendmsg()| actually sends all the data.
EXPECT_EQ(static_cast<ssize_t>(sizeof(kHello)),
PlatformChannelSendmsgWithHandles(server_handle.get(), &iov, 1,
- &platform_handles[0],
- platform_handles.size()));
+ &platform_handles->at(0),
+ platform_handles->size()));
WaitReadable(client_handle.get());
- char buf[100] = {};
+ char buf[10000] = {};
std::deque<PlatformHandle> received_handles;
// We assume that the |recvmsg()| actually reads all the data.
EXPECT_EQ(static_cast<ssize_t>(sizeof(kHello)),
@@ -176,10 +178,10 @@ TEST_F(PlatformChannelPairPosixTest, SendReceiveFDs) {
received_handles.pop_front();
ASSERT_TRUE(fp);
rewind(fp.get());
- char read_buf[100];
+ char read_buf[kPlatformChannelMaxNumHandles];
size_t bytes_read = fread(read_buf, 1, sizeof(read_buf), fp.get());
EXPECT_EQ(j + 1, bytes_read);
- EXPECT_EQ(std::string(j + 1, '0' + i), std::string(read_buf, bytes_read));
+ EXPECT_EQ(std::string(j + 1, c), std::string(read_buf, bytes_read));
}
}
}
@@ -203,18 +205,18 @@ TEST_F(PlatformChannelPairPosixTest, AppendReceivedFDs) {
ASSERT_TRUE(fp);
ASSERT_EQ(file_contents.size(),
fwrite(file_contents.data(), 1, file_contents.size(), fp.get()));
- PlatformHandleVector platform_handles;
- platform_handles.push_back(
+ ScopedPlatformHandleVectorPtr platform_handles(new PlatformHandleVector);
+ platform_handles->push_back(
test::PlatformHandleFromFILE(fp.Pass()).release());
- ASSERT_TRUE(platform_handles.back().is_valid());
+ ASSERT_TRUE(platform_handles->back().is_valid());
// Send the FD (+ "hello").
struct iovec iov = {const_cast<char*>(kHello), sizeof(kHello)};
// We assume that the |sendmsg()| actually sends all the data.
EXPECT_EQ(static_cast<ssize_t>(sizeof(kHello)),
PlatformChannelSendmsgWithHandles(server_handle.get(), &iov, 1,
- &platform_handles[0],
- platform_handles.size()));
+ &platform_handles->at(0),
+ platform_handles->size()));
}
WaitReadable(client_handle.get());
« no previous file with comments | « mojo/edk/embedder/entrypoints.cc ('k') | mojo/edk/js/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698