Skip to content

Commit c9896e5

Browse files
committed
[build-tools] Bump Test emulator to use API 30
1 parent a84eccb commit c9896e5

File tree

36 files changed

+262
-183
lines changed

36 files changed

+262
-183
lines changed

Configuration.props

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@
182182
<CommandLineToolsFolder Condition=" '$(CommandLineToolsFolder)' == '' ">5.0</CommandLineToolsFolder>
183183
<CommandLineToolsVersion Condition=" '$(CommandLineToolsVersion)' == '' ">7583922_latest</CommandLineToolsVersion>
184184
<CommandLineToolsBinPath Condition=" '$(CommandLineToolsBinPath)' == '' ">$(AndroidSdkFullPath)\cmdline-tools\$(CommandLineToolsFolder)\bin</CommandLineToolsBinPath>
185-
<EmulatorVersion Condition=" '$(EmulatorVersion)' == '' ">7033400</EmulatorVersion>
186-
<EmulatorPkgRevision Condition=" '$(EmulatorPkgRevision)' == '' ">30.3.5</EmulatorPkgRevision>
185+
<EmulatorVersion Condition=" '$(EmulatorVersion)' == '' ">7820599</EmulatorVersion>
186+
<EmulatorPkgRevision Condition=" '$(EmulatorPkgRevision)' == '' ">30.9.5</EmulatorPkgRevision>
187187
<EmulatorToolPath Condition=" '$(EmulatorToolPath)' == '' ">$(AndroidSdkFullPath)\emulator</EmulatorToolPath>
188188
<EmulatorToolExe Condition=" '$(EmulatorToolExe)' == '' ">emulator</EmulatorToolExe>
189189
<NdkBuildPath Condition=" '$(NdkBuildPath)' == '' And '$(HostOS)' != 'Windows' ">$(AndroidNdkDirectory)\ndk-build</NdkBuildPath>
@@ -240,12 +240,12 @@
240240

241241
<!-- Fix for IDEs -->
242242
<Target Name="CreateManifestResourceNames" />
243-
243+
244244
<!-- Don't analyze code from external repos -->
245245
<PropertyGroup Condition=" !$(MSBuildProjectDirectory.Contains ('external')) and !$(MSBuildProjectDirectory.Contains ('NUnitLite')) ">
246246
<XAShouldAnalyzeAssembly>True</XAShouldAnalyzeAssembly>
247247
</PropertyGroup>
248-
248+
249249
<!-- The net6.0 versions of these analyzers are stricter and require overloads not available in .NET Framework, so start with just .NET Framework -->
250250
<PropertyGroup Condition=" '$(TargetFramework)' != '' And (!$(TargetFramework.StartsWith('nets')) And !$(TargetFramework.StartsWith('net4')) And !$(TargetFramework.StartsWith('monoandroid'))) ">
251251
<XABuildingForNetCoreApp>True</XABuildingForNetCoreApp>

build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/CreateAndroidEmulator.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class CreateAndroidEmulator : ToolTask
2424

2525
public string ImageName {get; set;} = "XamarinAndroidTestRunner64";
2626
public string DeviceName {get; set;} = "pixel_4";
27+
public string ImageType {get; set;} = "default";
2728

2829
public string DataPartitionSizeMB {get; set;} = "2048";
2930
public string RamSizeMB {get; set;} = "2048";
@@ -32,6 +33,9 @@ public class CreateAndroidEmulator : ToolTask
3233

3334
public override bool Execute ()
3435
{
36+
if (string.IsNullOrEmpty (ToolExe))
37+
ToolExe = "avdmanager";
38+
3539
var dirs = string.IsNullOrEmpty (ToolPath)
3640
? null
3741
: new [] { ToolPath };
@@ -43,7 +47,7 @@ public override bool Execute ()
4347
ToolExe = filename;
4448

4549
if (string.IsNullOrEmpty (TargetId) && !string.IsNullOrEmpty (SdkVersion)) {
46-
TargetId = "system-images;android-" + SdkVersion + ";default;" + AndroidAbi;
50+
TargetId = $"system-images;android-{SdkVersion};{ImageType};{AndroidAbi}";
4751
}
4852

4953
var env = new List<string> ();

build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/RunInstrumentationTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,10 @@ public override bool Execute ()
100100
},
101101

102102
new CommandInfo {
103-
ArgumentsGenerator = () => $"{AdbTarget} {AdbOptions} pull \"{targetTestResultsPath}\" \"{NUnit2TestResultsFile}\"",
104-
ShouldRun = () => !String.IsNullOrEmpty (targetTestResultsPath)
103+
ArgumentsGenerator = () => $"{AdbTarget} {AdbOptions} shell run-as {PackageName} cat \"{targetTestResultsPath}\"",
104+
ShouldRun = () => !String.IsNullOrEmpty (targetTestResultsPath),
105+
StdoutFilePath = NUnit2TestResultsFile,
106+
StdoutAppend = false,
105107
},
106108
};
107109
}

build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/StartAndroidEmulator.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class StartAndroidEmulator : Task
3434
public string ToolPath {get; set;}
3535
public string ToolExe {get; set;}
3636
public string LogcatFile {get; set;}
37+
public bool ShowWindow {get; set;} = true;
3738

3839
public override bool Execute ()
3940
{
@@ -69,7 +70,8 @@ void Run (string emulator)
6970
return;
7071

7172
var port = string.IsNullOrEmpty (Port) ? "" : $" -port {Port}";
72-
var arguments = $"{Arguments ?? string.Empty} -verbose -logcat-output \"{LogcatFile}\" -no-boot-anim -no-audio -no-snapshot -cache-size 512 -timezone \"Etc/UTC\" -avd {ImageName}{port}";
73+
var showWindow = ShowWindow ? "" : " -no-window";
74+
var arguments = $"{Arguments ?? string.Empty} -verbose -logcat-output \"{LogcatFile}\" -no-boot-anim -no-audio -no-snapshot -cache-size 512 -timezone \"Etc/UTC\" {showWindow}{port} -avd {ImageName}";
7375
Log.LogMessage (MessageImportance.Low, $"Tool {emulator} execution started with arguments: {arguments}");
7476
var psi = new ProcessStartInfo () {
7577
FileName = emulator,

build-tools/automation/azure-pipelines-nightly.yaml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,31 @@ stages:
7474
Android21-x86:
7575
avdApiLevel: 21
7676
avdAbi: x86
77+
avdType: default
7778
Android23-x86:
7879
avdApiLevel: 23
7980
avdAbi: x86
81+
avdType: default
8082
Android24-x86:
8183
avdApiLevel: 24
8284
avdAbi: x86
85+
avdType: default
8386
Android26-x86_64:
8487
avdApiLevel: 26
8588
avdAbi: x86_64
89+
avdType: default
8690
Android28-x86_64:
8791
avdApiLevel: 28
8892
avdAbi: x86_64
93+
avdType: default
94+
Android30-x86_64:
95+
avdApiLevel: 30
96+
avdAbi: x86_64
97+
avdType: default
98+
Android31-x86_64:
99+
avdApiLevel: 31
100+
avdAbi: x86_64
101+
avdType: default
89102
pool:
90103
vmImage: $(HostedMacImage)
91104
workspace:
@@ -113,15 +126,15 @@ stages:
113126
inputs:
114127
solution: tests/Mono.Android-Tests/Mono.Android-Tests.csproj
115128
configuration: $(XA.Build.Configuration)
116-
msbuildArguments: /t:InstallAvdImage;AcquireAndroidTarget /p:TestAvdApiLevel=$(avdApiLevel) /p:TestAvdAbi=$(avdAbi) /bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/install-emulator-$(avdApiLevel).binlog
129+
msbuildArguments: /t:InstallAvdImage;AcquireAndroidTarget /p:TestAvdApiLevel=$(avdApiLevel) /p:TestAvdAbi=$(avdAbi) /p:TestAvdType=$(avdType) /bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/install-emulator-$(avdApiLevel).binlog
117130

118131
- template: yaml-templates/apk-instrumentation.yaml
119132
parameters:
120133
configuration: $(XA.Build.Configuration)
121-
testName: Mono.Android_Tests-$(avdApiLevel)-$(avdAbi)
134+
testName: Mono.Android_Tests-$(avdApiLevel)-$(avdAbi)-$(avdType)
122135
project: tests/Mono.Android-Tests/Mono.Android-Tests.csproj
123136
testResultsFiles: TestResult-Mono.Android_Tests-$(XA.Build.Configuration).xml
124-
extraBuildArgs: /p:TestAvdApiLevel=$(avdApiLevel) /p:TestAvdAbi=$(avdAbi)
137+
extraBuildArgs: /p:TestAvdApiLevel=$(avdApiLevel) /p:TestAvdAbi=$(avdAbi) /p:TestAvdType=$(avdType)
125138
artifactSource: bin/Test$(XA.Build.Configuration)/Mono.Android_Tests-Signed.apk
126139
artifactFolder: Default
127140

@@ -130,13 +143,13 @@ stages:
130143
inputs:
131144
solution: tests/Mono.Android-Tests/Mono.Android-Tests.csproj
132145
configuration: $(XA.Build.Configuration)
133-
msbuildArguments: /t:AcquireAndroidTarget,ReleaseAndroidTarget /p:TestAvdApiLevel=$(avdApiLevel) /p:TestAvdAbi=$(avdAbi) /bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/shutdown-emulator.binlog
146+
msbuildArguments: /t:AcquireAndroidTarget,ReleaseAndroidTarget /p:TestAvdApiLevel=$(avdApiLevel) /p:TestAvdAbi=$(avdAbi) /p:TestAvdType=$(avdType) /bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/shutdown-emulator.binlog
134147
condition: always()
135148

136149
- template: yaml-templates/upload-results.yaml
137150
parameters:
138151
configuration: $(XA.Build.Configuration)
139-
artifactName: Test Results - Emulator $(avdApiLevel)-$(avdAbi) - macOS
152+
artifactName: Test Results - Emulator $(avdApiLevel)-$(avdAbi)-$(avdType) - macOS
140153

141154
- template: yaml-templates/fail-on-issue.yaml
142155

build-tools/automation/azure-pipelines.yaml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ stages:
813813
job_name: mac_msbuild_tests_3
814814
job_suffix: Legacy
815815
nunit_categories: '&& cat != SmokeTests'
816-
816+
817817
- template: yaml-templates\run-msbuild-mac-tests.yaml
818818
parameters:
819819
node_id: 4
@@ -955,20 +955,31 @@ stages:
955955
job_name: mac_msbuilddevice_tests_1
956956
job_suffix: Legacy
957957
jdkTestFolder: $(XA.Jdk11.Folder)
958+
nunit_categories: '&& cat != Debugger'
958959

959960
- template: yaml-templates/run-msbuild-device-tests.yaml
960961
parameters:
961962
node_id: 2
962963
job_name: mac_msbuilddevice_tests_2
963964
job_suffix: Legacy
964965
jdkTestFolder: $(XA.Jdk11.Folder)
966+
nunit_categories: '&& cat != Debugger'
965967

966968
- template: yaml-templates/run-msbuild-device-tests.yaml
967969
parameters:
968970
node_id: 3
969971
job_name: mac_msbuilddevice_tests_3
970972
job_suffix: Legacy
971973
jdkTestFolder: $(XA.Jdk11.Folder)
974+
nunit_categories: '&& cat != Debugger'
975+
976+
- template: yaml-templates/run-msbuild-device-tests.yaml
977+
parameters:
978+
node_id: 4
979+
job_name: mac_msbuilddevice_tests_with_debugger
980+
job_suffix: Legacy
981+
jdkTestFolder: $(XA.Jdk11.Folder)
982+
nunit_categories: '&& cat == Debugger'
972983

973984
# Check - "Xamarin.Android (MSBuild Emulator Tests macOS - One .NET)"
974985
- template: yaml-templates/run-msbuild-device-tests.yaml
@@ -995,6 +1006,14 @@ stages:
9951006
nunit_categories: $(DotNetNUnitCategories)
9961007
target_framework: 'net6.0'
9971008

1009+
- template: yaml-templates/run-msbuild-device-tests.yaml
1010+
parameters:
1011+
node_id: 4
1012+
job_name: mac_dotnetdevice_tests_4
1013+
job_suffix: One .NET
1014+
nunit_categories: $(DotNetNUnitCategories)
1015+
target_framework: 'net6.0'
1016+
9981017
- stage: designer_tests
9991018
displayName: Designer Tests
10001019
dependsOn: mac_build
@@ -1430,7 +1449,7 @@ stages:
14301449
inputs:
14311450
packageType: runtime
14321451
version: 3.1.19
1433-
1452+
14341453
- task: DownloadPipelineArtifact@2
14351454
inputs:
14361455
artifactName: $(InstallerArtifactName)

build-tools/automation/yaml-templates/run-msbuild-device-tests.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ jobs:
7373
useDotNet: ${{ eq(parameters.target_framework, 'net6.0') }}
7474
testRunTitle: MSBuildDeviceIntegration On Device - macOS-NoNode - ${{ parameters.job_suffix }}
7575
testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/${{ parameters.target_framework }}/MSBuildDeviceIntegration.dll
76-
nunitConsoleExtraArgs: --where "cat != Node-1 && cat != Node-2 && cat != Node-3 && cat != SystemApplication && cat != TimeZoneInfo && cat != SmokeTests ${{ parameters.nunit_categories }}"
77-
dotNetTestExtraArgs: --filter "TestCategory != Node-1 & TestCategory != Node-2 & TestCategory != Node-3 & TestCategory != TimeZoneInfo ${{ parameters.nunit_categories }}"
76+
nunitConsoleExtraArgs: --where "cat != Node-1 && cat != Node-2 && cat != Node-3 && cat != Node-4 && cat != SystemApplication && cat != TimeZoneInfo && cat != SmokeTests ${{ parameters.nunit_categories }}"
77+
dotNetTestExtraArgs: --filter "TestCategory != Node-1 & TestCategory != Node-2 & TestCategory != Node-3 & TestCategory != Node-4 & TestCategory != TimeZoneInfo ${{ parameters.nunit_categories }}"
7878
testResultsFile: TestResult-MSBuildDeviceIntegration-${{ parameters.job_name }}-NoNode-$(XA.Build.Configuration).xml
7979

8080
- task: MSBuild@1

build-tools/check-boot-times/Program.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,10 @@ static async Task<double> GetBootTime (bool coldBoot)
130130
{
131131
var times = new List<long> ();
132132
int errors = 0;
133+
var timeoutInMS = (int) TimeSpan.FromMinutes (15).TotalMilliseconds;
133134

134135
Stopwatch sw = new Stopwatch ();
135-
var token = coldBoot ? "emulator: INFO: boot time" : "onGuestSendCommand";
136+
var token = coldBoot ? "boot completed" : "onGuestSendCommand";
136137

137138
for (int i = 0; i < executionTimes; i++) {
138139
await CloseEmulator ();
@@ -162,7 +163,7 @@ bool validation (string data, ManualResetEvent mre)
162163
bool hasTimedOut = false;
163164
sw.Reset ();
164165
sw.Start ();
165-
if (!await RunProcess (emulatorPath, $"-avd {deviceName} {bootOptions} -verbose", 300000, validation, async () => {
166+
if (!await RunProcess (emulatorPath, $"-avd {deviceName} {bootOptions} -verbose", timeoutInMS, validation, async () => {
166167
hasTimedOut = true;
167168
await ForceKillEmulator ();
168169
})) {

build-tools/scripts/TestApks.targets

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@
1919
<PropertyGroup>
2020
<TestAvdApiLevel Condition=" '$(TestAvdApiLevel)' == '' ">29</TestAvdApiLevel>
2121
<TestAvdAbi Condition=" '$(TestAvdAbi)' == '' ">x86_64</TestAvdAbi>
22-
<SdkManagerImageName Condition=" '$(SdkManagerImageName)' == '' ">system-images;android-$(TestAvdApiLevel);default;$(TestAvdAbi)</SdkManagerImageName>
22+
<TestAvdType Condition=" '$(TestAvdType)' == '' ">default</TestAvdType>
23+
<SdkManagerImageName Condition=" '$(SdkManagerImageName)' == '' ">system-images;android-$(TestAvdApiLevel);$(TestAvdType);$(TestAvdAbi)</SdkManagerImageName>
2324
<TestAvdName>XamarinAndroidTestRunner$(TestAvdApiLevel)-$(TestAvdAbi)</TestAvdName>
2425
<_AdbEmulatorPort>5570</_AdbEmulatorPort>
26+
<_AdbEmulatorShowWindow Condition=" '$(RunningOnCI)' == 'True' And '$(_AdbEmulatorShowWindow)' == '' ">False</_AdbEmulatorShowWindow>
27+
<_AdbEmulatorShowWindow Condition=" '$(_AdbEmulatorShowWindow)' == '' ">True</_AdbEmulatorShowWindow>
2528
<_ApkSizesReferenceDirectory>$(MSBuildThisFileDirectory)..\..\tests\apk-sizes-reference</_ApkSizesReferenceDirectory>
26-
<AvdLaunchTimeoutMinutes Condition=" '$(AvdLaunchTimeoutMinutes)' == '' ">5</AvdLaunchTimeoutMinutes>
29+
<AvdLaunchTimeoutMinutes Condition=" '$(AvdLaunchTimeoutMinutes)' == '' ">10</AvdLaunchTimeoutMinutes>
2730
<AvdLaunchTimeoutSeconds>$([MSBuild]::Multiply($(AvdLaunchTimeoutMinutes), 60))</AvdLaunchTimeoutSeconds>
2831
<AvdLaunchTimeoutMS>$([MSBuild]::Multiply($(AvdLaunchTimeoutSeconds), 1000))</AvdLaunchTimeoutMS>
2932
<_LogcatFilename>$(MSBuildThisFileDirectory)..\..\bin\Test$(Configuration)\logcat-$(Configuration)-full.log</_LogcatFilename>
@@ -58,6 +61,7 @@
5861
SdkVersion="$(TestAvdApiLevel)"
5962
TargetId="$(SdkManagerImageName)"
6063
ImageName="$(TestAvdName)"
64+
ImageType="$(TestAvdType)"
6165
ToolExe="$(AvdManagerToolExe)"
6266
ToolPath="$(CommandLineToolsBinPath)"
6367
RamSizeMB="3072"
@@ -71,6 +75,7 @@
7175
ImageName="$(TestAvdName)"
7276
LogcatFile="$(_LogcatFilename)"
7377
Port="$(_AdbEmulatorPort)"
78+
ShowWindow="$(_AdbEmulatorShowWindow)"
7479
ToolExe="$(EmulatorToolExe)"
7580
ToolPath="$(EmulatorToolPath)">
7681
<Output TaskParameter="AdbTarget" PropertyName="_AdbTarget" />
@@ -83,7 +88,7 @@
8388
Arguments="$(_AdbTarget) wait-for-device"
8489
ToolExe="$(AdbToolExe)"
8590
ToolPath="$(AdbToolPath)"
86-
Timeout="120000"
91+
Timeout="$(AvdLaunchTimeoutMS)"
8792
WriteOutputAsMessage="True"
8893
/>
8994
<WaitForAndroidEmulator

build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/AndroidToolchain.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,15 @@ public AndroidToolchain ()
7373
new AndroidToolchainComponent ("docs-24_r01", destDir: "docs", pkgRevision: "1", dependencyType: AndroidToolchainComponentType.BuildDependency),
7474
new AndroidToolchainComponent ("android_m2repository_r47", destDir: Path.Combine ("extras", "android", "m2repository"), pkgRevision: "47.0.0", dependencyType: AndroidToolchainComponentType.BuildDependency),
7575
new AndroidToolchainComponent ($"x86_64-29_r07-{osTag}", destDir: Path.Combine ("system-images", "android-29", "default", "x86_64"), relativeUrl: new Uri ("sys-img/android/", UriKind.Relative), pkgRevision: "7", dependencyType: AndroidToolchainComponentType.EmulatorDependency),
76+
new AndroidToolchainComponent ($"x86_64-31_r02", destDir: Path.Combine ("system-images", "android-31", "default", "x86_64"), relativeUrl: new Uri ("sys-img/android/", UriKind.Relative), pkgRevision: "2", dependencyType: AndroidToolchainComponentType.EmulatorDependency),
7677
new AndroidToolchainComponent ($"android-ndk-r{AndroidNdkVersion}-{osTag}", destDir: AndroidNdkDirectory, pkgRevision: AndroidPkgRevision),
7778
new AndroidToolchainComponent ($"{XABuildToolsPackagePrefix}build-tools_r{XABuildToolsVersion}-{altOsTag}", destDir: Path.Combine ("build-tools", XABuildToolsFolder), isMultiVersion: true),
7879
new AndroidToolchainComponent ($"{XABuildTools30PackagePrefix}build-tools_r{XABuildTools30Version}-{altOsTag}", destDir: Path.Combine ("build-tools", XABuildTools30Folder), isMultiVersion: true),
7980
new AndroidToolchainComponent ($"commandlinetools-{cltOsTag}-{CommandLineToolsVersion}",
8081
destDir: Path.Combine ("cmdline-tools", CommandLineToolsFolder), isMultiVersion: true),
8182
new AndroidToolchainComponent ($"{XAPlatformToolsPackagePrefix}platform-tools_r{XAPlatformToolsVersion}-{osTag}", destDir: "platform-tools", pkgRevision: XAPlatformToolsVersion),
8283
new AndroidToolchainComponent ($"sdk-tools-{osTag}-4333796", destDir: "tools", pkgRevision: "26.1.1"),
83-
new AndroidToolchainComponent ($"emulator-{osTag}-{EmulatorVersion}", destDir: "emulator", pkgRevision: EmulatorPkgRevision, dependencyType: AndroidToolchainComponentType.EmulatorDependency),
84+
new AndroidToolchainComponent ($"emulator-{osTag}_x64-{EmulatorVersion}", destDir: "emulator", pkgRevision: EmulatorPkgRevision, dependencyType: AndroidToolchainComponentType.EmulatorDependency),
8485
new AndroidToolchainComponent ($"{AndroidCmakeUrlPrefix}cmake-{AndroidCmakeVersion}-{osTag}", destDir: Path.Combine ("cmake", AndroidCmakeVersionPath), isMultiVersion: true, noSubdirectory: true, pkgRevision: "3.18.1"),
8586
};
8687
}

0 commit comments

Comments
 (0)