dart-sdk/tests/ffi_2/structs_packed_test.dart
Daco Harkes 8516cdc587 [test/ffi] Split generated files on isLeaf
Splits up tests/ffi/function_structs_by_value_generated_test.dart in
- compounds
- non-leaf calls
- leaf calls

We could also consider splitting on chunks from the `functions` from
tests/ffi/generator/structs_by_value_tests_configuration.dart as a
follow up.

TEST=This only splits up the tests, please reapprove failures.
Expected failures:
https://dart-ci.firebaseapp.com/current_results/#/filter=ffi
- windows precompiled https://github.com/dart-lang/sdk/issues/40564
- mac arm64 https://github.com/dart-lang/sdk/issues/46349

Bug: https://github.com/dart-lang/sdk/issues/45007

Change-Id: Id3d9987cbc1e09f579b8cc68ce72fe5d36348b80
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-win-release-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-precomp-win-debug-x64c-try,pkg-mac-release-arm64-try,vm-kernel-mac-release-arm64-try,vm-kernel-nnbd-mac-debug-arm64-try,vm-kernel-nnbd-mac-release-arm64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216666
Reviewed-by: Clement Skau <cskau@google.com>
2021-10-14 13:05:33 +00:00

42 lines
1.1 KiB
Dart

// Copyright (c) 2021, 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
// @dart = 2.9
import 'dart:ffi';
import "package:expect/expect.dart";
import 'dylib_utils.dart';
// Reuse compound definitions.
import 'function_structs_by_value_generated_compounds.dart';
void main() {
testSizeOfC();
testSizeOfDart();
}
final ffiTestFunctions = dlopenPlatformSpecific("ffi_test_functions");
final sizeOfStruct3BytesPackedInt =
ffiTestFunctions.lookupFunction<Uint64 Function(), int Function()>(
"SizeOfStruct3BytesPackedInt");
void testSizeOfC() {
Expect.equals(3, sizeOfStruct3BytesPackedInt());
}
void testSizeOfDart() {
// No packing needed to get to 3 bytes.
Expect.equals(3, sizeOf<Struct3BytesHomogeneousUint8>());
// Contents 3 bytes, but alignment forces it to be 4 bytes.
Expect.equals(4, sizeOf<Struct3BytesInt2ByteAligned>());
// Alignment gets the same content back to 3 bytes.
Expect.equals(3, sizeOf<Struct3BytesPackedInt>());
}