-
-
Notifications
You must be signed in to change notification settings - Fork 203
test: add Android emulator test for dotnet signal handling #1574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jpnurmi
merged 29 commits into
jpnurmi/fix/sa-nodefer-chain-at-start
from
jpnurmi/test/android-dotnet-signals
Mar 13, 2026
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
7a5322d
test: add Android emulator test for dotnet signal handling
jpnurmi 09a5a3a
fix: wrap skipif conditions in bool() to avoid pytest string evaluation
jpnurmi 43a5fe2
ci: install .NET SDK and Android workload for Android CI jobs
jpnurmi 956ceb5
fix: only target net10.0-android when ANDROID_HOME is set
jpnurmi 03a16f7
fix: use ANDROID_API instead of ANDROID_HOME for android TFM condition
jpnurmi 236914d
test: print logcat output for Android test diagnostics
jpnurmi e2f516c
fix: use sh -c for run-as commands on Android
jpnurmi 4206e14
test: include stdout/stderr in dotnet run returncode assertions
jpnurmi e0642e7
fix: use am start -W to avoid race in Android test
jpnurmi 39361fc
fix: exclude Android sources from desktop dotnet build
jpnurmi e03edad
try arm64-v8a
jpnurmi 8dc739f
try x86_64 on linux
jpnurmi 5480f0a
Test 22-30
jpnurmi 594bd41
fix: move test logic to OnResume to avoid am start -W hang
jpnurmi 17714ed
ci: use default emulator target instead of google_apis
jpnurmi cdf3474
fix: replace sleeps with retry loops in Android test
jpnurmi 23e5bfe
fix: add timeout to am start -W with logcat dump on failure
jpnurmi 41a24dd
fix: run test directly on UI thread instead of background thread
jpnurmi ad29174
fix: use DecorView.Post + worker thread for Android test
jpnurmi dd06544
fix: simplify Android test app and handle am start -W timeout
jpnurmi d399edb
fix: emulate MAUI abort behavior for unhandled exceptions on Android
jpnurmi c4b63fa
fix: expect no crash for unhandled managed exceptions on Android
jpnurmi d51ab3f
ci: drop broken Android API 22 job
jpnurmi f45a661
ci: switch Android emulator to google_apis, drop API 27
jpnurmi 6947607
test: skip Android dotnet signal test on API < 26
jpnurmi 286b922
Try macos-15-large again, drop others but 26
jpnurmi cd82d46
test: clean up dotnet signal test assertions and comments
jpnurmi d337b49
ci: switch Android emulator back to default target
jpnurmi c03b5af
fix: use double quotes in run-as shell wrapper to preserve inner quotes
jpnurmi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| <!-- Prevent MSBuild from using parent Directory.Build.props --> | ||
| <Project /> |
31 changes: 31 additions & 0 deletions
31
tests/fixtures/dotnet_signal/Platforms/Android/MainActivity.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| using Android.App; | ||
| using Android.OS; | ||
|
|
||
| // Required for "adb shell run-as" to access the app's data directory in Release builds | ||
| [assembly: Application(Debuggable = true)] | ||
|
|
||
| namespace dotnet_signal; | ||
|
|
||
| [Activity(Name = "dotnet_signal.MainActivity", MainLauncher = true)] | ||
| public class MainActivity : Activity | ||
| { | ||
| protected override void OnResume() | ||
| { | ||
| base.OnResume(); | ||
|
|
||
| var arg = Intent?.GetStringExtra("arg"); | ||
| if (!string.IsNullOrEmpty(arg)) | ||
| { | ||
| var databasePath = FilesDir?.AbsolutePath + "/.sentry-native"; | ||
|
|
||
| // Post to the message queue so the activity finishes starting | ||
| // before the crash test runs. Without this, "am start -W" may hang. | ||
| new Handler(Looper.MainLooper!).Post(() => | ||
| { | ||
| Program.RunTest(new[] { arg }, databasePath); | ||
| FinishAndRemoveTask(); | ||
| Java.Lang.JavaSystem.Exit(0); | ||
| }); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,23 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net10.0</TargetFramework> | ||
| <TargetFrameworks>net10.0</TargetFrameworks> | ||
| <TargetFrameworks Condition="'$(ANDROID_API)' != ''">$(TargetFrameworks);net10.0-android</TargetFrameworks> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup Condition="$(TargetFramework.Contains('-android'))"> | ||
| <ApplicationId>io.sentry.ndk.dotnet.signal.test</ApplicationId> | ||
| <SupportedOSPlatformVersion>21</SupportedOSPlatformVersion> | ||
| <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup Condition="!$(TargetFramework.Contains('-android'))"> | ||
| <Compile Remove="Platforms\Android\**" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup Condition="$(TargetFramework.Contains('-android'))"> | ||
| <AndroidNativeLibrary Include="native\**\*.so" /> | ||
| </ItemGroup> | ||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left one of the Android builds (API 35) running with
macos-15-largeand changed the rest to useubuntu-latest, which is much cheaper, faster, and works fine with KVM. The host doesn't really matter, but it's nice to have both in the CI to ensure the test suite works on either.