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
116 changes: 58 additions & 58 deletions integration-test/android.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,37 @@ BeforeDiscovery {
$script:emulator = Get-AndroidEmulatorId
}

Describe 'MAUI app' -ForEach @(
@{ tfm = "net9.0-android35.0" }
Describe 'MAUI app (<tfm>, <configuration>)' -ForEach @(
@{ tfm = "net9.0-android35.0"; configuration = "Release" }
@{ tfm = "net9.0-android35.0"; configuration = "Debug" }
) -Skip:(-not $script:emulator) {
BeforeAll {
Remove-Item -Path "$PSScriptRoot/mobile-app" -Recurse -Force -ErrorAction SilentlyContinue
Copy-Item -Path "$PSScriptRoot/net9-maui" -Destination "$PSScriptRoot/mobile-app" -Recurse -Force
Push-Location $PSScriptRoot/mobile-app

function InstallAndroidApp
{
param([string] $Dsn)
$dsn = $Dsn.Replace('http://', 'http://key@') + '/0'
# replace {{SENTRY_DSN}} in MauiProgram.cs
(Get-Content MauiProgram.cs) `
-replace '\{\{SENTRY_DSN\}\}', 'http://[email protected]:8000/0' `
| Set-Content MauiProgram.cs

# replace {{SENTRY_DSN}} in MauiProgram.cs
(Get-Content MauiProgram.cs) `
-replace '\{\{SENTRY_DSN\}\}', $dsn `
| Set-Content MauiProgram.cs
$arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLower()
$rid = "android-$arch"

$arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLower()
$rid = "android-$arch"
Write-Host "::group::Build Sentry.Maui.Device.IntegrationTestApp.csproj"
dotnet build Sentry.Maui.Device.IntegrationTestApp.csproj `
--configuration $configuration `
--framework $tfm `
--runtime $rid
| ForEach-Object { Write-Host $_ }
Write-Host '::endgroup::'
$LASTEXITCODE | Should -Be 0

Write-Host "::group::Build Sentry.Maui.Device.IntegrationTestApp.csproj"
dotnet build Sentry.Maui.Device.IntegrationTestApp.csproj `
--configuration Release `
--framework $tfm `
--runtime $rid
| ForEach-Object { Write-Host $_ }
Write-Host '::endgroup::'
$LASTEXITCODE | Should -Be 0

Write-Host "::group::Install bin/Release/$tfm/$rid/io.sentry.dotnet.maui.device.integrationtestapp-Signed.apk"
function InstallAndroidApp
{
Write-Host "::group::Install bin/$configuration/$tfm/$rid/io.sentry.dotnet.maui.device.integrationtestapp-Signed.apk"
xharness android install -v `
--app bin/Release/$tfm/$rid/io.sentry.dotnet.maui.device.integrationtestapp-Signed.apk `
--app bin/$configuration/$tfm/$rid/io.sentry.dotnet.maui.device.integrationtestapp-Signed.apk `
--package-name io.sentry.dotnet.maui.device.integrationtestapp `
--output-directory=test_output
| ForEach-Object { Write-Host $_ }
Expand All @@ -58,35 +56,25 @@ Describe 'MAUI app' -ForEach @(
[string] $Dsn,
[string] $TestArg = 'None'
)
Write-Host "::group::Run Android app (TestArg=$TestArg)"
$dsn = $Dsn.Replace('http://', 'http://key@') + '/0'
xharness android adb -v `
-- shell am start -S -n io.sentry.dotnet.maui.device.integrationtestapp/.MainActivity `
-e SENTRY_DSN $dsn `
-e SENTRY_TEST_ARG $TestArg
| ForEach-Object { Write-Host $_ }
Write-Host '::endgroup::'
$LASTEXITCODE | Should -Be 0

try
do
{
# Setup port forwarding for accessing sentry-server at 127.0.0.1:8000 from the emulator
$port = $Dsn.Split(':')[2].Split('/')[0]
xharness android adb -v -- reverse tcp:$port tcp:$port

Write-Host "::group::Run Android app (TestArg=$TestArg)"
xharness android adb -v `
-- shell am start -S -n io.sentry.dotnet.maui.device.integrationtestapp/.MainActivity `
-e SENTRY_TEST_ARG $TestArg
| ForEach-Object { Write-Host $_ }
Write-Host '::endgroup::'
$LASTEXITCODE | Should -Be 0
Write-Host "Waiting for app..."
Start-Sleep -Seconds 1

do
{
Write-Host "Waiting for app..."
Start-Sleep -Seconds 1
$procid = (& xharness android adb -- shell pidof "io.sentry.dotnet.maui.device.integrationtestapp") -replace '\s', ''
$activity = (& xharness android adb -- shell dumpsys activity activities) -match "io\.sentry\.dotnet\.maui\.device\.integrationtestapp"

$procid = (& xharness android adb -- shell pidof "io.sentry.dotnet.maui.device.integrationtestapp") -replace '\s', ''
$activity = (& xharness android adb -- shell dumpsys activity activities) -match "io\.sentry\.dotnet\.maui\.device\.integrationtestapp"

} while ($procid -and $activity)
}
finally
{
xharness android adb -v -- reverse --remove-all
}
} while ($procid -and $activity)
}

function UninstallAndroidApp
Expand All @@ -111,20 +99,27 @@ Describe 'MAUI app' -ForEach @(
Write-Host '::endgroup::'
}
}

# Setup port forwarding for accessing sentry-server at 127.0.0.1:8000 from the emulator
xharness android adb -v -- reverse tcp:8000 tcp:8000
}

AfterAll {
Pop-Location
xharness android adb -v -- reverse --remove tcp:8000
}

BeforeEach {
InstallAndroidApp
}

AfterEach {
UninstallAndroidApp
}

It 'Managed crash' {
It 'Managed crash (<configuration>)' {
$result = Invoke-SentryServer {
param([string]$url)
InstallAndroidApp -Dsn $url
RunAndroidApp -Dsn $url -TestArg "Managed"
RunAndroidApp -Dsn $url
}
Expand All @@ -133,12 +128,12 @@ Describe 'MAUI app' -ForEach @(
$result.HasErrors() | Should -BeFalse
$result.Envelopes() | Should -AnyElementMatch "`"type`":`"System.ApplicationException`""
$result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"SIGABRT`""
$result.Envelopes() | Should -HaveCount 1
}

It 'Java crash' {
It 'Java crash (<configuration>)' {
$result = Invoke-SentryServer {
param([string]$url)
InstallAndroidApp -Dsn $url
RunAndroidApp -Dsn $url -TestArg "Java"
RunAndroidApp -Dsn $url
}
Expand All @@ -147,12 +142,12 @@ Describe 'MAUI app' -ForEach @(
$result.HasErrors() | Should -BeFalse
$result.Envelopes() | Should -AnyElementMatch "`"type`":`"RuntimeException`""
$result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"System.\w+Exception`""
$result.Envelopes() | Should -HaveCount 1
}

It 'Native crash' {
It 'Native crash (<configuration>)' {
$result = Invoke-SentryServer {
param([string]$url)
InstallAndroidApp -Dsn $url
RunAndroidApp -Dsn $url -TestArg "Native"
RunAndroidApp -Dsn $url
}
Expand All @@ -161,20 +156,25 @@ Describe 'MAUI app' -ForEach @(
$result.HasErrors() | Should -BeFalse
$result.Envelopes() | Should -AnyElementMatch "`"type`":`"SIG[A-Z]+`"" # SIGILL (x86_64), SIGTRAP (arm64-v8a)
$result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"System.\w+Exception`""
$result.Envelopes() | Should -HaveCount 1
}

It 'Null reference exception' {
It 'Null reference exception (<configuration>)' {
$result = Invoke-SentryServer {
param([string]$url)
InstallAndroidApp -Dsn $url
RunAndroidApp -Dsn $url -TestArg "NullReferenceException"
RunAndroidApp -Dsn $url
}

Dump-ServerErrors -Result $result
$result.HasErrors() | Should -BeFalse
$result.Envelopes() | Should -AnyElementMatch "`"type`":`"System.NullReferenceException`""
# TODO: fix redundant RuntimeException (#3954)
{ $result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"SIGSEGV`"" } | Should -Throw
# TODO: fix redundant SIGSEGV in Release (#3954)
if ($configuration -eq "Release") {
{ $result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"SIGSEGV`"" } | Should -Throw
} else {
$result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"SIGSEGV`""
$result.Envelopes() | Should -HaveCount 1
}
}
}
28 changes: 18 additions & 10 deletions integration-test/ios.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ BeforeDiscovery {
$script:simulator = Get-IosSimulatorUdid -PreferredStates @('Booted')
}

Describe 'iOS app (<tfm>)' -ForEach @(
@{ tfm = "net9.0-ios18.0" }
Describe 'iOS app (<tfm>, <configuration>)' -ForEach @(
@{ tfm = "net9.0-ios18.0"; configuration = "Release" }
@{ tfm = "net9.0-ios18.0"; configuration = "Debug" }
) -Skip:(-not $script:simulator) {
BeforeAll {
. $PSScriptRoot/../scripts/device-test-utils.ps1
Expand All @@ -26,7 +27,7 @@ Describe 'iOS app (<tfm>)' -ForEach @(

Write-Host "::group::Build Sentry.Maui.Device.IntegrationTestApp.csproj"
dotnet build Sentry.Maui.Device.IntegrationTestApp.csproj `
--configuration Release `
--configuration $configuration `
--framework $tfm `
--runtime $rid
| ForEach-Object { Write-Host $_ }
Expand All @@ -35,9 +36,9 @@ Describe 'iOS app (<tfm>)' -ForEach @(

function InstallIosApp
{
Write-Host "::group::Install bin/Release/$tfm/$rid/Sentry.Maui.Device.IntegrationTestApp.app"
Write-Host "::group::Install bin/$configuration/$tfm/$rid/Sentry.Maui.Device.IntegrationTestApp.app"
xcrun simctl install $simulator `
bin/Release/$tfm/$rid/Sentry.Maui.Device.IntegrationTestApp.app
bin/$configuration/$tfm/$rid/Sentry.Maui.Device.IntegrationTestApp.app
| ForEach-Object { Write-Host $_ }
Write-Host '::endgroup::'
$LASTEXITCODE | Should -Be 0
Expand Down Expand Up @@ -86,7 +87,7 @@ Describe 'iOS app (<tfm>)' -ForEach @(
UninstallIosApp
}

It 'captures managed crash' {
It 'captures managed crash (<configuration>)' {
$result = Invoke-SentryServer {
param([string]$url)
RunIosApp -Dsn $url -TestArg "Managed"
Expand All @@ -97,9 +98,10 @@ Describe 'iOS app (<tfm>)' -ForEach @(
$result.Envelopes() | Should -AnyElementMatch "`"type`":`"System.ApplicationException`""
# TODO: fix redundant SIGABRT (#3954)
{ $result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"SIGABRT`"" } | Should -Throw
{ $result.Envelopes() | Should -HaveCount 1 } | Should -Throw
}

It 'captures native crash' {
It 'captures native crash (<configuration>)' {
$result = Invoke-SentryServer {
param([string]$url)
RunIosApp -Dsn $url -TestArg "Native"
Expand All @@ -109,9 +111,10 @@ Describe 'iOS app (<tfm>)' -ForEach @(
$result.HasErrors() | Should -BeFalse
$result.Envelopes() | Should -AnyElementMatch "`"type`":`"EXC_[A-Z_]+`""
$result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"System.\w+Exception`""
$result.Envelopes() | Should -HaveCount 1
}

It 'captures null reference exception' {
It 'captures null reference exception (<configuration>)' {
$result = Invoke-SentryServer {
param([string]$url)
RunIosApp -Dsn $url -TestArg "NullReferenceException"
Expand All @@ -120,7 +123,12 @@ Describe 'iOS app (<tfm>)' -ForEach @(

$result.HasErrors() | Should -BeFalse
$result.Envelopes() | Should -AnyElementMatch "`"type`":`"System.NullReferenceException`""
# TODO: fix redundant EXC_BAD_ACCESS (#3954)
{ $result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"EXC_BAD_ACCESS`"" } | Should -Throw
# TODO: fix redundant EXC_BAD_ACCESS in Release (#3954)
if ($configuration -eq 'Release') {
{ $result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"EXC_BAD_ACCESS`"" } | Should -Throw
} else {
$result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"EXC_BAD_ACCESS`""
$result.Envelopes() | Should -HaveCount 1
}
}
}
2 changes: 2 additions & 0 deletions integration-test/net9-maui/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ protected override void OnAppearing()

SentrySdk.Close();
#if ANDROID
// prevent auto-restart
Platform.CurrentActivity?.FinishAffinity();
Process.KillProcess(Process.MyPid());
#elif IOS
System.Environment.Exit(0);
Expand Down
3 changes: 3 additions & 0 deletions integration-test/net9-maui/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public static MauiApp CreateMauiApp()
#endif
options.Debug = false;
options.DiagnosticLevel = SentryLevel.Error;
// predictable crash envelopes only
options.SendClientReports = false;
options.AutoSessionTracking = false;
})
.ConfigureFonts(fonts =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ protected override void OnCreate(Bundle? savedInstanceState)
{
base.OnCreate(savedInstanceState);

System.Environment.SetEnvironmentVariable("SENTRY_DSN", Intent?.GetStringExtra("SENTRY_DSN"));
System.Environment.SetEnvironmentVariable("SENTRY_TEST_ARG", Intent?.GetStringExtra("SENTRY_TEST_ARG"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<MtouchUseLlvm>false</MtouchUseLlvm>
<EnableAssemblyILStripping>false</EnableAssemblyILStripping>

<!-- https://github.com/dotnet/android/wiki/Diagnose-Fast-Deployment-Issues -->
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>

<!-- Display name -->
<ApplicationTitle>Sentry.Maui.Device.IntegrationTestApp</ApplicationTitle>

Expand Down
Loading