dart-sdk/tests/ffi/dylib_close_test.dart
Daco Harkes fbee607329 [vm/ffi] Cleanup tests
Address all warnings and errors in positive tests.

Move all static checks tests to tests/ffi/static_checks/ so it's
easier to ignore them in the analyzer.

Change-Id: I16ac2c00432a4e1b6750bffd9b03ac8a2e988fe6
Cq-Include-Trybots: luci.dart.try:vm-fuchsia-release-arm64-try,vm-fuchsia-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/351123
Reviewed-by: Liam Appelbe <liama@google.com>
2024-02-09 21:27:29 +00:00

35 lines
872 B
Dart

// Copyright (c) 2023, 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.
//
// SharedObjects=ffi_test_functions
import 'dart:ffi';
import 'package:expect/expect.dart';
import 'dylib_utils.dart';
void main() {
testClose();
testUnclosable();
}
void testClose() {
final lib = dlopenPlatformSpecific("ffi_test_functions");
lib.lookup('ReturnMaxUint8');
lib.close();
Expect.throwsStateError(
() => lib.lookup('ReturnMaxUint8'), 'Illegal lookup in closed library');
lib.close(); // Duplicate close should not crash.
}
void testUnclosable() {
final proc = DynamicLibrary.process();
final exec = DynamicLibrary.executable();
Expect.throwsStateError(proc.close);
Expect.throwsStateError(exec.close);
}