Files
sdk/pkg/vm_service/test/get_isolate_rpc_test.dart
Alexander Aprelev 69485e9b28 [vm] Move origin_id from isolate to isolate group.
Isolates in one group share same origin_id anyway, so it makes sense to store it on the group too.


Remove isolate's _originNumber from service api - isolate group should be used instead.

Based on feedback from https://dart-review.git.corp.google.com/c/sdk/+/418503/21/runtime/lib/isolate.cc#107

TEST=ci
Change-Id: Iab4b6393a042c9302e911a276a6afc6dab63e70d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424140
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-04-23 15:26:21 -07:00

64 lines
2.2 KiB
Dart

// Copyright (c) 2020, 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/service_test_common.dart';
import 'common/test_helper.dart';
final tests = <IsolateTest>[
hasPausedAtStart,
(VmService service, IsolateRef isolateRef) async {
final result = await service.getIsolate(isolateRef.id!);
expect(result.id, startsWith('isolates/'));
expect(result.number, isNotNull);
expect(result.isolateFlags, isNotNull);
expect(result.isolateFlags!.length, isPositive);
expect(result.isSystemIsolate, isFalse);
expect(result.startTime, isPositive);
expect(result.livePorts, isPositive);
expect(result.pauseOnExit, isFalse);
expect(result.pauseEvent!.type, 'Event');
expect(result.error, isNull);
expect(result.rootLib, isNotNull);
expect(result.libraries!.length, isPositive);
expect(result.libraries![0], isNotNull);
expect(result.breakpoints!.length, isZero);
expect(result.json!['_heaps']['new']['type'], 'HeapSpace');
expect(result.json!['_heaps']['old']['type'], 'HeapSpace');
},
(VmService service, IsolateRef _) async {
bool caughtException = false;
try {
await service.getIsolate('badid');
expect(false, isTrue, reason: 'Unreachable');
} on RPCError catch (e) {
caughtException = true;
expect(e.code, equals(RPCErrorKind.kInvalidParams.code));
expect(e.details, "getIsolate: invalid 'isolateId' parameter: badid");
}
expect(caughtException, isTrue);
},
// Plausible isolate id, not found.
(VmService service, IsolateRef _) async {
try {
await service.getIsolate('isolates/9999999999');
fail('successfully got isolate with bad ID');
} on SentinelException catch (e) {
expect(e.sentinel.kind, 'Collected');
expect(e.sentinel.valueAsString, '<collected>');
}
},
];
void main([args = const <String>[]]) => runIsolateTests(
args,
tests,
'get_isolate_rpc_test.dart',
pauseOnStart: true,
);