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

Side by Side Diff: runtime/observatory/test/debugging_test.dart

Issue 1071363002: Relocate service library tests and hookup a working status file (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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 | Annotate | Revision Log
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 --checked
5
6 import 'package:observatory/service_io.dart';
7 import 'package:unittest/unittest.dart';
8 import 'test_helper.dart';
9 import 'dart:async';
10
11 void helper(i) {
12 print(i);
13 }
14
15 void testFunction() {
16 int i = 0;
17 while (true) {
18 if (++i % 100000000 == 0) {
19 helper(i); // line 18
20 }
21 }
22 }
23
24 var tests = [
25
26 // Pause
27 (Isolate isolate) {
28 Completer completer = new Completer();
29 var subscription;
30 subscription = isolate.vm.events.stream.listen((ServiceEvent event) {
31 if (event.eventType == ServiceEvent.kPauseInterrupted) {
32 subscription.cancel();
33 completer.complete();
34 }
35 });
36 isolate.pause();
37 return completer.future;
38 },
39
40 // Resume
41 (Isolate isolate) {
42 Completer completer = new Completer();
43 var subscription;
44 subscription = isolate.vm.events.stream.listen((ServiceEvent event) {
45 if (event.eventType == ServiceEvent.kResume) {
46 subscription.cancel();
47 completer.complete();
48 }
49 });
50 isolate.resume();
51 return completer.future;
52 },
53
54 // Add breakpoint
55 (Isolate isolate) {
56 return isolate.rootLib.load().then((_) {
57 // Set up a listener to wait for breakpoint events.
58 Completer completer = new Completer();
59 var subscription;
60 subscription = isolate.vm.events.stream.listen((ServiceEvent event) {
61 if (event.eventType == ServiceEvent.kPauseBreakpoint) {
62 print('Breakpoint reached');
63 subscription.cancel();
64 completer.complete();
65 }
66 });
67
68 // Add the breakpoint.
69 var script = isolate.rootLib.scripts[0];
70 return isolate.addBreakpoint(script, 18).then((result) {
71 expect(result is Breakpoint, isTrue);
72 Breakpoint bpt = result;
73 expect(bpt.type, equals('Breakpoint'));
74 expect(bpt.script.id, equals(script.id));
75 expect(bpt.tokenPos, equals(58));
76 expect(isolate.breakpoints.length, equals(1));
77 return completer.future; // Wait for breakpoint events.
78 });
79 });
80 },
81
82 // Get the stack trace
83 (Isolate isolate) {
84 return isolate.getStack().then((ServiceMap stack) {
85 expect(stack.type, equals('Stack'));
86 expect(stack['frames'].length, greaterThanOrEqualTo(1));
87 expect(stack['frames'][0]['function'].name, equals('testFunction'));
88 expect(stack['frames'][0]['tokenPos'], equals(58));
89 });
90 },
91
92 // Stepping
93 (Isolate isolate) {
94 // Set up a listener to wait for breakpoint events.
95 Completer completer = new Completer();
96 var subscription;
97 subscription = isolate.vm.events.stream.listen((ServiceEvent event) {
98 if (event.eventType == ServiceEvent.kPauseBreakpoint) {
99 print('Breakpoint reached');
100 subscription.cancel();
101 completer.complete();
102 }
103 });
104
105 return isolate.stepInto().then((isolate) {
106 return completer.future; // Wait for breakpoint events.
107 });
108 },
109
110 // Get the stack trace again. Our position has updated.
111 (Isolate isolate) {
112 return isolate.getStack().then((ServiceMap stack) {
113 expect(stack.type, equals('Stack'));
114 expect(stack['frames'].length, greaterThanOrEqualTo(2));
115 expect(stack['frames'][0]['function'].name, equals('testFunction'));
116 expect(stack['frames'][0]['tokenPos'], equals(60));
117 });
118 },
119
120 // Remove breakpoint
121 (Isolate isolate) {
122 // Set up a listener to wait for breakpoint events.
123 Completer completer = new Completer();
124 var subscription;
125 subscription = isolate.vm.events.stream.listen((ServiceEvent event) {
126 if (event.eventType == ServiceEvent.kBreakpointRemoved) {
127 print('Breakpoint removed');
128 expect(isolate.breakpoints.length, equals(0));
129 subscription.cancel();
130 completer.complete();
131 }
132 });
133
134 expect(isolate.breakpoints.length, equals(1));
135 var bpt = isolate.breakpoints.values.first;
136 return isolate.removeBreakpoint(bpt).then((_) {
137 return completer.future;
138 });
139 },
140
141 // Resume
142 (Isolate isolate) {
143 Completer completer = new Completer();
144 var subscription;
145 subscription = isolate.vm.events.stream.listen((ServiceEvent event) {
146 if (event.eventType == ServiceEvent.kResume) {
147 subscription.cancel();
148 completer.complete();
149 }
150 });
151 isolate.resume();
152 return completer.future;
153 },
154
155 // Add breakpoint at function entry
156 (Isolate isolate) {
157 // Set up a listener to wait for breakpoint events.
158 Completer completer = new Completer();
159 var subscription;
160 subscription = isolate.vm.events.stream.listen((ServiceEvent event) {
161 if (event.eventType == ServiceEvent.kPauseBreakpoint) {
162 print('Breakpoint reached');
163 subscription.cancel();
164 completer.complete();
165 }
166 });
167
168 // Find a specific function.
169 ServiceFunction function = isolate.rootLib.functions.firstWhere(
170 (f) => f.name == 'helper');
171 expect(function, isNotNull);
172
173 // Add the breakpoint at function entry
174 return isolate.addBreakpointAtEntry(function).then((result) {
175 expect(result is Breakpoint, isTrue);
176 Breakpoint bpt = result;
177 expect(bpt.type, equals('Breakpoint'));
178 expect(bpt.script.name, equals('debugging_test.dart'));
179 expect(bpt.tokenPos, equals(29));
180 expect(isolate.breakpoints.length, equals(1));
181 return completer.future; // Wait for breakpoint events.
182 });
183 },
184
185 ];
186
187 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction);
OLDNEW
« no previous file with comments | « runtime/observatory/test/coverage_test.dart ('k') | runtime/observatory/test/dominator_tree_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698