Skip to content

Commit

Permalink
Merge branch 'main' into mm-codegen
Browse files Browse the repository at this point in the history
* main:
  [Mono.Android] fix crash on startup with EnableLLVM (dotnet#7188)
  [ci] Add Android Designer test template (dotnet#7227)
  • Loading branch information
grendello committed Aug 3, 2022
2 parents 4d7ec30 + b6c22f3 commit 9a476d8
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 29 deletions.
52 changes: 26 additions & 26 deletions build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ stages:
testName: Mono.Android_Tests-Aot
project: tests/Mono.Android-Tests/Mono.Android-Tests.csproj
testResultsFiles: TestResult-Mono.Android_Tests-$(ApkTestConfiguration)-Aot.xml
extraBuildArgs: /p:AotAssemblies=True /p:EnableLlvm=True
extraBuildArgs: /p:AotAssemblies=True /p:EnableLLVM=True
artifactSource: bin/Test$(ApkTestConfiguration)/Mono.Android_Tests-Signed.apk
artifactFolder: AotLlvm

Expand Down Expand Up @@ -691,13 +691,15 @@ stages:

- template: yaml-templates/apk-instrumentation.yaml
parameters:
# TODO: disable LLVM test, see: https://github.com/dotnet/runtime/issues/68914
# TODO: disable LLVM test, see:
# https://github.com/dotnet/runtime/issues/68914
# https://github.com/dotnet/runtime/issues/73304
condition: false
configuration: $(XA.Build.Configuration)
testName: Mono.Android.NET_Tests-AotLlvm
project: tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj
testResultsFiles: TestResult-Mono.Android.NET_Tests-$(XA.Build.Configuration)AotLlvm.xml
extraBuildArgs: -p:TestsFlavor=AotLlvm -p:EnableLlvm=true
extraBuildArgs: -p:TestsFlavor=AotLlvm -p:EnableLLVM=true -p:AndroidEnableProfiledAot=false
artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab
artifactFolder: $(DotNetTargetFramework)-AotLlvm
useDotNet: true
Expand Down Expand Up @@ -1318,32 +1320,30 @@ stages:
jdkTestFolder: $(JAVA_HOME_8_X64)
provisionatorChannel: ${{ parameters.provisionatorChannel }}

- template: designer\android-designer-build-win.yaml@yaml
parameters:
designerSourcePath: $(System.DefaultWorkingDirectory)\UITools\Designer
uiToolsSourcePath: $(System.DefaultWorkingDirectory)\UITools
javaSdkDirectory: $(JAVA_HOME_8_X64)

- template: designer\android-designer-tests.yaml@yaml
parameters:
designerSourcePath: $(System.DefaultWorkingDirectory)\UITools\Designer

- task: CopyFiles@2
displayName: 'Copy binlogs'
- task: VSBuild@1
displayName: Restore Xamarin.AndroidDesigner
inputs:
sourceFolder: $(System.DefaultWorkingDirectory)\UITools\Designer\Xamarin.Designer.Android
contents: '**/*.binlog'
targetFolder: $(Build.ArtifactStagingDirectory)\designer-binlogs
overWrite: true
flattenFolders: true
condition: ne(variables['Agent.JobStatus'], 'Succeeded')
solution: $(System.DefaultWorkingDirectory)\UITools\Designer\Xamarin.Designer.Android\Xamarin.AndroidDesigner.sln
vsVersion: 17.0
msbuildArgs: >-
/t:Restore /p:RestoreDisableParallel=true
/p:RestoreConfigFile="$(System.DefaultWorkingDirectory)\UITools\NuGet.Config"
/p:JavaSdkDirectory="$(JAVA_HOME_8_X64)"
platform: Any CPU
configuration: DebugWin32

- task: VSBuild@1
displayName: Build Xamarin.AndroidDesigner
inputs:
solution: $(System.DefaultWorkingDirectory)\UITools\Designer\Xamarin.Designer.Android\Xamarin.AndroidDesigner.sln
vsVersion: 17.0
msbuildArgs: /t:Build
platform: Any CPU
configuration: DebugWin32

- template: yaml-templates/publish-artifact.yaml
- template: yaml-templates/run-designer-tests.yml
parameters:
displayName: upload designer binlogs
artifactName: Test Results - Designer - Windows
targetPath: $(Build.ArtifactStagingDirectory)\designer-binlogs
condition: ne(variables['Agent.JobStatus'], 'Succeeded')
designerSourcePath: $(System.DefaultWorkingDirectory)\UITools\Designer

- stage: bcl_tests
displayName: BCL Emulator Tests
Expand Down
76 changes: 76 additions & 0 deletions build-tools/automation/yaml-templates/run-designer-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
parameters:
designerSourcePath: $(System.DefaultWorkingDirectory)
nunitConsoleVersion: '3.9.0'
runAddinTests: true
testResultArtifactName: Test Results - Designer - Windows

steps:
- task: DeleteFiles@1
displayName: Delete Test Outputs
inputs:
SourceFolder: ${{ parameters.designerSourcePath }}/Xamarin.Designer.Android/Xamarin.AndroidDesigner.Tests
Contents: |
CustomControlsOutput
AndroidCustomControlsClass/obj
AndroidCustomControlsBinding/obj
AndroidCustomControls/obj
AndroidCustomControlsClass/bin
AndroidCustomControlsBinding/bin
AndroidCustomControls/bin
- task: NuGetCommand@2
displayName: Install NUnit.Console ${{ parameters.nunitConsoleVersion }}
inputs:
command: custom
arguments: install NUnit.Console -version ${{ parameters.nunitConsoleVersion }} -OutputDirectory ${{ parameters.designerSourcePath }}/packages

- powershell: |
$nunitConsole = [IO.Path]::Combine("${{ parameters.designerSourcePath }}", "packages", "NUnit.ConsoleRunner.${{ parameters.nunitConsoleVersion }}", "tools", "nunit3-console.exe")
if ([Environment]::OSVersion.Platform -eq "Unix")
{
mono64 "$nunitConsole" "-labels=All" "-result=TestResult_AndroidDesignerUnitTests.xml" "Xamarin.AndroidDesigner.UnitTests.dll"
}
else
{
."$nunitConsole" "-labels=All" "-result=TestResult_AndroidDesignerUnitTests.xml" "Xamarin.AndroidDesigner.UnitTests.dll"
}
displayName: Run Unit Tests
workingDirectory: ${{ parameters.designerSourcePath }}/Xamarin.Designer.Android/Xamarin.AndroidDesigner.Tests/bin-tests/Debug

- powershell: |
if ([Environment]::OSVersion.Platform -eq "Unix")
{
mono64 "--debug" "GuiUnit.exe" "-labels=All" "-result=TestResult_AndroidDesigner.xml" "Xamarin.AndroidDesigner.Tests.dll"
}
else
{
.\GuiUnit.exe "-labels=All" "-result=TestResult_AndroidDesigner.xml" "Xamarin.AndroidDesigner.Tests.dll"
}
displayName: Run GUI Tests
workingDirectory: ${{ parameters.designerSourcePath }}/Xamarin.Designer.Android/Xamarin.AndroidDesigner.Tests/bin/Debug
condition: false # https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1583237

- task: PublishTestResults@2
displayName: Publish Core Unit Test Results
inputs:
testResultsFormat: NUnit
testResultsFiles: ${{ parameters.designerSourcePath }}/Xamarin.Designer.Android/Xamarin.AndroidDesigner.Tests/**/TestResult_*.xml
testRunTitle: Xamarin.AndroidDesigner.Tests
condition: succeededOrFailed()

- task: CopyFiles@2
displayName: 'Copy binlogs'
inputs:
sourceFolder: ${{ parameters.designerSourcePath }}/Xamarin.Designer.Android
contents: '**/*.binlog'
targetFolder: $(Build.ArtifactStagingDirectory)/designer-binlogs
overWrite: true
flattenFolders: true
condition: ne(variables['Agent.JobStatus'], 'Succeeded')

- template: publish-artifact.yaml
parameters:
displayName: upload designer binlogs
artifactName: ${{ parameters.testResultArtifactName }}
targetPath: $(Build.ArtifactStagingDirectory)/designer-binlogs
condition: ne(variables['Agent.JobStatus'], 'Succeeded')
9 changes: 8 additions & 1 deletion src/Mono.Android/Android.Runtime/JNIEnv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,17 @@ internal static unsafe void Initialize (JnienvInitializeArgs* args)
}

#if !MONOANDROID1_0
SynchronizationContext.SetSynchronizationContext (Android.App.Application.SynchronizationContext);
SetSynchronizationContext ();
#endif
}

#if !MONOANDROID1_0
// NOTE: prevents Android.App.Application static ctor from running
[MethodImpl (MethodImplOptions.NoInlining)]
static void SetSynchronizationContext () =>
SynchronizationContext.SetSynchronizationContext (Android.App.Application.SynchronizationContext);
#endif

internal static void Exit ()
{
/* Manually dispose surfaced objects and close the current JniEnvironment to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
<AndroidUseNegotiateAuthentication>true</AndroidUseNegotiateAuthentication>
<!--
TODO: Fix excluded tests
For AOT, InetAccess excluded due to: https://github.com/dotnet/runtime/issues/56315
For $(EnableLLVM), InetAccess excluded due to: https://github.com/dotnet/runtime/issues/56315
-->
<ExcludeCategories>DotNetIgnore</ExcludeCategories>
<ExcludeCategories Condition=" '$(RunAOTCompilation)' == 'true' ">$(ExcludeCategories):InetAccess</ExcludeCategories>
<ExcludeCategories Condition=" '$(EnableLLVM)' == 'true' ">$(ExcludeCategories):InetAccess</ExcludeCategories>
<ExcludeCategories Condition=" '$(UseInterpreter)' == 'true' ">$(ExcludeCategories):IgnoreInterpreter</ExcludeCategories>
</PropertyGroup>

Expand Down

0 comments on commit 9a476d8

Please sign in to comment.