Skip to content

[tests] Add DotNetRunCtrlC integration test#11293

Draft
jonathanpeppers wants to merge 1 commit intomainfrom
jonathanpeppers/ctrl-c-device-test
Draft

[tests] Add DotNetRunCtrlC integration test#11293
jonathanpeppers wants to merge 1 commit intomainfrom
jonathanpeppers/ctrl-c-device-test

Conversation

@jonathanpeppers
Copy link
Copy Markdown
Member

Adds a device integration test that verifies Ctrl+C (SIGINT) sent to dotnet run properly stops the Android app on the device/emulator.

Test flow:

  1. Build and launch an Android app via dotnet run with WaitForExit=true
  2. Wait for app logcat output confirming launch
  3. Verify the app PID exists on the device via adb shell pidof
  4. Send SIGINT via process.SendCtrlC() extension method
  5. Assert the process exits gracefully
  6. Verify Microsoft.Android.Run's Ctrl+C handler ran ("Stopping application...")
  7. Confirm the app is no longer running on the device

Also adds a SendCtrlC() extension method on Process in ProcessExtensions.cs, using libc kill(pid, SIGINT) P/Invoke (Unix/macOS only; throws PlatformNotSupportedException on Windows).

Fixes #11264

Add a device integration test that verifies Ctrl+C (SIGINT) sent to
`dotnet run` properly stops the Android app on the device/emulator.

The test:
1. Builds and launches an Android app via `dotnet run` with WaitForExit
2. Waits for app logcat output confirming launch
3. Verifies the app PID exists on the device
4. Sends SIGINT via Process.SendCtrlC() extension method
5. Asserts the process exits gracefully
6. Verifies Microsoft.Android.Run's Ctrl+C handler ran ("Stopping application...")
7. Confirms the app is no longer running on the device

Also adds a `SendCtrlC()` extension method on `Process` in
`ProcessExtensions.cs`, using libc `kill(pid, SIGINT)` P/Invoke.
Windows support is not yet implemented (throws PlatformNotSupportedException).

Fixes: #11264

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dotnet run Ctrl+C does not stop the app on the device

1 participant