Skip System.Formats.Tar hard-link tests on platforms that can't create hard links (Android)#126316
Draft
Skip System.Formats.Tar hard-link tests on platforms that can't create hard links (Android)#126316
Conversation
…ks guards
Android's SELinux app sandbox prohibits hard link creation (denied { link }).
Tests that call File.CreateHardLink fail with UnauthorizedAccessException.
Guard all affected tests with [ConditionalFact/ConditionalTheory(typeof(MountHelper),
nameof(MountHelper.CanCreateHardLinks))] to skip them when hard links are unavailable.
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/9ff99a47-c680-4c34-9df0-eb63eaf86bdd
Co-authored-by: rzikm <32671551+rzikm@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix UnauthorizedAccessException for creating hard links in Android app
Skip System.Formats.Tar hard-link tests on platforms that can't create hard links (Android)
Mar 30, 2026
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-formats-tar |
This was referenced Mar 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Android's SELinux app sandbox denies
linksyscalls from untrusted apps, causingUnauthorizedAccessExceptionin any test that callsFile.CreateHardLink. This produced 154 CI failures across all Android architectures (x86/arm/arm64/x64) on both Mono and CoreCLR.Description
All test methods in
System.Formats.Tar.Teststhat callFile.CreateHardLink— either directly or via the sharedCreateSourceDirectoryForCreateFromDirectory_UsesWriterOptions()helper — are now gated with[ConditionalFact/ConditionalTheory(typeof(MountHelper), nameof(MountHelper.CanCreateHardLinks))]. This is the same pattern already used in the same files for symbolic-link tests.Changed tests:
TarWriter_WriteEntry_File_Tests.WriteEntry_HardLinksTarFile_ExtractToDirectory_File_Tests.HardLinkExtractionRoundtripTarFile_ExtractToDirectory_File_Tests.HardLinkExtraction_CopyContentsTarFile_ExtractToDirectoryAsync_File_Tests.HardLinkExtraction_CopyContentsAsyncTarFile_CreateFromDirectory_{File,Stream}_Tests.CreateFromDirectory_UsesWriterOptionsTarFile_CreateFromDirectoryAsync_{File,Stream}_Tests.CreateFromDirectoryAsync_UsesWriterOptionsNote: the guard is required even for
TarHardLinkMode.CopyContents/preserveLinks=falsevariants — those tests still invokeFile.CreateHardLinkduring setup to create the source fixture.MountHelper.CanCreateHardLinksdoes a live capability probe (Lazy<bool>), so tests are skipped correctly on any platform that disallows hard links, not just Android.