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

Side by Side Diff: runtime/vm/isolate_test.cc

Issue 2554983002: Created methods to surface zone memory information for each isolate and thread in JSON. (Closed)
Patch Set: Created methods to surface zone memory information for each isolate and thread in JSON. Created 4 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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "platform/assert.h" 6 #include "platform/assert.h"
7 #include "vm/globals.h" 7 #include "vm/globals.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/lockers.h" 9 #include "vm/lockers.h"
10 #include "vm/thread_barrier.h" 10 #include "vm/thread_barrier.h"
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 239
240 // Restore, then clear interrupts. The world is as it was. 240 // Restore, then clear interrupts. The world is as it was.
241 interrupt_bits = thread->GetAndClearInterrupts(); 241 interrupt_bits = thread->GetAndClearInterrupts();
242 EXPECT_EQ(kMessageInterrupt, interrupt_bits); 242 EXPECT_EQ(kMessageInterrupt, interrupt_bits);
243 EXPECT_EQ(IsolateTestHelper::GetStackLimit(thread), 243 EXPECT_EQ(IsolateTestHelper::GetStackLimit(thread),
244 IsolateTestHelper::GetSavedStackLimit(thread)); 244 IsolateTestHelper::GetSavedStackLimit(thread));
245 EXPECT_EQ(kZero, IsolateTestHelper::GetDeferredInterruptsMask(thread)); 245 EXPECT_EQ(kZero, IsolateTestHelper::GetDeferredInterruptsMask(thread));
246 EXPECT_EQ(kZero, IsolateTestHelper::GetDeferredInterrupts(thread)); 246 EXPECT_EQ(kZero, IsolateTestHelper::GetDeferredInterrupts(thread));
247 } 247 }
248 248
249
250 #ifndef RELEASE
Cutch 2016/12/06 19:11:14 this doesn't look right.
bkonyi 2016/12/08 18:04:14 Yes, you're right. I've switched to if defined(DEB
251 UNIT_TEST_CASE(PrintIsolateInformationToJSON) {
252 Dart_Isolate isolate = Dart_CreateIsolate(
253 NULL, NULL, bin::isolate_snapshot_buffer, NULL, NULL, NULL);
254 EXPECT_EQ(isolate, Dart_CurrentIsolate());
255 JSONStream stream;
256 {
257 JSONObject obj(&stream);
Cutch 2016/12/06 19:11:14 These should probably be rewritten as service test
bkonyi 2016/12/08 18:04:14 As discussed offline, will add a test once I start
258 reinterpret_cast<Isolate*>(isolate)->PrintThreadsInfoToJSONObject(&obj);
259 }
260
261 char isolate_buf[64];
262 const char* json = stream.ToCString();
263 snprintf(isolate_buf, sizeof(isolate_buf),
264 "\"isolate_address\":\"0x%" Px "\"",
265 reinterpret_cast<uword>(isolate));
siva 2016/12/07 22:12:52 We use OS::SNPrint and not snprintf in order to ma
bkonyi 2016/12/08 18:04:14 Acknowledged.
266 EXPECT_SUBSTRING(isolate_buf, json);
267
siva 2016/12/07 22:12:52 How does this verify all the threads info that was
bkonyi 2016/12/08 18:04:14 Acknowledged. I'll be removing this test either wa
268 Dart_ShutdownIsolate();
269 }
270
271
272 UNIT_TEST_CASE(PrintAllIsolateInformationToJSON) {
273 Dart_Isolate isolate0 = TestCase::CreateTestIsolate();
274 EXPECT_EQ(isolate0, Dart_CurrentIsolate());
275
276 char isolate0_buf[64];
277 snprintf(isolate0_buf, sizeof(isolate0_buf),
278 "\"isolate_address\":\"0x%" Px "\"",
279 reinterpret_cast<uword>(isolate0));
280 {
281 JSONStream stream;
282 Isolate::PrintAllIsolatesMemoryInfoToJSONLocked(&stream);
283 const char* json = stream.ToCString();
284 EXPECT_SUBSTRING(isolate0_buf, json);
285 }
286
287 Dart_ExitIsolate();
288 // Create a second isolate to ensure info for all isolates is returned.
289 Dart_Isolate isolate1 = TestCase::CreateTestIsolate();
290 EXPECT_EQ(isolate1, Dart_CurrentIsolate());
291
292 char isolate1_buf[64];
293 snprintf(isolate1_buf, sizeof(isolate1_buf),
294 "\"isolate_address\":\"0x%" Px "\"",
295 reinterpret_cast<uword>(isolate1));
296 {
297 JSONStream stream;
298 Isolate::PrintAllIsolatesMemoryInfoToJSONLocked(&stream);
299 const char* json = stream.ToCString();
300 EXPECT_SUBSTRING(isolate0_buf, json);
301 EXPECT_SUBSTRING(isolate1_buf, json);
302 }
303
304 Dart_ShutdownIsolate();
305 Dart_EnterIsolate(isolate0);
306 Dart_ShutdownIsolate();
307 }
308 #endif
309
249 } // namespace dart 310 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698