Skip to content

Commit 5c723f5

Browse files
committed
Enable building smoke tests as apks
- Use ReferenceXUnitWrapperGenerator != false to define SINGLE_FILE_TEST_RUNNER (android & singlefile targets) instead of IsFunctionalTest - Condition SingleFileTestRunner compile and TrimmerRootAssembly (TestUtilities) on wrapper/generator and SkipTestUtilitiesReference - Add Android NativeAOT publish/trim settings and set NativeLib/CustomNativeMain for android nativeaot - Make DisableImplicitFrameworkReferences respect preexisting value and add explicit DisableImplicitFrameworkReferences=false in nativeaot tests dir - Import testing\tests.targets when TargetsAndroid is true - Update many NativeAOT smoke tests Main signatures to public static int Main(string[] args) to match runner invocation
1 parent e6338fb commit 5c723f5

File tree

14 files changed

+23
-15
lines changed

14 files changed

+23
-15
lines changed

eng/testing/tests.android.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<BundleTestAndroidAppDependsOn>AndroidBuild</BundleTestAndroidAppDependsOn>
1313
</PropertyGroup>
1414

15-
<PropertyGroup Condition="'$(RuntimeFlavor)' == 'CoreCLR' and '$(IsFunctionalTest)' != 'true'">
15+
<PropertyGroup Condition="'$(RuntimeFlavor)' == 'CoreCLR' and '$(ReferenceXUnitWrapperGenerator)' != 'false'">
1616
<DefineConstants>$(DefineConstants);SINGLE_FILE_TEST_RUNNER</DefineConstants>
1717
</PropertyGroup>
1818

eng/testing/tests.singlefile.targets

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<SelfContained>true</SelfContained>
3333
</PropertyGroup>
3434

35-
<PropertyGroup Condition="('$(PublishSingleFile)' == 'true' or '$(TestNativeAot)' == 'true') and '$(IsFunctionalTest)' != 'true'">
35+
<PropertyGroup Condition="('$(PublishSingleFile)' == 'true' or '$(TestNativeAot)' == 'true') and '$(ReferenceXUnitWrapperGenerator)' != 'false'">
3636
<DefineConstants>$(DefineConstants);SINGLE_FILE_TEST_RUNNER</DefineConstants>
3737
</PropertyGroup>
3838

@@ -44,13 +44,13 @@
4444

4545
<ItemGroup Condition="'$(TestNativeAot)' == 'true'">
4646
<RdXmlFile Include="$(MSBuildThisFileDirectory)default.rd.xml" />
47-
<TrimmerRootAssembly Include="TestUtilities" />
47+
<TrimmerRootAssembly Include="TestUtilities" Condition="'$(SkipTestUtilitiesReference)' != 'true'" />
4848
</ItemGroup>
4949

5050
<ItemGroup>
5151
<Compile Include="$(CommonTestPath)SingleFileTestRunner\SingleFileTestRunner.cs"
5252
Link="Common\SingleFileTestRunner\SingleFileTestRunner.cs"
53-
Condition="'$(IsFunctionalTest)' != 'true'" />
53+
Condition="'$(ReferenceXUnitWrapperGenerator)' != 'false'" />
5454
</ItemGroup>
5555

5656
<ItemGroup>

src/tests/Directory.Build.props

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@
215215
<ImportProjectExtensionTargets>false</ImportProjectExtensionTargets>
216216
</PropertyGroup>
217217

218-
<PropertyGroup Condition="'$(TargetOS)' == 'ios' or '$(TargetOS)' == 'tvos'">
218+
<PropertyGroup Condition="'$(TargetOS)' == 'ios' or '$(TargetOS)' == 'tvos' or ('$(TargetOS)' == 'android' and '$(TestBuildMode)' == 'nativeaot')">
219219
<EnableAggressiveTrimming Condition="'$(OutputType)' == 'Exe'">true</EnableAggressiveTrimming>
220220
<PublishTrimmed Condition="'$(OutputType)' == 'Exe'">true</PublishTrimmed>
221221
<SkipTestUtilitiesReference>true</SkipTestUtilitiesReference>
@@ -235,6 +235,11 @@
235235
<HybridGlobalization Condition="'$(_IsApplePlatform)' == 'true'">true</HybridGlobalization>
236236
</PropertyGroup>
237237

238+
<PropertyGroup Condition="'$(TargetOS)' == 'android' and '$(TestBuildMode)' == 'nativeaot'">
239+
<NativeLib>shared</NativeLib>
240+
<CustomNativeMain>true</CustomNativeMain>
241+
</PropertyGroup>
242+
238243
<Import Project="$(RepositoryEngineeringDir)testing\tests.props" Condition="'$(IsTestsCommonProject)' != 'true'" />
239244
<Import Project="$(BaseOutputPath)\packages\Common\test_dependencies\test_dependencies\test_dependencies.*.props" Condition="'$(IsTestsCommonProject)' != 'true'" />
240245
</Project>

src/tests/Directory.Build.targets

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@
456456

457457

458458
<PropertyGroup>
459-
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
459+
<DisableImplicitFrameworkReferences Condition="'$(DisableImplicitFrameworkReferences)' == ''">true</DisableImplicitFrameworkReferences>
460460
</PropertyGroup>
461461

462462
<PropertyGroup>
@@ -508,6 +508,7 @@
508508
<Import Project="$(RepositoryEngineeringDir)toolAot.targets" />
509509
<Import Project="$(MSBuildProjectFullPath).targets" Condition="Exists('$(MSBuildProjectFullPath).targets')"/>
510510
<Import Project="$(RepoRoot)/src/tests/Common/mergedrunner.targets" Condition="'$(IsMergedTestRunnerAssembly)' == 'true'" />
511+
<Import Project="$(RepositoryEngineeringDir)testing\tests.targets" Condition="'$(TargetsAndroid)' == 'true'" />
511512

512513
<Target Name="GetBinPlaceTargetFramework" />
513514

src/tests/nativeaot/Directory.Build.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55
<PropertyGroup>
66
<!-- We expect trimming to be fully enabled in these tests -->
77
<EnableAggressiveTrimming>true</EnableAggressiveTrimming>
8+
<!-- We need the library import generator when running android tests. -->
9+
<DisableImplicitFrameworkReferences>false</DisableImplicitFrameworkReferences>
810
</PropertyGroup>
911
</Project>

src/tests/nativeaot/SmokeTests/AttributeTrimming/AttributeTrimming.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
class Program
1010
{
1111
[Method]
12-
static int Main()
12+
public static int Main(string[] args)
1313
{
1414
// Sanity check: we don't currently expect attributes on types to be optimized away
1515
if (GetTypeSecretly(nameof(TypeAttribute)) == null)

src/tests/nativeaot/SmokeTests/ControlFlowGuard/ControlFlowGuard.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ unsafe class ControlFlowGuardTests
3030

3131
static bool s_armed;
3232

33-
static int Main(string[] args)
33+
public static int Main(string[] args)
3434
{
3535
// Are we running the control program?
3636
if (args.Length == 0)

src/tests/nativeaot/SmokeTests/Exceptions/Exceptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public BringUpTest()
2424

2525
static int finallyCounter = 0;
2626

27-
public static int Main()
27+
public static int Main(string[] args)
2828
{
2929
// This test also doubles as server GC test
3030
if (!System.Runtime.GCSettings.IsServerGC)

src/tests/nativeaot/SmokeTests/HardwareIntrinsics/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
unsafe class Program
1111
{
12-
static int Main()
12+
public static int Main(string[] args)
1313
{
1414
s_success = true;
1515

src/tests/nativeaot/SmokeTests/MultiModule/MultiModule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class ReflectionTest
1111
const int Pass = 100;
1212
const int Fail = -1;
1313

14-
public static int Main()
14+
public static int Main(string[] args)
1515
{
1616
if (TestStaticBases() == Fail)
1717
return Fail;

0 commit comments

Comments
 (0)