[vm/gardening] Fix send_unsupported_objects_* tests.

Make sure tests do correct checking of retaining paths, make sure test passes in obufscation mode

Fixes https://github.com/dart-lang/sdk/issues/51501
TEST=ci

Change-Id: Id97a1302f151a2f359f34e5def065401a4aa47c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303003
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
This commit is contained in:
Alexander Aprelev 2023-05-12 19:42:12 +00:00 committed by Commit Queue
parent aa9a219266
commit 1cabe60b14
11 changed files with 32 additions and 24 deletions

View file

@ -31,12 +31,12 @@ main() async {
print('$nestedList');
});
} catch (e) {
checkForRetainingPath(e, <String>[
'NativeWrapper',
Expect.isTrue(checkForRetainingPath(e, <String>[
'NativeClass',
'Baz',
'Fu',
'Closure',
]);
]));
final msg = e.toString();
Expect.isTrue(msg.split('\n').length > NESTED_DEPTH * 2);

View file

@ -15,11 +15,11 @@ worker(SendPort sp) async {
try {
Isolate.exit(sp, Fu.unsendable('fu'));
} catch (e) {
checkForRetainingPath(e, <String>[
'NativeWrapper',
Expect.isTrue(checkForRetainingPath(e, <String>[
'NativeClass',
'Baz',
'Fu',
]);
]));
sp.send(true);
}
}

View file

@ -23,13 +23,12 @@ main() async {
Expect.fail('This closure should fail to be sent, shouldn\'t be called');
});
} catch (e) {
checkForRetainingPath(e, <String>[
'NativeWrapper',
Expect.isTrue(checkForRetainingPath(e, <String>[
'Baz',
'Fu',
'Context',
'Closure',
]);
]));
asyncEnd();
}
}

View file

@ -15,6 +15,7 @@ import 'package:expect/expect.dart';
import 'send_unsupported_objects_test.dart';
@pragma('vm:entry-point') // prevent obfuscation
class ConstFoo {
const ConstFoo(this.name);
final String name;
@ -41,7 +42,7 @@ Future<void> main(args, message) async {
]);
}, (e) {
print(e);
checkForRetainingPath(e, <String>['ConstFoo']);
Expect.isTrue(checkForRetainingPath(e, <String>['ConstFoo']));
final msg = e.toString();
Expect.equals(3, msg.split('\n').where((s) => s.contains('_List')).length);

View file

@ -17,6 +17,7 @@ class Bar {
Foo foo = Foo();
}
@pragma('vm:entry-point') // prevent obfuscation
base class NativeClass extends NativeFieldWrapperClass1 {}
class MockNativeClass implements NativeFieldWrapperClass1 {}
@ -27,6 +28,7 @@ class Baz {
Baz();
}
@pragma('vm:entry-point') // prevent obfuscation
class Fu {
String label;
Bar bar = Bar();
@ -38,11 +40,14 @@ class Fu {
}
}
@pragma('vm:entry-point') // prevent obfuscation
@pragma("vm:isolate-unsendable")
class Locked {}
@pragma('vm:entry-point') // prevent obfuscation
class ExtendsLocked extends Locked {}
@pragma('vm:entry-point') // prevent obfuscation
class ImplementsLocked implements Locked {}
Future<T> sendAndReceive<T>(T object) async {
@ -107,7 +112,7 @@ main() async {
Expect.throws(() {
final z = Zone.current;
rp.sendPort.send(Zone.current);
}, (e) => checkForRetainingPath(e, <String>['Zone']));
}, (e) => e is ArgumentError);
}, zoneValues: {0: 1});
rp.close();

View file

@ -33,12 +33,12 @@ main() async {
print('$nestedList');
});
} catch (e) {
checkForRetainingPath(e, <String>[
'NativeWrapper',
Expect.isTrue(checkForRetainingPath(e, <String>[
'NativeClass',
'Baz',
'Fu',
'Closure',
]);
]));
final msg = e.toString();
Expect.isTrue(msg.split('\n').length > NESTED_DEPTH * 2);

View file

@ -17,11 +17,11 @@ worker(SendPort sp) async {
try {
Isolate.exit(sp, Fu.unsendable('fu'));
} catch (e) {
checkForRetainingPath(e, <String>[
'NativeWrapper',
Expect.isTrue(checkForRetainingPath(e, <String>[
'NativeClass',
'Baz',
'Fu',
]);
]));
sp.send(true);
}
}

View file

@ -25,13 +25,12 @@ main() async {
Expect.fail('This closure should fail to be sent, shouldn\'t be called');
});
} catch (e) {
checkForRetainingPath(e, <String>[
'NativeWrapper',
Expect.isTrue(checkForRetainingPath(e, <String>[
'Baz',
'Fu',
'Context',
'Closure',
]);
]));
asyncEnd();
}
}

View file

@ -17,6 +17,7 @@ import 'package:expect/expect.dart';
import 'send_unsupported_objects_test.dart';
@pragma('vm:entry-point') // prevent obfuscation
class ConstFoo {
const ConstFoo(this.name);
final String name;
@ -42,7 +43,7 @@ Future<void> main(args, message) async {
]
]);
}, (e) {
checkForRetainingPath(e, <String>['ConstFoo']);
Expect.isTrue(checkForRetainingPath(e, <String>['ConstFoo']));
final msg = e.toString();
Expect.equals(3, msg.split('\n').where((s) => s.contains('_List')).length);

View file

@ -19,6 +19,7 @@ class Bar {
Foo foo = Foo();
}
@pragma('vm:entry-point') // prevent obfuscation
class NativeClass extends NativeFieldWrapperClass1 {}
class MockNativeClass implements NativeFieldWrapperClass1 {}
@ -29,6 +30,7 @@ class Baz {
Baz();
}
@pragma('vm:entry-point') // prevent obfuscation
class Fu {
String label;
Bar bar = Bar();
@ -40,11 +42,14 @@ class Fu {
}
}
@pragma('vm:entry-point') // prevent obfuscation
@pragma("vm:isolate-unsendable")
class Locked {}
@pragma('vm:entry-point') // prevent obfuscation
class ExtendsLocked extends Locked {}
@pragma('vm:entry-point') // prevent obfuscation
class ImplementsLocked implements Locked {}
Future<T> sendAndReceive<T>(T object) async {
@ -109,7 +114,7 @@ main() async {
Expect.throws(() {
final z = Zone.current;
rp.sendPort.send(Zone.current);
}, (e) => checkForRetainingPath(e, <String>['Zone']));
}, (e) => e is ArgumentError);
}, zoneValues: {0: 1});
rp.close();

View file

@ -65,11 +65,9 @@ dart_2/transferable_throws_oom_test: SkipByDesign # This test tries to allocate
[ $builder_tag == obfuscated ]
dart/heapsnapshot_cli_test: SkipByDesign # Relies on symbol names
dart/isolate_exit_unsendable_test: SkipByDesign # Relies on symbol names
dart/isolates/send_unsupported_objects_test: SkipByDesign # Relies on symbol names
dart/sendandexit_test: SkipByDesign # Relies on symbol names
dart_2/heapsnapshot_cli_test: SkipByDesign # Relies on symbol names
dart_2/isolate_exit_unsendable_test: SkipByDesign # Relies on symbol names
dart_2/isolates/send_unsupported_objects_test: SkipByDesign # Relies on symbol names
dart_2/sendandexit_test: SkipByDesign # Relies on symbol names
[ $builder_tag == optimization_counter_threshold ]