Chromium Code Reviews| Index: runtime/vm/isolate_test.cc |
| diff --git a/runtime/vm/isolate_test.cc b/runtime/vm/isolate_test.cc |
| index 5e71ed7fa95d547429fcbbece69f81f439b42b9b..8d6bd1de1ab26806a27c91aef67a6ac0c224b2f4 100644 |
| --- a/runtime/vm/isolate_test.cc |
| +++ b/runtime/vm/isolate_test.cc |
| @@ -246,4 +246,65 @@ TEST_CASE(NoOOBMessageScope) { |
| EXPECT_EQ(kZero, IsolateTestHelper::GetDeferredInterrupts(thread)); |
| } |
| + |
| +#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
|
| +UNIT_TEST_CASE(PrintIsolateInformationToJSON) { |
| + Dart_Isolate isolate = Dart_CreateIsolate( |
| + NULL, NULL, bin::isolate_snapshot_buffer, NULL, NULL, NULL); |
| + EXPECT_EQ(isolate, Dart_CurrentIsolate()); |
| + JSONStream stream; |
| + { |
| + 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
|
| + reinterpret_cast<Isolate*>(isolate)->PrintThreadsInfoToJSONObject(&obj); |
| + } |
| + |
| + char isolate_buf[64]; |
| + const char* json = stream.ToCString(); |
| + snprintf(isolate_buf, sizeof(isolate_buf), |
| + "\"isolate_address\":\"0x%" Px "\"", |
| + 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.
|
| + EXPECT_SUBSTRING(isolate_buf, json); |
| + |
|
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
|
| + Dart_ShutdownIsolate(); |
| +} |
| + |
| + |
| +UNIT_TEST_CASE(PrintAllIsolateInformationToJSON) { |
| + Dart_Isolate isolate0 = TestCase::CreateTestIsolate(); |
| + EXPECT_EQ(isolate0, Dart_CurrentIsolate()); |
| + |
| + char isolate0_buf[64]; |
| + snprintf(isolate0_buf, sizeof(isolate0_buf), |
| + "\"isolate_address\":\"0x%" Px "\"", |
| + reinterpret_cast<uword>(isolate0)); |
| + { |
| + JSONStream stream; |
| + Isolate::PrintAllIsolatesMemoryInfoToJSONLocked(&stream); |
| + const char* json = stream.ToCString(); |
| + EXPECT_SUBSTRING(isolate0_buf, json); |
| + } |
| + |
| + Dart_ExitIsolate(); |
| + // Create a second isolate to ensure info for all isolates is returned. |
| + Dart_Isolate isolate1 = TestCase::CreateTestIsolate(); |
| + EXPECT_EQ(isolate1, Dart_CurrentIsolate()); |
| + |
| + char isolate1_buf[64]; |
| + snprintf(isolate1_buf, sizeof(isolate1_buf), |
| + "\"isolate_address\":\"0x%" Px "\"", |
| + reinterpret_cast<uword>(isolate1)); |
| + { |
| + JSONStream stream; |
| + Isolate::PrintAllIsolatesMemoryInfoToJSONLocked(&stream); |
| + const char* json = stream.ToCString(); |
| + EXPECT_SUBSTRING(isolate0_buf, json); |
| + EXPECT_SUBSTRING(isolate1_buf, json); |
| + } |
| + |
| + Dart_ShutdownIsolate(); |
| + Dart_EnterIsolate(isolate0); |
| + Dart_ShutdownIsolate(); |
| +} |
| +#endif |
| + |
| } // namespace dart |