OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // VMOptions=--compile-all --error_on_bad_type --error_on_bad_override | 4 // VMOptions=--compile-all --error_on_bad_type --error_on_bad_override |
5 | 5 |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'dart:isolate' as I; | 7 import 'dart:isolate' as I; |
8 | 8 |
9 import 'package:observatory/service_io.dart'; | 9 import 'package:observatory/service_io.dart'; |
10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 running++; | 47 running++; |
48 } | 48 } |
49 } | 49 } |
50 return running; | 50 return running; |
51 } | 51 } |
52 | 52 |
53 var tests = [ | 53 var tests = [ |
54 (VM vm) async { | 54 (VM vm) async { |
55 // Wait for the testee to start all of the isolates. | 55 // Wait for the testee to start all of the isolates. |
56 if (vm.isolates.length != spawnCount + 1) { | 56 if (vm.isolates.length != spawnCount + 1) { |
57 await processServiceEvents(vm, (event, sub, completer) { | 57 await processServiceEvents(vm, VM.kIsolateEventStreamId, |
| 58 (event, sub, completer) { |
58 if (event.eventType == ServiceEvent.kIsolateStart) { | 59 if (event.eventType == ServiceEvent.kIsolateStart) { |
59 if (vm.isolates.length == spawnCount + 1) { | 60 if (vm.isolates.length == spawnCount + 1) { |
60 sub.cancel(); | 61 sub.cancel(); |
61 completer.complete(null); | 62 completer.complete(null); |
62 } | 63 } |
63 } | 64 } |
64 }); | 65 }); |
65 } | 66 } |
66 expect(vm.isolates.length, spawnCount + 1); | 67 expect(vm.isolates.length, spawnCount + 1); |
67 }, | 68 }, |
68 | 69 |
69 (VM vm) async { | 70 (VM vm) async { |
70 // Load each isolate. | 71 // Load each isolate. |
71 for (var isolate in vm.isolates) { | 72 for (var isolate in vm.isolates) { |
72 await isolate.load(); | 73 await isolate.load(); |
73 } | 74 } |
74 }, | 75 }, |
75 | 76 |
76 (VM vm) async { | 77 (VM vm) async { |
77 // Wait for all spawned isolates to hit pause-at-exit. | 78 // Wait for all spawned isolates to hit pause-at-exit. |
78 if (numPaused(vm) != spawnCount) { | 79 if (numPaused(vm) != spawnCount) { |
79 await processServiceEvents(vm, (event, sub, completer) { | 80 await processServiceEvents(vm, VM.kDebugEventStreamId, |
| 81 (event, sub, completer) { |
80 if (event.eventType == ServiceEvent.kPauseExit) { | 82 if (event.eventType == ServiceEvent.kPauseExit) { |
81 if (numPaused(vm) == spawnCount) { | 83 if (numPaused(vm) == spawnCount) { |
82 sub.cancel(); | 84 sub.cancel(); |
83 completer.complete(null); | 85 completer.complete(null); |
84 } | 86 } |
85 } | 87 } |
86 }); | 88 }); |
87 } | 89 } |
88 expect(numPaused(vm), spawnCount); | 90 expect(numPaused(vm), spawnCount); |
89 expect(numRunning(vm), 1); | 91 expect(numRunning(vm), 1); |
90 }, | 92 }, |
91 | 93 |
92 | 94 |
93 (VM vm) async { | 95 (VM vm) async { |
94 var resumedReceived = 0; | 96 var resumedReceived = 0; |
95 var eventsDone = processServiceEvents(vm, (event, sub, completer) { | 97 var eventsDone = processServiceEvents(vm, VM.kIsolateEventStreamId, |
| 98 (event, sub, completer) { |
96 if (event.eventType == ServiceEvent.kIsolateExit) { | 99 if (event.eventType == ServiceEvent.kIsolateExit) { |
97 resumedReceived++; | 100 resumedReceived++; |
98 if (resumedReceived == resumeCount) { | 101 if (resumedReceived == resumeCount) { |
99 sub.cancel(); | 102 sub.cancel(); |
100 completer.complete(null); | 103 completer.complete(null); |
101 } | 104 } |
102 } | 105 } |
103 }); | 106 }); |
104 var resumesIssued = 0; | 107 var resumesIssued = 0; |
105 var isolateList = vm.isolates.toList(); | 108 var isolateList = vm.isolates.toList(); |
(...skipping 15 matching lines...) Expand all Loading... |
121 (VM vm) async { | 124 (VM vm) async { |
122 expect(numPaused(vm), spawnCount - resumeCount); | 125 expect(numPaused(vm), spawnCount - resumeCount); |
123 expect(numRunning(vm), 1); | 126 expect(numRunning(vm), 1); |
124 }, | 127 }, |
125 ]; | 128 ]; |
126 | 129 |
127 main(args) async => runVMTests(args, tests, | 130 main(args) async => runVMTests(args, tests, |
128 testeeBefore: before, | 131 testeeBefore: before, |
129 testeeConcurrent: during, | 132 testeeConcurrent: during, |
130 pause_on_exit: true); | 133 pause_on_exit: true); |
OLD | NEW |