Skip to content

[tests] Wait for device state and bound output draining - #13697

Draft
simonrozsival wants to merge 4 commits into
dev/simonrozsival/timing-incremental-outputfrom
dev/simonrozsival/timing-device-readiness
Draft

simonrozsival wants to merge 4 commits into
dev/simonrozsival/timing-incremental-outputfrom
dev/simonrozsival/timing-device-readiness

Conversation

@simonrozsival

Copy link
Copy Markdown
Member

Device and process tests should wait for the state they require, while retaining timeouts only to detect hangs.

Windows redirected-output draining

Track and clean up the child that inherits the output handles, using its PID file if the output handshake fails. Assert that draining reports incomplete output while that child is still alive, with a generous watchdog rather than a narrow stopwatch range.

Timezone readiness

The fixture already waits until the requested timezone property is set before launching a fresh app process. Remove the additional fixed sleep and pass the selected device to the install so a second attached emulator cannot receive the fixture.

Localization service restart

After stopping Android services, poll their actual states using exit-code-aware ADB calls under one aggregate deadline, then restart services in finally. Require both the boot-completed signal and the requested locale property before starting the app. A failed getprop can no longer look like a stopped service, and a slow device is not expected to become ready within a fixed sleep.

JNI collection watchdogs

Keep the existing worker-state and collection assertions, but allow a longer watchdog for loaded devices. Preserve zero-duration timeout cases. The watchdog still detects a hang; it is not used as a performance assertion.

Validation

Validation was run with all five layers applied on macOS and an API 35 arm64 emulator; intermediate branch heads were not built separately.

  • ./dotnet-local.sh test bin/TestDebug/net11.0/Xamarin.Android.Build.Tests.dll --filter 'FullyQualifiedName~RemoveDirTests|Name~CancelStopsKeytool|Name~BuilderDoesNotWaitForInheritedRedirectedOutput' -v minimal — passed: 10 passed and 3 skipped, including the Windows-only drain test, on macOS.
  • ADB_TARGET='-s emulator-5558' ./dotnet-local.sh test bin/TestDebug/MSBuildDeviceIntegration/net11.0/MSBuildDeviceIntegration.dll --filter 'Name~CheckLocalizationIsCorrectWithSlicer&Name~fr-FR' -v minimal — passed (CoreCLR and NativeAOT).
  • ADB_TARGET='-s emulator-5558' ANDROID_SERIAL=emulator-5558 ./dotnet-local.sh test bin/TestDebug/MSBuildDeviceIntegration/net11.0/MSBuildDeviceIntegration.dll --filter '(Name~UnknownSystemLibraryLoadsWithoutMainThreadDispatch|Name~ExemptJniLibraryLoadsOnWorkerThreadWithBlockedMainThread|(Name~CheckTimeZoneInfoIsCorrectWithSlicer&Name~Europe/Prague))' --logger 'console;verbosity=normal' — passed (5 device cases, including timezone checks on CoreCLR and NativeAOT).
  • ./dotnet-local.sh build -t:Install -c Debug tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj -p:Device=emulator-5558 -p:IncludeCategories=AndroidMessageHandlerCancellation%2CJniReferenceLeakMeasurement%2CTrimmableTypeMapRuntimeCoverage -v minimal — passed.
  • (cd tests/Mono.Android-Tests/Mono.Android-Tests && ../../../dotnet-local.sh test Mono.Android.NET-Tests.csproj --no-build -c Debug -p:Device=emulator-5558 -p:IncludeCategories=AndroidMessageHandlerCancellation%2CJniReferenceLeakMeasurement%2CTrimmableTypeMapRuntimeCoverage --report-trx --results-directory ../../../bin/TestDebug/ReviewCoreCLRResults) — passed 55 cases in each of 3 CoreCLR runs on API 35 arm64.
  • ./dotnet-local.sh msbuild tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj -getProperty:_AndroidRuntime -p:PublishAot=true -p:Optimize=true -p:RuntimeIdentifier=android-arm64 -p:Configuration=Debug -p:Device=emulator-5558 — returned NativeAOT.
  • ./dotnet-local.sh build -t:Install -c Debug tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj -p:Device=emulator-5558 -p:RuntimeIdentifier=android-arm64 -p:PublishAot=true -p:Optimize=true -p:IncludeCategories=AndroidMessageHandlerCancellation%2CJniReferenceLeakMeasurement%2CTrimmableTypeMapRuntimeCoverage -v minimal — passed.
  • (cd tests/Mono.Android-Tests/Mono.Android-Tests && ../../../dotnet-local.sh test Mono.Android.NET-Tests.csproj --no-build -c Debug -p:Device=emulator-5558 -p:RuntimeIdentifier=android-arm64 -p:PublishAot=true -p:Optimize=true -p:IncludeCategories=AndroidMessageHandlerCancellation%2CJniReferenceLeakMeasurement%2CTrimmableTypeMapRuntimeCoverage --report-trx --results-directory ../../../bin/TestDebug/ReviewNativeAotResults) — passed 55 cases in each of 2 NativeAOT runs.

The drain tests establish bounded completion while the child retains its handles; they do not enforce an exact two-second duration. The Windows-specific path was not exercised locally.

@simonrozsival
simonrozsival force-pushed the dev/simonrozsival/timing-device-readiness branch from 4a0b204 to dbaa2e3 Compare November 21, 2026 16:00
@simonrozsival
simonrozsival force-pushed the dev/simonrozsival/timing-device-readiness branch from dbaa2e3 to b78223e Compare November 23, 2026 07:20
@simonrozsival
simonrozsival force-pushed the dev/simonrozsival/timing-device-readiness branch from b78223e to 2e12421 Compare November 23, 2026 07:37
simonrozsival and others added 4 commits November 23, 2026 08:55
Track and clean up the pipe-holding child, using its PID file if the output handshake fails. Assert that draining reports incomplete output while the child is still alive, with a generous hang watchdog instead of a narrow elapsed-time threshold.

Co-authored-by: Copilot App <[email protected]>
The fixture already checks the requested timezone property before launching a fresh app process; remove the additional fixed sleep. Use the configured adb target when installing the fixture.

Co-authored-by: Copilot App <[email protected]>
Observe the framework services stopped by the Android stop command, with exit-code-aware polling bounded by a single deadline, and require the boot-completed signal and expected locale property before launching the app, instead of sleeping for fixed intervals. Use the configured adb target when installing the fixture.

Co-authored-by: Copilot App <[email protected]>
Keep the state-based worker and collection assertions while allowing for slow scheduling on loaded devices. Preserve zero-duration timeout cases.

Co-authored-by: Copilot App <[email protected]>
@jonathanpeppers
jonathanpeppers force-pushed the dev/simonrozsival/timing-device-readiness branch from 2e12421 to abe7a0f Compare November 23, 2026 14:55

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant