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

Side by Side Diff: runtime/observatory/tests/service/vm_restart_test.dart

Issue 1371193005: VM restart + shutdown fixes (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fix ups Created 5 years, 2 months 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4 // VMOptions=--compile-all --error_on_bad_type --error_on_bad_override
5
6 import 'dart:async';
7 import 'dart:developer';
8 import 'dart:io';
9 import 'package:observatory/service_io.dart';
10 import 'package:unittest/unittest.dart';
11 import 'test_helper.dart';
12
13 int count = 0;
14
15 void test() {
16 while (true) {
17 count++;
18 debugger();
19 }
20 }
21
22 var tests = [
23 hasStoppedAtBreakpoint,
24
25 (Isolate isolate) async {
26 // The loop has run one time.
27 var result = await isolate.rootLibrary.evaluate('count');
28 expect(result.type, equals('Instance'));
29 expect(result.valueAsString, equals('1'));
30
31 Completer completer = new Completer();
32 var stream = await isolate.vm.getEventStream(VM.kDebugStream);
33 var subscription;
34 subscription = stream.listen((ServiceEvent event) {
35 if (event.kind == ServiceEvent.kResume) {
36 subscription.cancel();
37 completer.complete();
38 }
39 });
40 isolate.resume();
41 await completer.future;
42
43 // The loop has run twice.
44 result = await isolate.rootLibrary.evaluate('count');
45 expect(result.type, equals('Instance'));
46 expect(result.valueAsString, equals('2'));
47 },
48
49 hasStoppedAtBreakpoint,
50
51 (Isolate isolate) async {
52 Isolate newIsolate = null;
53
54 Completer testCompleter = new Completer();
55 var debugStream = await isolate.vm.getEventStream(VM.kDebugStream);
56 var debugSub;
57 debugSub = debugStream.listen((ServiceEvent event) {
58 if (event.kind == ServiceEvent.kPauseBreakpoint) {
59 if (event.isolate == newIsolate) {
60 // The old isolate has died and the new isolate is at
61 // the breakpoint.
62 newIsolate.reload().then((_) {
63 newIsolate.rootLibrary.evaluate('count').then((result) {
64 expect(result.type, equals('Instance'));
65 expect(result.valueAsString, equals('1'));
66 debugSub.cancel();
67 testCompleter.complete();
68 });
69 });
70 }
71 }
72 });
73
74 Completer restartCompleter = new Completer();
75 var isolateStream = await isolate.vm.getEventStream(VM.kIsolateStream);
76 var isolateSub;
77 bool exit = false;
78 bool start = false;
79 isolateSub = isolateStream.listen((ServiceEvent event) {
80 if (event.kind == ServiceEvent.kIsolateExit) {
81 print('Old isolate exited');
82 expect(event.isolate, equals(isolate));
Cutch 2015/10/05 18:10:46 nit: flip order of print and expect
turnidge 2015/10/05 22:18:24 Done.
83 exit = true;
84 }
85 if (event.kind == ServiceEvent.kIsolateStart) {
86 print('New isolate started');
87 newIsolate = event.isolate;
88 start = true;
89 }
90 if (exit && start) {
91 isolateSub.cancel();
92 restartCompleter.complete();
93 }
94 });
95
96 // Restart the vm.
97 print("restarting");
98 await isolate.vm.restart();
99 await restartCompleter.future;
100 print("restarted");
101 await testCompleter.future;
102 },
103 ];
104
105
106 main(args) => runIsolateTests(args, tests, testeeConcurrent: test);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698