Skip to content
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] Enable tests for FileManager in Android. #2176

Merged
merged 1 commit into from
May 1, 2019

Conversation

drodriguez
Copy link
Contributor

Many tests were disabled in Android, but they actually work without
almost changes.

  • Android uses /proc/mounts as Linux. Enabling that code path gives good
    results in Android.
  • attributesOfFileSystem works on Android once glibc.modulemap
    includes the right headers (see [android] Add missing POSIX/Linux headers to Android build. swift#24286).
  • However, since Process is still not available in Android, the test
    that relies on xdgTestHelper tool will not work, and have been
    disabled (but instead of causing the test to fail, they are simply not
    run in Android, which probably will never conform to XDG).

Many tests were disable in Android, but they actually work without
almost changes.

- Android uses /proc/mounts as Linux. Enabling that code path gives good
  results in Android.
- `attributesOfFileSystem` works on Android once glibc.modulemap
  includes the right headers (see swiftlang/swift#24286).
- However, since Process is still not available in Android, the test
  that relies on xdgTestHelper tool will not work, and have been
  disabled (but instead of causing the test to fail, they are simply not
  run in Android, which probably will never conform to XDG).
@millenomi
Copy link
Contributor

millenomi commented Apr 26, 2019

Note that xdgTestHelper is used in other tests and is increasingly misnamed.

Is there a way we can spawn processes programmatically on Android?

@drodriguez
Copy link
Contributor Author

I’m looking into it. Some of the POSIX APIs used by Foundation appeared in very recent Androids (ref: https://android.googlesource.com/platform/bionic/+/master/libc/include/spawn.h), so I don’t think they are a possibility. I don’t know if I can do fork/exec instead. I don’t know if Process will be possible to bring to Android at all (and so the tests that depend on it will probably never pass in Android).

Copy link
Member

@finagolfin finagolfin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had made the first two changes when building Foundation natively on Android AArch64. I also had to disable three other Android-specific blocks in FileManager because they wouldn't compile: the two mode_t & conversion functions and the TimeInterval conversion in attributesOfItem.

@finagolfin
Copy link
Member

I don’t know if I can do fork/exec instead.

The posix_spawn added in Pie last year is a wrapper around fork, it has been backported to older Android versions too.

@spevans
Copy link
Contributor

spevans commented Apr 28, 2019

@swift-ci test

@drodriguez
Copy link
Contributor Author

@swift-ci please test linux platform

@spevans
Copy link
Contributor

spevans commented Apr 30, 2019

@swift-ci test linux

@drodriguez
Copy link
Contributor Author

@buttaface: I haven’t had problems with mode_t or TimeInterval. It seems to compile fine with NDK r18 and r16. There's a workaround at the top of the files for mode_t, I wonder if that's what’s creating the problem in your setup.

Re spawn vs. fork/exec. It is completely possible to replicate spawn, but the code also uses actions and other pieces of the API that will have to be branched out or duplicated. I think it is not impossible, but I don’t think it is easy either.

@swift-ci please test linux platform

@finagolfin
Copy link
Member

I haven’t had problems with mode_t or TimeInterval. It seems to compile fine with NDK r18 and r16.

Hmm, I'm using the latest NDK r19, with the Android API set to 21, could be why.

There's a workaround at the top of the files for mode_t, I wonder if that's what’s creating the problem in your setup.

Yes, that bitwise & function for Android makes other code not compile: I haven't looked into why, just disabled it.

It is completely possible to replicate spawn

I'll try it with the backported posix_spawn from Bionic and see how it goes.

@spevans
Copy link
Contributor

spevans commented May 1, 2019

@swift-ci test linux

@drodriguez drodriguez merged commit 2e6971e into swiftlang:master May 1, 2019
@drodriguez drodriguez deleted the android-file-manager-tests branch May 1, 2019 17:17
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.

4 participants