mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 23:49:47 +00:00
a6e3008ded
See: https://dart-review.googlesource.com/c/sdk/+/196026 TEST=Code cleanup exclusively (sorting imports); no new tests. Change-Id: Ib07a82ff418138c542d6a83cfab9aabbb285f866 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196180 Auto-Submit: Phil Quitslund <pquitslund@google.com> Reviewed-by: Phil Quitslund <pquitslund@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Ben Konyi <bkonyi@google.com> Reviewed-by: Bob Nystrom <rnystrom@google.com> Commit-Queue: Phil Quitslund <pquitslund@google.com>
65 lines
1.7 KiB
Dart
65 lines
1.7 KiB
Dart
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
|
|
// 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.
|
|
|
|
import 'package:test/test.dart';
|
|
import 'package:vm_service/vm_service.dart';
|
|
|
|
import 'common/test_helper.dart';
|
|
|
|
fib(n) {
|
|
if (n < 0) return 0;
|
|
if (n == 0) return 1;
|
|
return fib(n - 1) + fib(n - 2);
|
|
}
|
|
|
|
testeeDo() {
|
|
print("Testee doing something.");
|
|
fib(30);
|
|
print("Testee did something.");
|
|
}
|
|
|
|
Future checkSamples(VmService service, IsolateRef isolate) async {
|
|
// Grab all the samples.
|
|
final isolateId = isolate.id!;
|
|
final result = await service.getCpuSamples(isolateId, 0, ~0);
|
|
|
|
final isString = TypeMatcher<String>();
|
|
final isInt = TypeMatcher<int>();
|
|
final isList = TypeMatcher<List>();
|
|
expect(result.functions!.length, greaterThan(10),
|
|
reason: "Should have many functions!");
|
|
|
|
final samples = result.samples!;
|
|
expect(samples.length, greaterThan(10), reason: "Should have many samples");
|
|
expect(samples.length, result.sampleCount);
|
|
|
|
final sample = samples.first;
|
|
expect(sample.tid, isInt);
|
|
expect(sample.timestamp, isInt);
|
|
if (sample.vmTag != null) {
|
|
expect(sample.vmTag, isString);
|
|
}
|
|
if (sample.userTag != null) {
|
|
expect(sample.userTag, isString);
|
|
}
|
|
expect(sample.stack, isList);
|
|
}
|
|
|
|
var tests = <IsolateTest>[
|
|
((VmService service, IsolateRef i) => checkSamples(service, i)),
|
|
];
|
|
|
|
var vmArgs = [
|
|
'--profiler=true',
|
|
'--profile-vm=false', // So this also works with KBC.
|
|
];
|
|
|
|
main([args = const <String>[]]) async => runIsolateTests(
|
|
args,
|
|
tests,
|
|
'get_cpu_samples_rpc_test.dart',
|
|
testeeBefore: testeeDo,
|
|
extraArgs: vmArgs,
|
|
);
|