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

Side by Side Diff: mojo/edk/system/multiprocess_message_pipe_unittest.cc

Issue 1956703005: EDK: Check that handle rights are preserved in various tests. (Closed) Base URL: https://github.com/domokit/mojo.git@work787_edk_handle_13.8
Patch Set: Created 4 years, 7 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include <stdint.h> 5 #include <stdint.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 uint32_t num_handles = 10; // Maximum number to receive. 242 uint32_t num_handles = 10; // Maximum number to receive.
243 CHECK_EQ(mp->ReadMessage(0, UserPointer<void>(&read_buffer[0]), 243 CHECK_EQ(mp->ReadMessage(0, UserPointer<void>(&read_buffer[0]),
244 MakeUserPointer(&num_bytes), &handles, &num_handles, 244 MakeUserPointer(&num_bytes), &handles, &num_handles,
245 MOJO_READ_MESSAGE_FLAG_NONE), 245 MOJO_READ_MESSAGE_FLAG_NONE),
246 MOJO_RESULT_OK); 246 MOJO_RESULT_OK);
247 read_buffer.resize(num_bytes); 247 read_buffer.resize(num_bytes);
248 CHECK_EQ(read_buffer, std::string("go 1")); 248 CHECK_EQ(read_buffer, std::string("go 1"));
249 CHECK_EQ(num_handles, 1u); 249 CHECK_EQ(num_handles, 1u);
250 250
251 CHECK_EQ(handles[0].dispatcher->GetType(), Dispatcher::Type::SHARED_BUFFER); 251 CHECK_EQ(handles[0].dispatcher->GetType(), Dispatcher::Type::SHARED_BUFFER);
252 // TODO(vtl): Also check the rights here once they're actually preserved? 252 CHECK_EQ(handles[0].rights, SharedBufferDispatcher::kDefaultHandleRights);
253 253
254 RefPtr<SharedBufferDispatcher> dispatcher( 254 RefPtr<SharedBufferDispatcher> dispatcher(
255 static_cast<SharedBufferDispatcher*>(handles[0].dispatcher.get())); 255 static_cast<SharedBufferDispatcher*>(handles[0].dispatcher.get()));
256 256
257 // Make a mapping. 257 // Make a mapping.
258 std::unique_ptr<PlatformSharedBufferMapping> mapping; 258 std::unique_ptr<PlatformSharedBufferMapping> mapping;
259 CHECK_EQ(dispatcher->MapBuffer(0, 100, MOJO_MAP_BUFFER_FLAG_NONE, &mapping), 259 CHECK_EQ(dispatcher->MapBuffer(0, 100, MOJO_MAP_BUFFER_FLAG_NONE, &mapping),
260 MOJO_RESULT_OK); 260 MOJO_RESULT_OK);
261 CHECK(mapping); 261 CHECK(mapping);
262 CHECK(mapping->GetBase()); 262 CHECK(mapping->GetBase());
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 char hello[32]; 430 char hello[32];
431 unsigned num_handles = 0; 431 unsigned num_handles = 0;
432 sscanf(read_buffer.c_str(), "%s %u", hello, &num_handles); 432 sscanf(read_buffer.c_str(), "%s %u", hello, &num_handles);
433 CHECK_EQ(std::string("hello"), std::string(hello)); 433 CHECK_EQ(std::string("hello"), std::string(hello));
434 CHECK_GT(num_handles, 0u); 434 CHECK_GT(num_handles, 0u);
435 CHECK_EQ(num_read_handles, num_handles); 435 CHECK_EQ(num_read_handles, num_handles);
436 436
437 for (size_t i = 0; i < num_read_handles; ++i) { 437 for (size_t i = 0; i < num_read_handles; ++i) {
438 CHECK_EQ(read_handles[i].dispatcher->GetType(), 438 CHECK_EQ(read_handles[i].dispatcher->GetType(),
439 Dispatcher::Type::PLATFORM_HANDLE); 439 Dispatcher::Type::PLATFORM_HANDLE);
440 // TODO(vtl): Also check the rights here once they're actually preserved? 440 CHECK_EQ(read_handles[i].rights,
441 PlatformHandleDispatcher::kDefaultHandleRights);
441 442
442 RefPtr<PlatformHandleDispatcher> dispatcher( 443 RefPtr<PlatformHandleDispatcher> dispatcher(
443 static_cast<PlatformHandleDispatcher*>( 444 static_cast<PlatformHandleDispatcher*>(
444 read_handles[i].dispatcher.get())); 445 read_handles[i].dispatcher.get()));
445 ScopedPlatformHandle h = dispatcher->PassPlatformHandle(); 446 ScopedPlatformHandle h = dispatcher->PassPlatformHandle();
446 CHECK(h.is_valid()); 447 CHECK(h.is_valid());
447 dispatcher->Close(); 448 dispatcher->Close();
448 449
449 util::ScopedFILE fp(FILEFromPlatformHandle(h.Pass(), "r")); 450 util::ScopedFILE fp(FILEFromPlatformHandle(h.Pass(), "r"));
450 CHECK(fp); 451 CHECK(fp);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 // Android multi-process tests are not executing the new process. This is flaky. 521 // Android multi-process tests are not executing the new process. This is flaky.
521 #if !defined(OS_ANDROID) 522 #if !defined(OS_ANDROID)
522 INSTANTIATE_TEST_CASE_P(PipeCount, 523 INSTANTIATE_TEST_CASE_P(PipeCount,
523 MultiprocessMessagePipeTestWithPipeCount, 524 MultiprocessMessagePipeTestWithPipeCount,
524 testing::Values(1u, 128u, 140u)); 525 testing::Values(1u, 128u, 140u));
525 #endif 526 #endif
526 527
527 } // namespace 528 } // namespace
528 } // namespace system 529 } // namespace system
529 } // namespace mojo 530 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/data_pipe_impl_unittest.cc ('k') | mojo/edk/system/remote_data_pipe_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698