This is an archive of the discontinued LLVM Phabricator instance.

[libc++][Android] Disable test_no_resolve_symlink_on_symlink on Android
AcceptedPublic

Authored by rprichard on Dec 15 2022, 6:21 PM.

Details

Reviewers
danalbert
ldionne
Group Reviewers
Restricted Project
Summary

The test is intended to ensure a particular behavior, but different
versions of Android (even just L and up) have multiple possible
behaviors.

Starting with Android M, fchmodat appears to successfully modify the
permissions of a symlink on an ext4 filesystem (but not f2fs). With
Android R, fchmodat then fails with operation_not_supported, but still
modifies the symlink's permissions. This issue is tracked internally at
http://b/262631136.

Diff Detail

Event Timeline

rprichard created this revision.Dec 15 2022, 6:21 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 15 2022, 6:21 PM
rprichard requested review of this revision.Dec 15 2022, 6:21 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 15 2022, 6:21 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
Mordante accepted this revision as: Restricted Project.Dec 18 2022, 11:18 AM
Mordante added a subscriber: Mordante.

Looks good from libc++'s point of view. I really like @danalbert review to see whether the comments are correct.

Looks good from libc++'s point of view. I really like @danalbert review to see whether the comments are correct.

Sounds good. @danalbert is going to be on vacation until next year. Maybe I can find someone else to review them?

ldionne accepted this revision.Dec 20 2022, 4:32 PM
ldionne added a subscriber: ldionne.

Would it be better to instead XFAIL it using Lit machinery? Right now you're disabling the test even when it would succeed, which means you're losing that coverage.

I'm fine with the patch, but I think you may want to do something less drastic to retain coverage on your platform.

This revision is now accepted and ready to land.Dec 20 2022, 4:32 PM

Would it be better to instead XFAIL it using Lit machinery? Right now you're disabling the test even when it would succeed, which means you're losing that coverage.

I'm fine with the patch, but I think you may want to do something less drastic to retain coverage on your platform.

I think the last bullet point is the correct behavior (no-op + operation_not_supported).

I'm not quite sure what this test ought to cover. Should it:

  • Just verify that libc++ translates std::filesystem APIs properly to the Linux fchmodat API, or
  • Also verify that fchmodat itself works.

If we want to cover both, then we'd need to define when fchmodat is expected to work correctly, which is complicated. Currently, this appears to be:

  • If /data is f2fs, then fchmodat appears to work for Android M and up.
  • If /data is any other FS, then fchmodat is currently broken, but it might be fixed in a new Android platform (libc.so) and/or a fixed Android kernel.

Maybe we can add a features.py test that looks for a broken fchmodat on Android? It would need to repeat parts of the symlink test but using fchmodat instead of std::filesystem. If we want to test fchmodat itself, then we could carve out the cases that are expected to work:

  • Parse /proc/mounts and look for a /data of type f2fs.
  • Use android_get_device_api_level to detect a platform that should work.
  • If there's a kernel patch, then parse the kernel version and look for ones that are guaranteed to have the fix. (Older versions could have a backported fix?)

FWIW, I have another WIP patch that tries to fix the rest of std::filesystem for Android. It disables tests for hard links, FIFOs, and domain sockets, because all of these are blocked by SELinux policy, at least for the shell (non-root) user. Unfortunately, I suspect non-emulator L devices can't run any of the std::filesystem tests, because they can't create symlinks, and I haven't figured out yet how to accommodate that yet.

I reported a kernel bug related to this issue, https://bugzilla.kernel.org/show_bug.cgi?id=216834.

XFAIL would remove test coverage of the rest of this test file, which I think is more interesting than what test_no_resolve_symlink_on_symlink is testing. But it should be easy to split test_no_resolve_symlink_on_symlink into its own test file?

I think the condition we want for the XFAIL today is "/data/local/tmp is on an ext4 filesystem and/or the device's API is 21 or 22". The latter could be determined using android_get_device_api_level() and added to a general feature like android-device-api=$API. We could determine the filesystem type by dumping and parsing /proc/mounts. We may have to revisit that if the kernel gets fixed in a way that fixes this test for Bionic. (IIRC, I think other libc's implement fchmodat differently, in a way that doesn't expose the kernel behavior.)