-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[android] Run tests for libdispatch in x64 emulator (wip) #78762
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
[android] Run tests for libdispatch in x64 emulator (wip) #78762
Conversation
Is the goal to make it easy to run these tests locally or to run them as part of CI? I think this change makes sense for local testing, but for CI we tend to put the bulk of the logic into a GitHub workflow. This way, you can leverage many well-tested, supported GitHub actions like nttld/setup-ndk and reactivecircus/android-emulator-runner to install NDK and run tests on Android emulators. The ds2 github workflow is an example for running non-Swift tests on an Android emulator: https://github.com/compnerd/ds2/blob/main/.github/workflows/build.yml#L460 |
Thanks for the feedback and links @andrurogerz. I am sure a GitHub workflow would be a good solution, but I think we want to run this in Swift CI. Thus, we need to implement it in the build script. |
libc++ has
We likely find an answer in the above scripts
For the moment this question remains as it's Windows-specific. We will see with trial and error. |
We should consider to cross-compile ctest for the targets we need and use it as a test driver instead of the script |
Interesting, I wanted to test this in the emulator once Android is added to the official CI, so we can probably reuse this script on a linux host then. You're probably aware that the compiler validation suite currently supports running its executable tests in the emulator through adb. You obviously don't use |
Thanks for your notes @finagolfin! This is meant as a first test balloon to run something in the emulator at all in the Swift CI for Windows. I considered LIT-based tests more complicated and wanted to try something simple first. Happy to collaborate if there is overlap with Linux!
Yes, I literally found them 2 days ago :) That will help a lot with tests for Swift itself and out-of-tree libs like xctest!
I don't see how we would run these on ci.swift.org, is that possible? |
@swift-ci Please test Windows |
1b32852
to
e01333a
Compare
Pushed a number of fixes and try to save some CI resources temporarily (only build Windows x64 + Android x86_64, only test dispatch). @swift-ci Please test Windows |
I don't know how the official Windows CI works. If it doesn't allow running github action workflows, then no, it's not possible. I think Andrew's point is that you'd be better off running these tests in your existing github-based CI first, before proposing them for non-github-based CI that requires more configuration work. |
In order to test Android in Swift CI, we need the However, my above attempt failed, because the machine's Java Runtime version is outdated (55 is from 2018). @shahmishal Is there a chance that the build machines get an update? (61 is from 2021)
|
If you TBC devs don't control the Windows environment in that CI, it may be using one of the Windows Docker files, in which case you can submit a Java update change there yourself, @weliveindetail. |
Thanks @finagolfin! Yes, I'd like to consider that once I double-checked it's the right image source. |
Unfortunately, the Windows builders haven't been ported to docker. In order to unblock progress we're installing Java on the fly now. This is a terrible workaround though. It's a waste of time and resources. |
@swift-ci Please test Windows |
The installation failed with:
Must be an issue with |
@swift-ci Please test Windows |
AVD failed to create a virtual device:
|
@swift-ci Please test Windows |
The build failed before any of the changes in
Let's try that again. |
We reach that step now that creates the virtual device and need to figure out how to avoid the interactive config:
|
@swift-ci Please test Windows |
@swift-ci please test Windows |
The build failed due to an unrelated issue in LLDB:
|
swiftlang/swift-corelibs-libdispatch#855 |
Looks like we need the Java runtime for the emulator as well and not only for for cmdline-tools. This worked locally, because the Java Runtime on my host isn't outdated like the one on the CI machines. I will retry once the current run reached the timeout. |
swiftlang/swift-corelibs-libdispatch#855 |
Still:
|
I can reproduce this locally by deleting the virtual device before running the build script. It seems that we cannot run a virtual device if we just created it, in particular, in the same process tree. The emulator process crashes without further notice. We can even wait and attempt it again and it crashes the same way. My latest patch demonstrates that. Running the build script again, however, works perfectly. So, this isn't an issue with permissions or execution environment. Instead, I assume that the avdmanager keeps a file handle open and the emulator fails to lock it. Once we close the build script process, the handle is released and next time the emulator can lock it, because we don't need to recreate the virtual devices. I will double-check and see how to close them. Anyway, let's run through the current state one more time. swiftlang/swift-corelibs-libdispatch#855 |
Build bot failed as expected:
|
Trial and error found a fix locally. Let's see if CI reproduces that 🤞 |
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.
We got past the emulator startup 🙌
utils/build.ps1
Outdated
|
||
Write-Host "Waiting while Android emulator boots in process $AndroidEmulatorPid" | ||
$adb = "$BinaryCache\android-sdk\platform-tools\adb.exe" | ||
Invoke-Program $adb "wait-for-device" |
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.
Now the build bot hangs here in adb wait-for-device
@swift-ci please test Windows |
No luck with that
|
Are you familiar with the popular ReactiveCircus github workflow to start an Android emulator on macOS/linux? They have it create some kind of polling loop in Typescript that waits to make sure the emulator starts up. Maybe you could look at their OSS code and find something useful for your Windows emulator startup here. |
No I wasn't aware of it. I am afraid the issues here are very Windows specific, but it's still a good source for common things to try. Like emulator flags |
@swift-ci please test Windows |
@swift-ci please test Windows |
@swift-ci please test Windows |
Android emulator requires Hyper-V support in Windows, but the CI machines don't seem to have it.
|
Early preview for a ctest-based library that raises some questions:
ctest_mock.sh
(we might be able to avoid this one).adb
network access once. How to do that in CI?