Chromium Code Reviews| Index: runtime/observatory/tests/service/developer_get_service_id_for_isolate_test.dart |
| diff --git a/runtime/observatory/tests/service/developer_get_service_id_for_isolate_test.dart b/runtime/observatory/tests/service/developer_get_service_id_for_isolate_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c2cbafc1a01c29bc3a769eec67d9a29dc8b33048 |
| --- /dev/null |
| +++ b/runtime/observatory/tests/service/developer_get_service_id_for_isolate_test.dart |
| @@ -0,0 +1,89 @@ |
| +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
|
siva
2016/12/01 00:09:11
2016
Cutch
2016/12/01 20:41:30
Done.
|
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| +// VMOptions=--error_on_bad_type --error_on_bad_override |
| + |
| +import 'dart:async'; |
| +import 'dart:developer'; |
| +import 'dart:isolate' as I; |
| + |
| +import 'package:observatory/service_io.dart'; |
| +import 'package:unittest/unittest.dart'; |
| +import 'service_test_common.dart'; |
| +import 'test_helper.dart'; |
| + |
| + |
| +// testee state. |
| +String selfId; |
| +I.Isolate childIsolate; |
| +String childId; |
| + |
| +void spawnEntry(int i) { |
| + debugger(); |
| +} |
| + |
| +Future testeeMain() async { |
| + debugger(); |
| + // Spawn an isolate. |
| + childIsolate = await I.Isolate.spawn(spawnEntry, 0); |
| + // Assign the id for this isolate and it's child to strings so they can |
| + // be read by the tester. |
| + selfId = Service.getServiceIdForIsolate(I.Isolate.current); |
| + childId = Service.getServiceIdForIsolate(childIsolate); |
| + debugger(); |
| +} |
| + |
| +// tester state: |
| +Isolate initialIsolate; |
|
siva
2016/12/01 00:09:11
The usage of Isolate here is a little confusing wh
Cutch
2016/12/01 20:41:30
Done.
|
| +Isolate localChildIsolate; |
| + |
| +var tests = [ |
| + (VM vm) async { |
| + // Sanity check. |
| + expect(vm.isolates.length, 1); |
| + initialIsolate = vm.isolates[0]; |
| + await hasStoppedAtBreakpoint(initialIsolate); |
| + // Resume. |
| + await initialIsolate.resume(); |
| + }, |
| + (VM vm) async { |
| + // Initial isolate has paused at second debugger call. |
| + await hasStoppedAtBreakpoint(initialIsolate); |
| + }, |
| + (VM vm) async { |
| + // Reload the VM. |
| + await vm.reload(); |
| + |
| + // Grab the child isolate. |
| + localChildIsolate = |
| + vm.isolates.firstWhere((Isolate i) => i != initialIsolate); |
| + expect(localChildIsolate, isNotNull); |
| + |
| + // Reload the initial isolate. |
| + await initialIsolate.reload(); |
| + |
| + // Grab the root library. |
| + Library rootLbirary = await initialIsolate.rootLibrary.load(); |
| + |
| + // Grab self id. |
| + Instance localSelfId = |
| + await initialIsolate.eval(rootLbirary, 'selfId'); |
| + |
| + // Check that the id reported from dart:developer matches the id reported |
| + // from the service protocol. |
| + expect(localSelfId.isString, true); |
| + expect(initialIsolate.id, equals(localSelfId.valueAsString)); |
| + |
| + // Grab the child isolate's id. |
| + Instance localChildId = |
| + await initialIsolate.eval(rootLbirary, 'childId'); |
| + |
| + // Check that the id reported from dart:developer matches the id reported |
| + // from the service protocol. |
| + expect(localChildId.isString, true); |
| + expect(localChildIsolate.id, equals(localChildId.valueAsString)); |
| + } |
| +]; |
| + |
| +main(args) async => runVMTests(args, tests, |
| + testeeConcurrent: testeeMain); |
|
siva
2016/12/01 00:09:11
This test would probably fail in dartium and poten
Cutch
2016/12/01 20:41:30
All tests in this directory rely on dart:io and so
|