Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tests] Kill the emulator in ReleaseAndroidTarget
We've been noticing that emulator-based unit test execution is getting "finicky", e.g. [PR Build dotnet#939][0]: Target AcquireAndroidTarget: Task "CheckAdbTarget" Tool /Users/builder/android-toolchain/sdk/platform-tools/adb execution started with arguments: shell getprop ro.build.version.sdk Environment variables being passed to the tool: 21 Tool /Users/builder/android-toolchain/sdk/platform-tools/adb execution finished. [Output] AdbTarget: [Output] IsValidTarget: True Done executing task "CheckAdbTarget" This means that there is already an Android device attached (emulator or hardware...), as *something* is responding to `adb shell getprop`. However...that attached device is b0rked: Target UndeployUnitTestApks: Task "Adb" Task Adb Arguments: uninstall "Mono.Android_Tests" Tool /Users/builder/android-toolchain/sdk/platform-tools/adb execution started with arguments: uninstall "Mono.Android_Tests" Environment variables being passed to the tool: Error: Could not access the Package Manager. Is the system running? Tool /Users/builder/android-toolchain/sdk/platform-tools/adb execution finished. [Output] Output: Error: Could not access the Package Manager. Is the system running? Done executing task "Adb" *Every* attempt to "do something" with the device -- uninstall and install packages, run applications, etc. -- results in the "Could not access the Package Manager" error. The device is dead, yet still present. We want on-device unit test execution to be *reliable* (7450efc). It isn't, and that's very annoying. Manual investigation of the Jenkins build machine after these errors occur indicates that after `adb TARGET emu kill` executes (as part of `make run-apk-tests`), the `emulator` process *is still running*. Hopefully, that's the problem: the emulator process isn't dead. Fix the problem by *killing* the process, with not-quite-extreme prejudice, by invoking `Process.Kill()` on the `System.Diagnostics.Process` instance that represents `emulator`. (If that doesn't kill it, we'll need to escalate to extreme `kill -9` prejudice.) *For good measure*, run `adb kill-server` within `ReleaseAndroidTarget`, to keep the `adb` daemone from outlasting it's usefulness. [0]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android-pr-builder/939/
- Loading branch information