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

Unified Diff: runtime/observatory/tests/service/service_test_common.dart

Issue 2680303002: Kernel debugging; service tests (Closed)
Patch Set: New failing test Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: runtime/observatory/tests/service/service_test_common.dart
diff --git a/runtime/observatory/tests/service/service_test_common.dart b/runtime/observatory/tests/service/service_test_common.dart
index 45e8b46c9e6248a00652859619c15422e28d0fa1..43255c4dab5063cd0f8c2b383853a79058b8aa18 100644
--- a/runtime/observatory/tests/service/service_test_common.dart
+++ b/runtime/observatory/tests/service/service_test_common.dart
@@ -262,7 +262,8 @@ IsolateTest stoppedAtLine(int line) {
}
-IsolateTest stoppedInFunction(String functionName, {bool contains: false}) {
+IsolateTest stoppedInFunction(String functionName,
+ {bool contains: false, bool includeOwner: false}) {
return (Isolate isolate) async {
print("Checking we are in function: $functionName");
@@ -274,13 +275,19 @@ IsolateTest stoppedInFunction(String functionName, {bool contains: false}) {
Frame topFrame = stack['frames'][0];
ServiceFunction function = await topFrame.function.load();
- final bool matches =
- contains ? function.name.contains(functionName) :
- function.name == functionName;
+ String foundFunctionName = function.name;
+ if (includeOwner) {
+ await (function.dartOwner as ServiceObject).load();
+ String ownerName = (function.dartOwner as ServiceObject).name;
+ foundFunctionName = "$ownerName.$foundFunctionName";
+ }
+ final bool matches = contains
+ ? foundFunctionName.contains(functionName)
+ : foundFunctionName == functionName;
if (!matches) {
StringBuffer sb = new StringBuffer();
sb.write("Expected to be in function $functionName but "
- "actually in function ${function.name}");
+ "actually in function ${function.name}");
sb.write("\nFull stack trace:\n");
for (Frame f in stack['frames']) {
await f.function.load();
@@ -296,7 +303,6 @@ IsolateTest stoppedInFunction(String functionName, {bool contains: false}) {
};
}
-
Future<Isolate> resumeIsolate(Isolate isolate) {
Completer completer = new Completer();
isolate.vm.getEventStream(VM.kDebugStream).then((stream) {
@@ -379,3 +385,45 @@ Future<Instance> rootLibraryFieldValue(Isolate isolate,
await value.load();
return value;
}
+
+IsolateTest runStepThroughProgramRecordingStops(List<String> recordStops) {
+ return (Isolate isolate) async {
+ Completer completer = new Completer();
+
+ await subscribeToStream(isolate.vm, VM.kDebugStream,
+ (ServiceEvent event) async {
+ if (event.kind == ServiceEvent.kPauseBreakpoint) {
+ await isolate.reload();
+ // We are paused: Step further.
+ Frame frame = isolate.topFrame;
+ recordStops.add(await frame.location.toUserString());
+ if (event.atAsyncSuspension) {
+ isolate.stepOverAsyncSuspension();
+ } else {
+ isolate.stepOver();
+ }
+ } else if (event.kind == ServiceEvent.kPauseExit) {
+ // We are at the exit: The test is done.
+ await cancelStreamSubscription(VM.kDebugStream);
+ completer.complete();
+ }
+ });
+ isolate.resume();
+ return completer.future;
+ };
+}
+
+IsolateTest checkRecordedStops(
+ List<String> recordStops, List<String> expectedStops) {
+ return (Isolate isolate) async {
+ int end = recordStops.length < expectedStops.length
+ ? recordStops.length
+ : expectedStops.length;
+ for (int i = 0; i < end; ++i) {
+ expect(recordStops[i], expectedStops[i]);
+ }
+
+ expect(recordStops.length >= expectedStops.length, true,
+ reason: "Expects at least ${expectedStops.length} breaks.");
+ };
+}

Powered by Google App Engine
This is Rietveld 408576698