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

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

Issue 728783003: Add infrastructure to run tests on android. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Follow review Created 6 years 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 <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 static_cast<uint32_t>(write_buffer.size()), 89 static_cast<uint32_t>(write_buffer.size()),
90 nullptr, MOJO_WRITE_MESSAGE_FLAG_NONE), 90 nullptr, MOJO_WRITE_MESSAGE_FLAG_NONE),
91 MOJO_RESULT_OK); 91 MOJO_RESULT_OK);
92 } 92 }
93 93
94 mp->Close(0); 94 mp->Close(0);
95 return rv; 95 return rv;
96 } 96 }
97 97
98 // Sends "hello" to child, and expects "hellohello" back. 98 // Sends "hello" to child, and expects "hellohello" back.
99 TEST_F(MultiprocessMessagePipeTest, Basic) { 99 #if defined(OS_ANDROID)
100 // Android multi-process tests are not executing the new process. This is flaky.
viettrungluu 2014/11/25 16:45:09 "
101 #define MAYBE_Basic DISABLED_Basic
102 #else
103 #define MAYBE_Basic Basic
104 #endif // defined(OS_ANDROID)
105 TEST_F(MultiprocessMessagePipeTest, MAYBE_Basic) {
100 helper()->StartChild("EchoEcho"); 106 helper()->StartChild("EchoEcho");
101 107
102 scoped_refptr<ChannelEndpoint> ep; 108 scoped_refptr<ChannelEndpoint> ep;
103 scoped_refptr<MessagePipe> mp(MessagePipe::CreateLocalProxy(&ep)); 109 scoped_refptr<MessagePipe> mp(MessagePipe::CreateLocalProxy(&ep));
104 Init(ep); 110 Init(ep);
105 111
106 std::string hello("hello"); 112 std::string hello("hello");
107 EXPECT_EQ(MOJO_RESULT_OK, 113 EXPECT_EQ(MOJO_RESULT_OK,
108 mp->WriteMessage(0, UserPointer<const void>(hello.data()), 114 mp->WriteMessage(0, UserPointer<const void>(hello.data()),
109 static_cast<uint32_t>(hello.size()), nullptr, 115 static_cast<uint32_t>(hello.size()), nullptr,
(...skipping 19 matching lines...) Expand all
129 EXPECT_EQ(hello + hello, read_buffer); 135 EXPECT_EQ(hello + hello, read_buffer);
130 136
131 mp->Close(0); 137 mp->Close(0);
132 138
133 // We sent one message. 139 // We sent one message.
134 EXPECT_EQ(1 % 100, helper()->WaitForChildShutdown()); 140 EXPECT_EQ(1 % 100, helper()->WaitForChildShutdown());
135 } 141 }
136 142
137 // Sends a bunch of messages to the child. Expects them "repeated" back. Waits 143 // Sends a bunch of messages to the child. Expects them "repeated" back. Waits
138 // for the child to close its end before quitting. 144 // for the child to close its end before quitting.
139 TEST_F(MultiprocessMessagePipeTest, QueueMessages) { 145 #if defined(OS_ANDROID)
146 // Android multi-process tests are not executing the new process. This is flaky.
147 #define MAYBE_QueueMessages DISABLED_QueueMessages
148 #else
149 #define MAYBE_QueueMessages QueueMessages
150 #endif // defined(OS_ANDROID)
151 TEST_F(MultiprocessMessagePipeTest, DISABLED_QueueMessages) {
140 helper()->StartChild("EchoEcho"); 152 helper()->StartChild("EchoEcho");
141 153
142 scoped_refptr<ChannelEndpoint> ep; 154 scoped_refptr<ChannelEndpoint> ep;
143 scoped_refptr<MessagePipe> mp(MessagePipe::CreateLocalProxy(&ep)); 155 scoped_refptr<MessagePipe> mp(MessagePipe::CreateLocalProxy(&ep));
144 Init(ep); 156 Init(ep);
145 157
146 static const size_t kNumMessages = 1001; 158 static const size_t kNumMessages = 1001;
147 for (size_t i = 0; i < kNumMessages; i++) { 159 for (size_t i = 0; i < kNumMessages; i++) {
148 std::string write_buffer(i, 'A' + (i % 26)); 160 std::string write_buffer(i, 'A' + (i % 26));
149 EXPECT_EQ(MOJO_RESULT_OK, 161 EXPECT_EQ(MOJO_RESULT_OK,
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 // It should have written something to the shared buffer. 287 // It should have written something to the shared buffer.
276 static const char kWorld[] = "world!!!"; 288 static const char kWorld[] = "world!!!";
277 CHECK_EQ(memcmp(mapping->GetBase(), kWorld, sizeof(kWorld)), 0); 289 CHECK_EQ(memcmp(mapping->GetBase(), kWorld, sizeof(kWorld)), 0);
278 290
279 // And we're done. 291 // And we're done.
280 mp->Close(0); 292 mp->Close(0);
281 293
282 return 0; 294 return 0;
283 } 295 }
284 296
285 #if defined(OS_POSIX) 297 #if defined(OS_POSIX) && !defined(OS_ANDROID)
286 #define MAYBE_SharedBufferPassing SharedBufferPassing 298 #define MAYBE_SharedBufferPassing SharedBufferPassing
287 #else 299 #else
288 // Not yet implemented (on Windows). 300 // Not yet implemented (on Windows).
301 // Android multi-process tests are not executing the new process. This is flaky.
289 #define MAYBE_SharedBufferPassing DISABLED_SharedBufferPassing 302 #define MAYBE_SharedBufferPassing DISABLED_SharedBufferPassing
290 #endif 303 #endif
291 TEST_F(MultiprocessMessagePipeTest, MAYBE_SharedBufferPassing) { 304 TEST_F(MultiprocessMessagePipeTest, MAYBE_SharedBufferPassing) {
292 helper()->StartChild("CheckSharedBuffer"); 305 helper()->StartChild("CheckSharedBuffer");
293 306
294 scoped_refptr<ChannelEndpoint> ep; 307 scoped_refptr<ChannelEndpoint> ep;
295 scoped_refptr<MessagePipe> mp(MessagePipe::CreateLocalProxy(&ep)); 308 scoped_refptr<MessagePipe> mp(MessagePipe::CreateLocalProxy(&ep));
296 Init(ep); 309 Init(ep);
297 310
298 // Make a shared buffer. 311 // Make a shared buffer.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 base::ScopedFILE fp(mojo::test::FILEFromPlatformHandle(h.Pass(), "r")); 428 base::ScopedFILE fp(mojo::test::FILEFromPlatformHandle(h.Pass(), "r"));
416 CHECK(fp); 429 CHECK(fp);
417 std::string fread_buffer(100, '\0'); 430 std::string fread_buffer(100, '\0');
418 size_t bytes_read = fread(&fread_buffer[0], 1, fread_buffer.size(), fp.get()); 431 size_t bytes_read = fread(&fread_buffer[0], 1, fread_buffer.size(), fp.get());
419 fread_buffer.resize(bytes_read); 432 fread_buffer.resize(bytes_read);
420 CHECK_EQ(fread_buffer, "world"); 433 CHECK_EQ(fread_buffer, "world");
421 434
422 return 0; 435 return 0;
423 } 436 }
424 437
425 #if defined(OS_POSIX) 438 #if defined(OS_POSIX) && !defined(OS_ANDROID)
426 #define MAYBE_PlatformHandlePassing PlatformHandlePassing 439 #define MAYBE_PlatformHandlePassing PlatformHandlePassing
427 #else 440 #else
428 // Not yet implemented (on Windows). 441 // Not yet implemented (on Windows).
442 // Android multi-process tests are not executing the new process. This is flaky.
429 #define MAYBE_PlatformHandlePassing DISABLED_PlatformHandlePassing 443 #define MAYBE_PlatformHandlePassing DISABLED_PlatformHandlePassing
430 #endif 444 #endif
431 TEST_F(MultiprocessMessagePipeTest, MAYBE_PlatformHandlePassing) { 445 TEST_F(MultiprocessMessagePipeTest, MAYBE_PlatformHandlePassing) {
432 base::ScopedTempDir temp_dir; 446 base::ScopedTempDir temp_dir;
433 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 447 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
434 448
435 helper()->StartChild("CheckPlatformHandleFile"); 449 helper()->StartChild("CheckPlatformHandleFile");
436 450
437 scoped_refptr<ChannelEndpoint> ep; 451 scoped_refptr<ChannelEndpoint> ep;
438 scoped_refptr<MessagePipe> mp(MessagePipe::CreateLocalProxy(&ep)); 452 scoped_refptr<MessagePipe> mp(MessagePipe::CreateLocalProxy(&ep));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 EXPECT_EQ(0u, hss.satisfiable_signals); 489 EXPECT_EQ(0u, hss.satisfiable_signals);
476 490
477 mp->Close(0); 491 mp->Close(0);
478 492
479 EXPECT_EQ(0, helper()->WaitForChildShutdown()); 493 EXPECT_EQ(0, helper()->WaitForChildShutdown());
480 } 494 }
481 495
482 } // namespace 496 } // namespace
483 } // namespace system 497 } // namespace system
484 } // namespace mojo 498 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698