Skip to content

Commit f9ad7c9

Browse files
[Android] Run CoreCLR library tests on Android (#114148)
* Enable running library tests * Add jobs to extra-platforms * Fix System.Runtime tests * Fix arm64 android coreclr tests * Add TestUtilities project reference * Add support for local android test execution on windows * Disable failing tests on Android devices * Disable failing tests on Android devices * Disable failing tests * Remove unnecessary using System directive * Disable failing tests * Disable failing tests * Fix typo * Disable failing tests * Disable ConfigSwitchIsHonored test * Disable failing tests * Fix typo * Enable System.Runtime.Loader.Tests tests * Enable System.Text.RegularExpressions tests * Disable failing tests * Try run disabled tests * Fix build * Disable failing tests * Enable tests that are passing * Fix typo * Fix ActiveIssue annotation * Disable failing tests * Add comment * Disable failing tests * Fix test annotations * Update ProjectExclusions tracking issue * Disable failing tests on Android platform * Skip MutexTests on CoreCLR Android * Disable tests on CoreCLR Android * Fix ActiveIssue annotation * Disable failing tests * Disable failing tests * Exclude System.Net.Security.Tests from project builds * Exclude System.Net.Security.Tests from project builds * Disable CoreCLR tests on Mono * Disable System.Net.WebSockets.Tests due to disk space limitation * Exclude debug symbols * Update StripDebugSymbols property * Disable failing tests * Fix build * Disable tests * Disable failing tests * Test run * Use Debug config to ensure android:debuggable=true * Fix StripDebugSymbols * Fix formatting * Test run --------- Co-authored-by: Steve Pfister <[email protected]>
1 parent f6d4a01 commit f9ad7c9

File tree

59 files changed

+350
-242
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+350
-242
lines changed

eng/pipelines/extra-platforms/runtime-extra-platforms-android.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,34 @@ jobs:
8383
parameters:
8484
creator: dotnet-bot
8585
testRunNamePrefixSuffix: Mono_$(_BuildConfig)
86+
87+
#
88+
# Android devices
89+
# Build the whole product using CoreCLR and run libraries tests
90+
#
91+
- template: /eng/pipelines/common/platform-matrix.yml
92+
parameters:
93+
jobTemplate: /eng/pipelines/common/global-build-job.yml
94+
helixQueuesTemplate: /eng/pipelines/libraries/helix-queues-setup.yml
95+
buildConfig: Release
96+
runtimeFlavor: coreclr
97+
platforms:
98+
- android_arm64
99+
variables:
100+
# map dependencies variables to local variables
101+
- name: librariesContainsChange
102+
value: $[ stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_libraries.containsChange'] ]
103+
- name: coreclrContainsChange
104+
value: $[ stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_coreclr.containsChange'] ]
105+
jobParameters:
106+
testGroup: innerloop
107+
nameSuffix: AllSubsets_CoreCLR
108+
isExtraPlatforms: ${{ parameters.isExtraPlatformsBuild }}
109+
buildArgs: -s clr.runtime+clr.alljits+clr.corelib+clr.nativecorelib+clr.tools+clr.packages+libs+libs.tests+host+packs -c $(_BuildConfig) /p:ArchiveTests=true $(_runSmokeTestsOnlyArg)
110+
timeoutInMinutes: 480
111+
# extra steps, run tests
112+
postBuildSteps:
113+
- template: /eng/pipelines/libraries/helix.yml
114+
parameters:
115+
creator: dotnet-bot
116+
testRunNamePrefixSuffix: CoreCLR_$(_BuildConfig)

eng/pipelines/extra-platforms/runtime-extra-platforms-androidemulator.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,34 @@ jobs:
118118
parameters:
119119
creator: dotnet-bot
120120
testRunNamePrefixSuffix: Mono_$(_BuildConfig)
121+
122+
#
123+
# Android emulators
124+
# Build the whole product using CoreCLR and run libraries tests
125+
#
126+
- template: /eng/pipelines/common/platform-matrix.yml
127+
parameters:
128+
jobTemplate: /eng/pipelines/common/global-build-job.yml
129+
helixQueuesTemplate: /eng/pipelines/libraries/helix-queues-setup.yml
130+
buildConfig: Release
131+
runtimeFlavor: coreclr
132+
platforms:
133+
- android_x64
134+
variables:
135+
# map dependencies variables to local variables
136+
- name: librariesContainsChange
137+
value: $[ stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_libraries.containsChange'] ]
138+
- name: coreclrContainsChange
139+
value: $[ stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_coreclr.containsChange'] ]
140+
jobParameters:
141+
testGroup: innerloop
142+
nameSuffix: AllSubsets_CoreCLR
143+
isExtraPlatforms: ${{ parameters.isExtraPlatformsBuild }}
144+
buildArgs: -s clr.runtime+clr.alljits+clr.corelib+clr.nativecorelib+clr.tools+clr.packages+libs+libs.tests+host+packs -c $(_BuildConfig) /p:ArchiveTests=true $(_runSmokeTestsOnlyArg)
145+
timeoutInMinutes: 240
146+
# extra steps, run tests
147+
postBuildSteps:
148+
- template: /eng/pipelines/libraries/helix.yml
149+
parameters:
150+
creator: dotnet-bot
151+
testRunNamePrefixSuffix: CoreCLR_$(_BuildConfig)

eng/pipelines/runtime.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ extends:
956956
jobParameters:
957957
testGroup: innerloop
958958
nameSuffix: AllSubsets_CoreCLR
959-
buildArgs: -s clr.runtime+clr.alljits+clr.corelib+clr.nativecorelib+clr.tools+clr.packages+libs++libs.tests+host+packs -c $(_BuildConfig) /p:ArchiveTests=true /p:TestAssemblies=false
959+
buildArgs: -s clr.runtime+clr.alljits+clr.corelib+clr.nativecorelib+clr.tools+clr.packages+libs+libs.tests+host+packs -c $(_BuildConfig) /p:ArchiveTests=true /p:RunSmokeTestsOnly=true
960960
timeoutInMinutes: 480
961961
condition: >-
962962
or(

eng/testing/AndroidRunnerTemplate.cmd

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
@ECHO OFF
2+
setlocal enabledelayedexpansion
3+
4+
SET EXECUTION_DIR=%~dp0
5+
SET ASSEMBLY_NAME=%1
6+
SET TARGET_ARCH=%2
7+
SET TARGET_OS=%3
8+
SET TEST_NAME=%4
9+
SET REPO_ROOT=%5
10+
11+
:Arg_Loop
12+
if "%6" == "" goto ArgsDone
13+
set "__AdditionalArgs=!__AdditionalArgs! %6"&shift&goto Arg_Loop
14+
:ArgsDone
15+
16+
SET "XHARNESS_OUT=%EXECUTION_DIR%xharness-output"
17+
18+
cd %EXECUTION_DIR%
19+
20+
:lock
21+
MKDIR androidtests.lock 2>NUL
22+
IF "%errorlevel%" NEQ "0" (
23+
ping -n 6 127.0.0.1 >NUL
24+
GOTO :lock
25+
)
26+
27+
IF [%XHARNESS_CLI_PATH%] NEQ [] (
28+
:: When running in CI, we only have the .NET runtime available
29+
:: We need to call the XHarness CLI DLL directly via dotnet exec
30+
SET HARNESS_RUNNER=%REPO_ROOT%dotnet.cmd exec "%XHARNESS_CLI_PATH%"
31+
) ELSE (
32+
SET HARNESS_RUNNER=%REPO_ROOT%dotnet.cmd xharness
33+
)
34+
35+
%HARNESS_RUNNER% android test --instrumentation="net.dot.MonoRunner" --package-name="net.dot.%ASSEMBLY_NAME%" --app="%EXECUTION_DIR%bin\%TEST_NAME%.apk" --output-directory="%XHARNESS_OUT%" --timeout=1800 %__AdditionalArgs%
36+
37+
SET EXIT_CODE=%ERRORLEVEL%
38+
39+
ECHO XHarness artifacts: %XHARNESS_OUT%
40+
41+
RMDIR /Q androidtests.lock 2>NUL
42+
EXIT /B %EXIT_CODE%
43+
44+
:: ========== FUNCTIONS ==========
45+
:NORMALIZEPATH
46+
SET RETVAL=%~f1
47+
EXIT /B

eng/testing/tests.android.targets

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<BundleTestAppTargets>$(BundleTestAppTargets);BundleTestAndroidApp</BundleTestAppTargets>
44
</PropertyGroup>
55

6-
<Import Project="$(MonoProjectRoot)\msbuild\common\LibraryBuilder.props" />
6+
<Import Project="$(MonoProjectRoot)\msbuild\common\LibraryBuilder.props" />
77
<Import Project="$(MonoProjectRoot)\msbuild\android\build\AndroidBuild.props" />
88
<Import Project="$(MonoProjectRoot)\msbuild\android\build\AndroidBuild.InTree.targets" />
99

@@ -12,6 +12,10 @@
1212
<BundleTestAndroidAppDependsOn>AndroidBuild</BundleTestAndroidAppDependsOn>
1313
</PropertyGroup>
1414

15+
<PropertyGroup Condition="'$(RuntimeFlavor)' == 'CoreCLR'">
16+
<DefineConstants>$(DefineConstants);SINGLE_FILE_TEST_RUNNER</DefineConstants>
17+
</PropertyGroup>
18+
1519
<!-- Target that kicks off the whole test build and run flow -->
1620
<Target Name="BundleTestAndroidApp" DependsOnTargets="$(BundleTestAndroidAppDependsOn)" />
1721

@@ -22,7 +26,7 @@
2226

2327
<PropertyGroup>
2428
<MainLibraryFileName Condition="'$(MainLibraryFileName)' == ''">AndroidTestRunner.dll</MainLibraryFileName>
25-
29+
2630
<AndroidBuildDir>$(PublishDir)</AndroidBuildDir>
2731
<AndroidBundleDir>$(BundleDir)</AndroidBundleDir>
2832
</PropertyGroup>
@@ -44,7 +48,7 @@
4448
<_InternalForceInterpret>true</_InternalForceInterpret>
4549
<_IsNative>true</_IsNative>
4650
</AndroidAssembliesToBundle>
47-
51+
4852
<_PublishAssemblies Include="$(PublishDir)\**\*.dll" Exclude="$(PublishDir)\**\*.resources.dll" />
4953
<_SatelliteAssemblies Include="$(PublishDir)\**\*.resources.dll" />
5054

@@ -73,4 +77,4 @@
7377
<RemoveDir Condition="'$(ArchiveTests)' == 'true' and '$(AndroidGenerateAppBundle)' == 'true'" Directories="$(OutDir)" />
7478
</Target>
7579

76-
</Project>
80+
</Project>

eng/testing/tests.targets

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<Project>
22
<PropertyGroup>
3-
<RunScriptWindowsCmd Condition="'$(TargetOS)' == 'windows' and '$(RunScriptWindowsCmd)' == ''">true</RunScriptWindowsCmd>
4-
<RunScriptWindowsCmd Condition="'$(TargetOS)' != 'windows' and '$(RunScriptWindowsCmd)' == ''">false</RunScriptWindowsCmd>
3+
<RunScriptWindowsCmd Condition="'$(OS)' == 'Windows_NT' and '$(RunScriptWindowsCmd)' == ''">true</RunScriptWindowsCmd>
4+
<RunScriptWindowsCmd Condition="'$(OS)' != 'Windows_NT' and '$(RunScriptWindowsCmd)' == ''">false</RunScriptWindowsCmd>
55
</PropertyGroup>
66
<PropertyGroup Condition="'$(RunScriptInputName)' == ''">
77
<RunScriptInputName Condition="'$(RunScriptWindowsCmd)' == 'true'">RunnerTemplate.cmd</RunScriptInputName>
88
<RunScriptInputName Condition="'$(RunScriptWindowsCmd)' != 'true'">RunnerTemplate.sh</RunScriptInputName>
99
<RunScriptInputName Condition="'$(BuildTestsOnHelix)' == 'true' and '$(TargetsAppleMobile)' == 'true'">AppleHelixRunnerTemplate.sh</RunScriptInputName>
1010
<RunScriptInputName Condition="'$(BuildTestsOnHelix)' != 'true' and '$(TargetsAppleMobile)' == 'true'">AppleRunnerTemplate.sh</RunScriptInputName>
11-
<RunScriptInputName Condition="'$(TargetOS)' == 'android'">AndroidRunnerTemplate.sh</RunScriptInputName>
11+
<RunScriptInputName Condition="'$(TargetOS)' == 'android' and '$(OS)' != 'Windows_NT'">AndroidRunnerTemplate.sh</RunScriptInputName>
12+
<RunScriptInputName Condition="'$(TargetOS)' == 'android' and '$(OS)' == 'Windows_NT'">AndroidRunnerTemplate.cmd</RunScriptInputName>
1213
<RunScriptInputName Condition="'$(TargetOS)' == 'wasi' and '$(OS)' != 'Windows_NT'">WasiRunnerTemplate.sh</RunScriptInputName>
1314
<RunScriptInputName Condition="'$(TargetOS)' == 'wasi' and '$(OS)' == 'Windows_NT'">WasiRunnerTemplate.cmd</RunScriptInputName>
1415
<RunScriptInputName Condition="'$(TargetOS)' == 'browser' and '$(OS)' != 'Windows_NT'">WasmRunnerTemplate.sh</RunScriptInputName>
@@ -172,7 +173,8 @@ TEST_ARCH=$(_AndroidArchitecture)
172173
<PropertyGroup Condition="'$(TargetsMobile)' == 'true'">
173174
<RunTestsCommand>"$(RunScriptOutputPath)" $(AssemblyName) $(TargetArchitecture) $(TargetOS) $(TestProjectName)</RunTestsCommand>
174175
<RunTestsCommand Condition="'$(TargetsAppleMobile)' == 'true'">$(RunTestsCommand) $(Configuration) $(AdditionalXHarnessArguments)</RunTestsCommand>
175-
<RunTestsCommand Condition="'$(TargetOS)' == 'android'">$(RunTestsCommand) $(AdditionalXHarnessArguments)</RunTestsCommand>
176+
<RunTestsCommand Condition="'$(TargetOS)' == 'android' and '$(OS)' != 'Windows_NT'">$(RunTestsCommand) $(AdditionalXHarnessArguments)</RunTestsCommand>
177+
<RunTestsCommand Condition="'$(TargetOS)' == 'android' and '$(OS)' == 'Windows_NT'">$(RunTestsCommand) $(RepoRoot) $(AdditionalXHarnessArguments)</RunTestsCommand>
176178
<RunTestsCommand Condition="'$(TargetOS)' == 'browser'">"$(RunScriptOutputPath)" $(JSEngine) $(AssemblyName).dll $(Scenario)</RunTestsCommand>
177179
</PropertyGroup>
178180

src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/ConfigBindingGenTestDriver.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System;
45
using System.Collections.Generic;
56
using System.Collections.Immutable;
67
using System.Diagnostics;
@@ -17,7 +18,7 @@
1718

1819
namespace Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests
1920
{
20-
[ActiveIssue("https://github.com/dotnet/runtime/issues/52062", TestPlatforms.Browser)]
21+
[ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.HasAssemblyFiles))]
2122
public partial class ConfigurationBindingGeneratorTests : ConfigurationBinderTestsBase
2223
{
2324
internal sealed class ConfigBindingGenTestDriver

src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/GeneratorTests.Baselines.Options.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public async Task Configure_T_NamedParameters_OutOfOrder(string row)
7272
using System.Collections.Generic;
7373
using Microsoft.Extensions.Configuration;
7474
using Microsoft.Extensions.DependencyInjection;
75-
75+
7676
public class Program
7777
{
7878
public static void Main()
@@ -84,7 +84,7 @@ public static void Main()
8484
8585
{{row}}
8686
}
87-
87+
8888
public class MyClass
8989
{
9090
public string MyString { get; set; }
@@ -109,7 +109,7 @@ public async Task Bind_T_NamedParameters_OutOfOrder(string row)
109109
using Microsoft.Extensions.Configuration;
110110
using Microsoft.Extensions.DependencyInjection;
111111
using Microsoft.Extensions.Options;
112-
112+
113113
public class Program
114114
{
115115
public static void Main()
@@ -121,7 +121,7 @@ public static void Main()
121121
122122
{{row}}
123123
}
124-
124+
125125
public class MyClass
126126
{
127127
public string MyString { get; set; }

src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/GeneratorTests.Incremental.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System;
45
using System.Threading.Tasks;
56
using Microsoft.CodeAnalysis;
67
using Microsoft.Extensions.Configuration.Binder.SourceGeneration;
@@ -11,7 +12,7 @@ namespace Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests
1112
{
1213
public partial class ConfigurationBindingGeneratorTests : ConfigurationBinderTestsBase
1314
{
14-
[ActiveIssue("https://github.com/dotnet/runtime/issues/52062", TestPlatforms.Browser)]
15+
[ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.HasAssemblyFiles))]
1516
public sealed class IncrementalTests
1617
{
1718
[Fact]

0 commit comments

Comments
 (0)