1efe7e2518
Change-Id: If15e49d7aab93382c15529a738b492552faf5376 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95489 Commit-Queue: Ben Konyi <bkonyi@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com>
50 lines
1.6 KiB
Dart
50 lines
1.6 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:observatory/service_io.dart';
|
|
import 'package:unittest/unittest.dart';
|
|
|
|
import 'test_helper.dart';
|
|
|
|
var tests = <VMTest>[
|
|
(VM vm) async {
|
|
var params = {
|
|
'isolateId': vm.isolates.first.id,
|
|
};
|
|
var result = await vm.invokeRpcNoUpgrade('getMemoryUsage', params);
|
|
expect(result['type'], equals('MemoryUsage'));
|
|
expect(result['heapUsage'], isPositive);
|
|
expect(result['heapCapacity'], isPositive);
|
|
expect(result['externalUsage'], isPositive);
|
|
},
|
|
(VM vm) async {
|
|
var params = {
|
|
'isolateId': 'badid',
|
|
};
|
|
bool caughtException;
|
|
try {
|
|
await vm.invokeRpcNoUpgrade('getMemoryUsage', params);
|
|
expect(false, isTrue, reason: 'Unreachable');
|
|
} on ServerRpcException catch (e) {
|
|
caughtException = true;
|
|
expect(e.code, equals(ServerRpcException.kInvalidParams));
|
|
expect(e.message, "getMemoryUsage: invalid 'isolateId' parameter: badid");
|
|
}
|
|
expect(caughtException, isTrue);
|
|
},
|
|
|
|
// Plausible isolate id, not found.
|
|
(VM vm) async {
|
|
var params = {
|
|
'isolateId': 'isolates/9999999999',
|
|
};
|
|
var result = await vm.invokeRpcNoUpgrade('getMemoryUsage', params);
|
|
expect(result['type'], equals('Sentinel'));
|
|
expect(result['kind'], equals('Collected'));
|
|
expect(result['valueAsString'], equals('<collected>'));
|
|
},
|
|
];
|
|
|
|
main(args) async => runVMTests(args, tests);
|