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

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

Issue 1492943005: Remove ShutdownIPCSupportAndWaitForNoChannels. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « mojo/edk/embedder/embedder_internal.h ('k') | mojo/edk/system/raw_channel.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 159
160 static const size_t kNumMessages = 1001; 160 static const size_t kNumMessages = 1001;
161 for (size_t i = 0; i < kNumMessages; i++) { 161 for (size_t i = 0; i < kNumMessages; i++) {
162 std::string write_buffer(i, 'A' + (i % 26)); 162 std::string write_buffer(i, 'A' + (i % 26));
163 ASSERT_EQ(MOJO_RESULT_OK, 163 ASSERT_EQ(MOJO_RESULT_OK,
164 MojoWriteMessage(mp.get().value(), write_buffer.data(), 164 MojoWriteMessage(mp.get().value(), write_buffer.data(),
165 static_cast<uint32_t>(write_buffer.size()), 165 static_cast<uint32_t>(write_buffer.size()),
166 nullptr, 0u, MOJO_WRITE_MESSAGE_FLAG_NONE)); 166 nullptr, 0u, MOJO_WRITE_MESSAGE_FLAG_NONE));
167 } 167 }
168 168
169 const std::string quitquitquit("quitquitquit");
170 ASSERT_EQ(MOJO_RESULT_OK,
171 MojoWriteMessage(mp.get().value(), quitquitquit.data(),
172 static_cast<uint32_t>(quitquitquit.size()),
173 nullptr, 0u, MOJO_WRITE_MESSAGE_FLAG_NONE));
174
175 for (size_t i = 0; i < kNumMessages; i++) { 169 for (size_t i = 0; i < kNumMessages; i++) {
176 HandleSignalsState hss; 170 HandleSignalsState hss;
177 ASSERT_EQ(MOJO_RESULT_OK, 171 ASSERT_EQ(MOJO_RESULT_OK,
178 MojoWait(mp.get().value(), MOJO_HANDLE_SIGNAL_READABLE, 172 MojoWait(mp.get().value(), MOJO_HANDLE_SIGNAL_READABLE,
179 MOJO_DEADLINE_INDEFINITE, &hss)); 173 MOJO_DEADLINE_INDEFINITE, &hss));
180 // The child may or may not have closed its end of the message pipe and died 174 // The child may or may not have closed its end of the message pipe and died
181 // (and we may or may not know it yet), so our end may or may not appear as 175 // (and we may or may not know it yet), so our end may or may not appear as
182 // writable. 176 // writable.
183 ASSERT_TRUE((hss.satisfied_signals & MOJO_HANDLE_SIGNAL_READABLE)); 177 ASSERT_TRUE((hss.satisfied_signals & MOJO_HANDLE_SIGNAL_READABLE));
184 ASSERT_TRUE((hss.satisfiable_signals & MOJO_HANDLE_SIGNAL_READABLE)); 178 ASSERT_TRUE((hss.satisfiable_signals & MOJO_HANDLE_SIGNAL_READABLE));
185 179
186 std::string read_buffer(kNumMessages * 2, '\0'); 180 std::string read_buffer(kNumMessages * 2, '\0');
187 uint32_t read_buffer_size = static_cast<uint32_t>(read_buffer.size()); 181 uint32_t read_buffer_size = static_cast<uint32_t>(read_buffer.size());
188 ASSERT_EQ(MojoReadMessage(mp.get().value(), &read_buffer[0], 182 ASSERT_EQ(MojoReadMessage(mp.get().value(), &read_buffer[0],
189 &read_buffer_size, nullptr, 0, 183 &read_buffer_size, nullptr, 0,
190 MOJO_READ_MESSAGE_FLAG_NONE), 184 MOJO_READ_MESSAGE_FLAG_NONE),
191 MOJO_RESULT_OK); 185 MOJO_RESULT_OK);
192 read_buffer.resize(read_buffer_size); 186 read_buffer.resize(read_buffer_size);
193 187
194 ASSERT_EQ(std::string(i * 2, 'A' + (i % 26)), read_buffer); 188 ASSERT_EQ(std::string(i * 2, 'A' + (i % 26)), read_buffer);
195 } 189 }
196 190
191 const std::string quitquitquit("quitquitquit");
192 ASSERT_EQ(MOJO_RESULT_OK,
193 MojoWriteMessage(mp.get().value(), quitquitquit.data(),
194 static_cast<uint32_t>(quitquitquit.size()),
195 nullptr, 0u, MOJO_WRITE_MESSAGE_FLAG_NONE));
196
197 // Wait for it to become readable, which should fail (since we sent 197 // Wait for it to become readable, which should fail (since we sent
198 // "quitquitquit"). 198 // "quitquitquit").
199 HandleSignalsState hss; 199 HandleSignalsState hss;
200 ASSERT_EQ(MOJO_RESULT_FAILED_PRECONDITION, 200 ASSERT_EQ(MOJO_RESULT_FAILED_PRECONDITION,
201 MojoWait(mp.get().value(), MOJO_HANDLE_SIGNAL_READABLE, 201 MojoWait(mp.get().value(), MOJO_HANDLE_SIGNAL_READABLE,
202 MOJO_DEADLINE_INDEFINITE, &hss)); 202 MOJO_DEADLINE_INDEFINITE, &hss));
203 ASSERT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfied_signals); 203 ASSERT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfied_signals);
204 ASSERT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfiable_signals); 204 ASSERT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfiable_signals);
205 205
206 ASSERT_EQ(static_cast<int>(kNumMessages % 100), 206 ASSERT_EQ(static_cast<int>(kNumMessages % 100),
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 777
778 MojoClose(mp1); 778 MojoClose(mp1);
779 MojoClose(mp.release().value()); 779 MojoClose(mp.release().value());
780 780
781 ASSERT_EQ(0, helper()->WaitForChildShutdown()); 781 ASSERT_EQ(0, helper()->WaitForChildShutdown());
782 } 782 }
783 783
784 } // namespace 784 } // namespace
785 } // namespace edk 785 } // namespace edk
786 } // namespace mojo 786 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/embedder/embedder_internal.h ('k') | mojo/edk/system/raw_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698