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

Make std tests pass on newer Android #102757

Merged
merged 1 commit into from
Jul 26, 2023
Merged

Conversation

pcc
Copy link
Contributor

@pcc pcc commented Oct 6, 2022

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.

@rust-highfive
Copy link
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.

@rustbot
Copy link
Collaborator

rustbot commented Oct 6, 2022

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 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 rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 6, 2022
@pcc
Copy link
Contributor Author

pcc commented Oct 6, 2022

cc @chriswailes

@rust-log-analyzer

This comment has been minimized.

@the8472
Copy link
Member

the8472 commented Oct 7, 2022

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?

@pcc
Copy link
Contributor Author

pcc commented Oct 7, 2022

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).

@m-ou-se
Copy link
Member

m-ou-se commented Oct 11, 2022

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 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
@pcc
Copy link
Contributor Author

pcc commented Oct 12, 2022

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.

@pcc
Copy link
Contributor Author

pcc commented Dec 10, 2022

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

@pcc
Copy link
Contributor Author

pcc commented Jan 23, 2023

Ping.

@the8472
Copy link
Member

the8472 commented Jan 23, 2023

@rustbot ready

@rustbot 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
@bors
Copy link
Contributor

bors commented Mar 2, 2023

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

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 with an #[ignore] directive.
@pcc
Copy link
Contributor Author

pcc commented Mar 3, 2023

Ping.

@ChrisDenton
Copy link
Member

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.

@pcc
Copy link
Contributor Author

pcc commented Apr 22, 2023

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.

@workingjubilee
Copy link
Member

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

@bors
Copy link
Contributor

bors commented Jul 26, 2023

📌 Commit fed6fce has been approved by workingjubilee

It is now in the queue for this repository.

@bors 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
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Jul 26, 2023
…bilee

Make std tests pass on newer Android

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.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 26, 2023
…bilee

Make std tests pass on newer Android

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.
@bors
Copy link
Contributor

bors commented Jul 26, 2023

⌛ Testing commit fed6fce with merge a6236fa...

@bors
Copy link
Contributor

bors commented Jul 26, 2023

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 26, 2023
@bors bors merged commit a6236fa into rust-lang:master Jul 26, 2023
@rustbot rustbot added this to the 1.73.0 milestone Jul 26, 2023
@rust-timer
Copy link
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

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.6% [-3.7%, -3.6%] 2
All ❌✅ (primary) - - 0

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
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
Development

Successfully merging this pull request may close these issues.

10 participants