Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Configuration.props
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,9 @@
<CommandLineToolsFolder Condition=" '$(CommandLineToolsFolder)' == '' ">5.0</CommandLineToolsFolder>
<CommandLineToolsVersion Condition=" '$(CommandLineToolsVersion)' == '' ">7583922_latest</CommandLineToolsVersion>
<CommandLineToolsBinPath Condition=" '$(CommandLineToolsBinPath)' == '' ">$(AndroidSdkFullPath)\cmdline-tools\$(CommandLineToolsFolder)\bin</CommandLineToolsBinPath>
<EmulatorVersion Condition=" '$(EmulatorVersion)' == '' ">7033400</EmulatorVersion>
<EmulatorPkgRevision Condition=" '$(EmulatorPkgRevision)' == '' ">30.3.5</EmulatorPkgRevision>
<!-- Version numbers and PkgVersion are found in https://dl-ssl.google.com/android/repository/repository2-1.xml -->
<EmulatorVersion Condition=" '$(EmulatorVersion)' == '' ">8129060</EmulatorVersion>
<EmulatorPkgRevision Condition=" '$(EmulatorPkgRevision)' == '' ">31.3.1</EmulatorPkgRevision>
<EmulatorToolPath Condition=" '$(EmulatorToolPath)' == '' ">$(AndroidSdkFullPath)\emulator</EmulatorToolPath>
<EmulatorToolExe Condition=" '$(EmulatorToolExe)' == '' ">emulator</EmulatorToolExe>
<NdkBuildPath Condition=" '$(NdkBuildPath)' == '' And '$(HostOS)' != 'Windows' ">$(AndroidNdkDirectory)\ndk-build</NdkBuildPath>
Expand Down Expand Up @@ -242,12 +243,12 @@

<!-- Fix for IDEs -->
<Target Name="CreateManifestResourceNames" />

<!-- Don't analyze code from external repos -->
<PropertyGroup Condition=" !$(MSBuildProjectDirectory.Contains ('external')) and !$(MSBuildProjectDirectory.Contains ('NUnitLite')) ">
<XAShouldAnalyzeAssembly>True</XAShouldAnalyzeAssembly>
</PropertyGroup>

<!-- The net6.0 versions of these analyzers are stricter and require overloads not available in .NET Framework, so start with just .NET Framework -->
<PropertyGroup Condition=" '$(TargetFramework)' != '' And (!$(TargetFramework.StartsWith('nets')) And !$(TargetFramework.StartsWith('net4')) And !$(TargetFramework.StartsWith('monoandroid'))) ">
<XABuildingForNetCoreApp>True</XABuildingForNetCoreApp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class CreateAndroidEmulator : ToolTask

public string ImageName {get; set;} = "XamarinAndroidTestRunner64";
public string DeviceName {get; set;} = "pixel_4";
public string ImageType {get; set;} = "default";

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

public override bool Execute ()
{
if (string.IsNullOrEmpty (ToolExe))
ToolExe = "avdmanager";

var dirs = string.IsNullOrEmpty (ToolPath)
? null
: new [] { ToolPath };
Expand All @@ -43,7 +47,7 @@ public override bool Execute ()
ToolExe = filename;

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

var env = new List<string> ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public class RunInstrumentationTests : Adb
const int StateGetLogcat = 1;
const int StateClearLogcat = 2;
const int StatePullFiles = 3;
const int MaxState = StatePullFiles;
const int StateRunAsCatFiles = 4;
const int MaxState = StateRunAsCatFiles;

public string TestFixture { get; set; }

Expand All @@ -41,6 +42,8 @@ public class RunInstrumentationTests : Adb

public string LogLevel { get; set; }

public int ApiLevel { get; set; }

int currentState = -1;
int instrumentationExitCode = 99;
string targetTestResultsPath;
Expand Down Expand Up @@ -98,10 +101,17 @@ public override bool Execute ()
ArgumentsString = $"{AdbTarget} {AdbOptions} logcat -c",
IgnoreExitCode = true,
},

new CommandInfo {
ArgumentsGenerator = () => $"{AdbTarget} {AdbOptions} pull \"{targetTestResultsPath}\" \"{NUnit2TestResultsFile}\"",
ShouldRun = () => !String.IsNullOrEmpty (targetTestResultsPath)
ShouldRun = () => !String.IsNullOrEmpty (targetTestResultsPath) && ApiLevel != 30,
IgnoreExitCode = true,
},
new CommandInfo {
ArgumentsGenerator = () => $"{AdbTarget} {AdbOptions} shell run-as {PackageName} cat \"{targetTestResultsPath}\"",
ShouldRun = () => !String.IsNullOrEmpty (targetTestResultsPath) && ApiLevel == 30,
StdoutFilePath = NUnit2TestResultsFile,
StdoutAppend = false,
IgnoreExitCode = true,
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class StartAndroidEmulator : Task
public string ToolPath {get; set;}
public string ToolExe {get; set;}
public string LogcatFile {get; set;}
public bool ShowWindow {get; set;} = true;

public override bool Execute ()
{
Expand Down Expand Up @@ -69,7 +70,8 @@ void Run (string emulator)
return;

var port = string.IsNullOrEmpty (Port) ? "" : $" -port {Port}";
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}";
var showWindow = ShowWindow ? "" : " -no-window";
var arguments = $"{Arguments ?? string.Empty} -verbose -detect-image-hang -logcat-output \"{LogcatFile}\" -no-boot-anim -no-audio -no-snapshot -cache-size 512 -timezone \"Etc/UTC\" {showWindow}{port} -avd {ImageName}";
Log.LogMessage (MessageImportance.Low, $"Tool {emulator} execution started with arguments: {arguments}");
var psi = new ProcessStartInfo () {
FileName = emulator,
Expand Down
23 changes: 18 additions & 5 deletions build-tools/automation/azure-pipelines-nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,31 @@ stages:
Android21-x86:
avdApiLevel: 21
avdAbi: x86
avdType: default
Android23-x86:
avdApiLevel: 23
avdAbi: x86
avdType: default
Android24-x86:
avdApiLevel: 24
avdAbi: x86
avdType: default
Android26-x86_64:
avdApiLevel: 26
avdAbi: x86_64
avdType: default
Android28-x86_64:
avdApiLevel: 28
avdAbi: x86_64
avdType: default
Android30-x86_64:
avdApiLevel: 30
avdAbi: x86_64
avdType: default
Android31-x86_64:
avdApiLevel: 31
avdAbi: x86_64
avdType: default
pool:
vmImage: $(HostedMacImage)
workspace:
Expand Down Expand Up @@ -113,15 +126,15 @@ stages:
inputs:
solution: tests/Mono.Android-Tests/Mono.Android-Tests.csproj
configuration: $(XA.Build.Configuration)
msbuildArguments: /t:InstallAvdImage;AcquireAndroidTarget /p:TestAvdApiLevel=$(avdApiLevel) /p:TestAvdAbi=$(avdAbi) /bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/install-emulator-$(avdApiLevel).binlog
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

- template: yaml-templates/apk-instrumentation.yaml
parameters:
configuration: $(XA.Build.Configuration)
testName: Mono.Android_Tests-$(avdApiLevel)-$(avdAbi)
testName: Mono.Android_Tests-$(avdApiLevel)-$(avdAbi)-$(avdType)
project: tests/Mono.Android-Tests/Mono.Android-Tests.csproj
testResultsFiles: TestResult-Mono.Android_Tests-$(XA.Build.Configuration).xml
extraBuildArgs: /p:TestAvdApiLevel=$(avdApiLevel) /p:TestAvdAbi=$(avdAbi)
extraBuildArgs: /p:TestAvdApiLevel=$(avdApiLevel) /p:TestAvdAbi=$(avdAbi) /p:TestAvdType=$(avdType)
artifactSource: bin/Test$(XA.Build.Configuration)/Mono.Android_Tests-Signed.apk
artifactFolder: Default

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

- template: yaml-templates/upload-results.yaml
parameters:
configuration: $(XA.Build.Configuration)
artifactName: Test Results - Emulator $(avdApiLevel)-$(avdAbi) - macOS
artifactName: Test Results - Emulator $(avdApiLevel)-$(avdAbi)-$(avdType) - macOS

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

Expand Down
21 changes: 21 additions & 0 deletions build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -996,20 +996,32 @@ stages:
node_id: 1
job_name: mac_msbuilddevice_tests_1
job_suffix: Legacy
nunit_categories: '&& cat != Debugger'
provisionatorChannel: ${{ parameters.provisionatorChannel }}

- template: yaml-templates/run-msbuild-device-tests.yaml
parameters:
node_id: 2
job_name: mac_msbuilddevice_tests_2
job_suffix: Legacy
nunit_categories: '&& cat != Debugger'
provisionatorChannel: ${{ parameters.provisionatorChannel }}

- template: yaml-templates/run-msbuild-device-tests.yaml
parameters:
node_id: 3
job_name: mac_msbuilddevice_tests_3
job_suffix: Legacy
nunit_categories: '&& cat != Debugger'
provisionatorChannel: ${{ parameters.provisionatorChannel }}

- template: yaml-templates/run-msbuild-device-tests.yaml
parameters:
node_id: 4
job_name: mac_msbuilddevice_tests_with_debugger
job_suffix: Legacy
jdkTestFolder: $(XA.Jdk11.Folder)
nunit_categories: '&& cat == Debugger'
provisionatorChannel: ${{ parameters.provisionatorChannel }}

# Check - "Xamarin.Android (MSBuild Emulator Tests macOS - One .NET)"
Expand Down Expand Up @@ -1040,6 +1052,15 @@ stages:
target_framework: 'net6.0'
provisionatorChannel: ${{ parameters.provisionatorChannel }}

- template: yaml-templates/run-msbuild-device-tests.yaml
parameters:
node_id: 4
job_name: mac_dotnetdevice_tests_4
job_suffix: One .NET
nunit_categories: $(DotNetNUnitCategories)
target_framework: 'net6.0'
provisionatorChannel: ${{ parameters.provisionatorChannel }}

- stage: designer_tests
displayName: Designer Tests
dependsOn: mac_build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ jobs:
useDotNet: ${{ eq(parameters.target_framework, 'net6.0') }}
testRunTitle: MSBuildDeviceIntegration On Device - macOS-NoNode - ${{ parameters.job_suffix }}
testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/${{ parameters.target_framework }}/MSBuildDeviceIntegration.dll
nunitConsoleExtraArgs: --where "cat != Node-1 && cat != Node-2 && cat != Node-3 && cat != SystemApplication && cat != TimeZoneInfo && cat != SmokeTests ${{ parameters.nunit_categories }}"
dotNetTestExtraArgs: --filter "TestCategory != Node-1 & TestCategory != Node-2 & TestCategory != Node-3 & TestCategory != TimeZoneInfo ${{ parameters.nunit_categories }}"
nunitConsoleExtraArgs: --where "cat != Node-1 && cat != Node-2 && cat != Node-3 && cat != Node-4 && cat != SystemApplication && cat != TimeZoneInfo && cat != SmokeTests ${{ parameters.nunit_categories }}"
dotNetTestExtraArgs: --filter "TestCategory != Node-1 & TestCategory != Node-2 & TestCategory != Node-3 & TestCategory != Node-4 & TestCategory != TimeZoneInfo ${{ parameters.nunit_categories }}"
testResultsFile: TestResult-MSBuildDeviceIntegration-${{ parameters.job_name }}-NoNode-$(XA.Build.Configuration).xml

- task: MSBuild@1
Expand Down
5 changes: 3 additions & 2 deletions build-tools/check-boot-times/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,10 @@ static async Task<double> GetBootTime (bool coldBoot)
{
var times = new List<long> ();
int errors = 0;
var timeoutInMS = (int) TimeSpan.FromMinutes (15).TotalMilliseconds;

Stopwatch sw = new Stopwatch ();
var token = coldBoot ? "emulator: INFO: boot time" : "onGuestSendCommand";
var token = coldBoot ? "boot completed" : "onGuestSendCommand";

for (int i = 0; i < executionTimes; i++) {
await CloseEmulator ();
Expand Down Expand Up @@ -162,7 +163,7 @@ bool validation (string data, ManualResetEvent mre)
bool hasTimedOut = false;
sw.Reset ();
sw.Start ();
if (!await RunProcess (emulatorPath, $"-avd {deviceName} {bootOptions} -verbose", 300000, validation, async () => {
if (!await RunProcess (emulatorPath, $"-avd {deviceName} {bootOptions} -verbose -detect-image-hang", timeoutInMS, validation, async () => {
hasTimedOut = true;
await ForceKillEmulator ();
})) {
Expand Down
12 changes: 9 additions & 3 deletions build-tools/scripts/TestApks.targets
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@
<PropertyGroup>
<TestAvdApiLevel Condition=" '$(TestAvdApiLevel)' == '' ">29</TestAvdApiLevel>
<TestAvdAbi Condition=" '$(TestAvdAbi)' == '' ">x86_64</TestAvdAbi>
<SdkManagerImageName Condition=" '$(SdkManagerImageName)' == '' ">system-images;android-$(TestAvdApiLevel);default;$(TestAvdAbi)</SdkManagerImageName>
<TestAvdType Condition=" '$(TestAvdType)' == '' ">default</TestAvdType>
<SdkManagerImageName Condition=" '$(SdkManagerImageName)' == '' ">system-images;android-$(TestAvdApiLevel);$(TestAvdType);$(TestAvdAbi)</SdkManagerImageName>
<TestAvdName>XamarinAndroidTestRunner$(TestAvdApiLevel)-$(TestAvdAbi)</TestAvdName>
<_AdbEmulatorPort>5570</_AdbEmulatorPort>
<_AdbEmulatorShowWindow Condition=" '$(RunningOnCI)' == 'True' And '$(_AdbEmulatorShowWindow)' == '' ">False</_AdbEmulatorShowWindow>
<_AdbEmulatorShowWindow Condition=" '$(_AdbEmulatorShowWindow)' == '' ">True</_AdbEmulatorShowWindow>
<_ApkSizesReferenceDirectory>$(MSBuildThisFileDirectory)..\..\tests\apk-sizes-reference</_ApkSizesReferenceDirectory>
<AvdLaunchTimeoutMinutes Condition=" '$(AvdLaunchTimeoutMinutes)' == '' ">5</AvdLaunchTimeoutMinutes>
<AvdLaunchTimeoutMinutes Condition=" '$(AvdLaunchTimeoutMinutes)' == '' ">10</AvdLaunchTimeoutMinutes>
<AvdLaunchTimeoutSeconds>$([MSBuild]::Multiply($(AvdLaunchTimeoutMinutes), 60))</AvdLaunchTimeoutSeconds>
<AvdLaunchTimeoutMS>$([MSBuild]::Multiply($(AvdLaunchTimeoutSeconds), 1000))</AvdLaunchTimeoutMS>
<_LogcatFilenameBase>$(MSBuildThisFileDirectory)..\..\bin\Test$(Configuration)\logcat-$(Configuration)$(TestsFlavor)</_LogcatFilenameBase>
Expand Down Expand Up @@ -58,6 +61,7 @@
SdkVersion="$(TestAvdApiLevel)"
TargetId="$(SdkManagerImageName)"
ImageName="$(TestAvdName)"
ImageType="$(TestAvdType)"
ToolExe="$(AvdManagerToolExe)"
ToolPath="$(CommandLineToolsBinPath)"
RamSizeMB="3072"
Expand All @@ -71,6 +75,7 @@
ImageName="$(TestAvdName)"
LogcatFile="$(_LogcatFilenameBase)-full.txt"
Port="$(_AdbEmulatorPort)"
ShowWindow="$(_AdbEmulatorShowWindow)"
ToolExe="$(EmulatorToolExe)"
ToolPath="$(EmulatorToolPath)">
<Output TaskParameter="AdbTarget" PropertyName="_AdbTarget" />
Expand All @@ -83,7 +88,7 @@
Arguments="$(_AdbTarget) wait-for-device"
ToolExe="$(AdbToolExe)"
ToolPath="$(AdbToolPath)"
Timeout="120000"
Timeout="$(AvdLaunchTimeoutMS)"
WriteOutputAsMessage="True"
/>
<WaitForAndroidEmulator
Expand Down Expand Up @@ -254,6 +259,7 @@
ContinueOnError="ErrorAndContinue"
AdbTarget="$(_AdbTarget)"
AdbOptions="$(AdbOptions)"
ApiLevel="$(TestAvdApiLevel)"
LogLevel="Verbose"
PackageName="%(TestApkInstrumentation.Package)"
Component="%(TestApkInstrumentation.Package)/%(TestApkInstrumentation.Identity)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,15 @@ public AndroidToolchain ()
new AndroidToolchainComponent ("docs-24_r01", destDir: "docs", pkgRevision: "1", dependencyType: AndroidToolchainComponentType.BuildDependency),
new AndroidToolchainComponent ("android_m2repository_r47", destDir: Path.Combine ("extras", "android", "m2repository"), pkgRevision: "47.0.0", dependencyType: AndroidToolchainComponentType.BuildDependency),
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),
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),
new AndroidToolchainComponent ($"android-ndk-r{AndroidNdkVersion}-{osTag}", destDir: AndroidNdkDirectory, pkgRevision: AndroidPkgRevision),
new AndroidToolchainComponent ($"{XABuildToolsPackagePrefix}build-tools_r{XABuildToolsVersion}-{altOsTag}", destDir: Path.Combine ("build-tools", XABuildToolsFolder), isMultiVersion: true),
new AndroidToolchainComponent ($"{XABuildTools30PackagePrefix}build-tools_r{XABuildTools30Version}-{altOsTag}", destDir: Path.Combine ("build-tools", XABuildTools30Folder), isMultiVersion: true),
new AndroidToolchainComponent ($"commandlinetools-{cltOsTag}-{CommandLineToolsVersion}",
destDir: Path.Combine ("cmdline-tools", CommandLineToolsFolder), isMultiVersion: true),
new AndroidToolchainComponent ($"{XAPlatformToolsPackagePrefix}platform-tools_r{XAPlatformToolsVersion}-{osTag}", destDir: "platform-tools", pkgRevision: XAPlatformToolsVersion),
new AndroidToolchainComponent ($"sdk-tools-{osTag}-4333796", destDir: "tools", pkgRevision: "26.1.1"),
new AndroidToolchainComponent ($"emulator-{osTag}-{EmulatorVersion}", destDir: "emulator", pkgRevision: EmulatorPkgRevision, dependencyType: AndroidToolchainComponentType.EmulatorDependency),
new AndroidToolchainComponent ($"emulator-{osTag}_x64-{EmulatorVersion}", destDir: "emulator", pkgRevision: EmulatorPkgRevision, dependencyType: AndroidToolchainComponentType.EmulatorDependency),
new AndroidToolchainComponent ($"{AndroidCmakeUrlPrefix}cmake-{AndroidCmakeVersion}-{osTag}", destDir: Path.Combine ("cmake", AndroidCmakeVersionPath), isMultiVersion: true, noSubdirectory: true, pkgRevision: "3.18.1"),
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,17 @@ void CopyExtraTestFiles (string destinationRoot, Context context)

var testConfigDir = Path.Combine (BuildPaths.XamarinAndroidSourceRoot, "bin", $"Test{context.Configuration}");
if (Directory.Exists (testConfigDir)) {
var matchedFiles = new List<string> ();
foreach (var fileMatch in testConfigFiles) {
Utilities.CopyFilesSimple (Directory.GetFiles (testConfigDir, fileMatch), destinationRoot, false);
// Handle files which might appear in multiple filters
// eg logcat-Relase-full.log will appear in both logcat* AND *log
foreach (var file in Directory.GetFiles (testConfigDir, fileMatch)) {
if (matchedFiles.Contains (file))
continue;
matchedFiles.Add (file);
}
}
Utilities.CopyFilesSimple (matchedFiles, destinationRoot, false);
}

var testConfigCompatDir = Path.Combine (testConfigDir, "compatibility");
Expand Down
Loading