5

Make std tests pass on newer Android by pcc · Pull Request #102757 · rust-lang/r...

 1 year ago
source link: https://github.com/rust-lang/rust/pull/102757
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Make std tests pass on newer Android #102757

Conversation

Contributor

Newer versions of Android forbid the creation of hardlinks as well as Unix domain sockets in the /data filesystem via SELinux rules, which causes several tests depending on this behavior to fail. So let's skip these tests on Android if we see an EACCES from one of these syscalls. To achieve this, introduce a macro with the horrible name of or_panic_or_skip_on_android_eacces (better suggestions welcome) which skips (returns from) the test if an EACCES return value is seen on Android.

Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @m-ou-se (or someone else) soon.

Please see the contribution instructions for more information.

Collaborator

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

rustbot

added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label

Oct 6, 2022

rust-highfive

added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label

Oct 6, 2022

Contributor

Author

This comment has been minimized.

Member

Newer versions of Android forbid the creation of hardlinks as well as Unix domain sockets in the /data filesystem

Can we find another fs to test on instead? E.g. /tmp?

Contributor

Author

Unfortunately Android devices do not have a filesystem mounted at /tmp. /data is AFAIK pretty much the only filesystem that we can rely on to be present and writable as the shell user (which adb shell commands run as).

Member

An issue with this is that we no longer know which tests are actually run and which are skipped on Android. Maybe we should explicitly check for the android version to decide whether a test should be skipped? Or just #[ignore] the tests on Android entirely?

m-ou-se

added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.

and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

labels

Oct 11, 2022

Contributor

Author

An issue with this is that we no longer know which tests are actually run and which are skipped on Android. Maybe we should explicitly check for the android version to decide whether a test should be skipped? Or just #[ignore] the tests on Android entirely?

I'm not sure if it's as simple as checking the Android version (I'm not sure when these restrictions were added and it might not have been at the same time on every device). Applications wouldn't be able to use these APIs successfully so there's less value in testing them, but on the other hand Rust is increasingly being used in the operating system itself. If we don't care that much about whether these tests pass on Android and we expect the existing testing on non-Android Linux to be sufficient then yes, the simplest approach is to ignore them on Android, and I've updated the patch to do that. For the operating system use case we may consider arranging to run these tests only on rooted devices, but that can come later.

Contributor

Author

Anything else needed here? As I mentioned, the tests are now ignored on Android.

Contributor

Author

Ping.

Member

@rustbot ready

rustbot

added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.

labels

Jan 23, 2023

Contributor

umbrella The latest upstream changes (presumably #106673) made this pull request unmergeable. Please resolve the merge conflicts.

Contributor

Author

Ping.

Contributor

It seems somewhat unfortunate to be ignoring the tests entirely but...

Applications wouldn't be able to use these APIs successfully so there's less value in testing them, but on the other hand Rust is increasingly being used in the operating system itself... For the operating system use case we may consider arranging to run these tests only on rooted devices, but that can come later.

Fair enough. And ignored tests can be run explicitly. I wonder though if there could be some way for the tests to be opt-in as a group? I'm thinking something like:

#[cfg_attr(all(target_os = "android", not(test_rooted_android_device)), ignore)]

Or some other --cfg that can be passed in using rustflags. I'm not sure of the name.

Contributor

Author

What I had in mind for later was that the tests could opt in automatically by checking for getuid() == 0 and skipping if false. That way, we don't end up adding a developer-facing --cfg that we'd just remove again a few months later. Choosing the right thing to do here may take some discussion.

I do think though that as a first step we should make these tests stop failing on Android, since after several months it's already getting rather tedious to need to patch this in every time I need to run the tests.

Contributor

Extremely annoying but at the same time seems fine to me.
r? @workingjubilee
@bors r+

Contributor

pushpin Commit fed6fce has been approved by workingjubilee

It is now in the queue for this repository.

bors

added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

labels

Jul 26, 2023

Contributor

hourglass Testing commit fed6fce with merge a6236fa...

Contributor

sunny Test successful - checks-actions
Approved by: workingjubilee
Pushing a6236fa to master...

bors

added the merged-by-bors This PR was explicitly merged by bors label

Jul 26, 2023

bors

merged commit a6236fa into

rust-lang:master

Jul 26, 2023

1 check passed

Collaborator

Finished benchmarking commit (a6236fa): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 650.76s -> 652.439s (0.26%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Labels
merged-by-bors This PR was explicitly merged by bors S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects

None yet

Milestone

1.73.0

Development

Successfully merging this pull request may close these issues.

None yet

10 participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK