swift-android-sdk icon indicating copy to clipboard operation
swift-android-sdk copied to clipboard

Add testing for swift-corelibs-foundation-android-test repo

Open marcprux opened this issue 1 year ago • 6 comments

This PR adds testing for the https://github.com/marcprux/swift-corelibs-foundation-android-test.git repository, which is a fork of https://github.com/apple/swift-corelibs-foundation.git that builds only the Tests/ part of the package and adapts a number of Foundation tests to accommodate Android. A number of tests are disabled (mostly some daylight savings and Process forking tests), but most pass on the Android emulator.

Having this baseline of tests that pass for swift-corelibs-foundation will be useful to see what breaks (or is fixed) when swift-foundation is added to the mix.

Note that this PR relies on the additional Termux libraries added in https://github.com/finagolfin/swift-android-sdk/pull/167, since those are required to run the XMLParser and URLSession tests.

marcprux avatar Sep 14 '24 14:09 marcprux

I am currently in the process of updating the CI to cross-compile the latest snapshot tags of the SDK, including the two updated foundation repos for Android. So far it works well for trunk 6.1, going to try 6.0 next.

I had not thought of building and running the foundation tests too, but you are right that since these are structured as Swift packages now, it should be possible to cross-compile the foundation test runners too.

Hold off for a bit till I get that in: it may be easier to use those patches to build these tests, as I use patches like apple/swift-foundation#871 natively on Android AArch64 to get almost all the tests passing.

Also, I see a strange TLS issue when building this test runner natively, that required some workarounds to get all the tests running and get their output.

finagolfin avatar Sep 15 '24 13:09 finagolfin

I am currently in the process of updating the CI to cross-compile the latest snapshot tags of the SDK, including the two updated foundation repos for Android. So far it works well for trunk 6.1, going to try 6.0 next.

Great! Is this pushed to a branch somewhere? Let me know if there is anything I can do to help … I'm very eager to get going with Swift 6 and swift-foundation.

Hold off for a bit till I get that in: it may be easier to use those patches to build these tests, as I use patches like apple/swift-foundation#871 natively on Android AArch64 to get almost all the tests passing.

Will do. I'll leave this as a draft PR for the time being, but feel free to close it and I'll open a new one later if you think that would be better.

Also, I see a strange TLS issue when building this test runner natively, that required some workarounds to get all the tests running and get their output.

Do you mean a TLS issue with URLSession and HTTPS URLs on Android? If so, you may be interested in this: https://gist.github.com/marcprux/34dd8da76ea56dca719b47b4b0072b98

marcprux avatar Sep 15 '24 16:09 marcprux

Great! Is this pushed to a branch somewhere?

No, still cleaning up and extracting my local patches.

Let me know if there is anything I can do to help … I'm very eager to get going with Swift 6 and swift-foundation.

OK, I will get that up by tomorrow, so we can iterate on it independently from then on.

Will do. I'll leave this as a draft PR for the time being

Sounds good.

Do you mean a TLS issue with URLSession and HTTPS URLs on Android?

No, I mean Thread-Local Storage, which I now see the Swift stdlib just added for the first time this summer on linux platforms. This caused no problems for me before because it was always invoked from the shared library libFoundation.so, but after the re-core on swift-foundation, SwiftPM builds the swift-corelibs-foundation test runner without dynamic linking of the Foundation libraries like libFoundation.so, ie statically linking those object files instead, which then causes problems because Android didn't support native TLS till API 29, whereas I'm building for API 24.

I'm not sure exactly why it causes problems for executables alone- haven't dug into it- but it doesn't appear to be using the emulated TLS talked about there. Could be a simple mis-configuration on my end, will need to look into it.

finagolfin avatar Sep 16 '24 04:09 finagolfin

I'm still sorting through the Android patches for Swift 6, should have that up tonight.

finagolfin avatar Sep 19 '24 18:09 finagolfin

Unless you really care about checking the APIs in swift-corelibs-foundation, it may be better to change this to testing swift-foundation alone for now, at least until we get the TLS issue figured out, as bumping the emulator API level doesn't help with this repo. The official CI runs the tests for both repos separately, which we can try once the TLS issue is resolved.

finagolfin avatar Oct 07 '24 03:10 finagolfin

The last time I looked, the swift-foundation tests didn't have as much coverage as swift-corelibs-foundation, but it seems like they have been expanded considerably. I'll take a look at them. Thanks!

marcprux avatar Oct 07 '24 04:10 marcprux

I don't think we need this. Closing.

marcprux avatar Dec 12 '24 21:12 marcprux

I'll try to get this in once we have the emulated TLS fix.

finagolfin avatar Dec 12 '24 22:12 finagolfin