Skip System.Formats.Tar hard-link tests on platforms that can't create hard links (Android)#126316
Open
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
Member
|
/azp list |
Member
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates System.Formats.Tar link-related tests to skip hard-link scenarios on platforms where creating hard links is not permitted (notably Android, where SELinux denies link syscalls in the app sandbox), preventing widespread CI failures.
Changes:
- Gate all tests that create hard links (directly or via shared helpers) with
MountHelper.CanCreateHardLinks. - Align hard-link test gating with the existing symbolic-link test pattern already used in the same test areas.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.File.Tests.cs | Converts the hard-link writer test to ConditionalTheory guarded by MountHelper.CanCreateHardLinks. |
| src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.File.Tests.cs | Guards hard-link extraction tests (ConditionalTheory/ConditionalFact) using MountHelper.CanCreateHardLinks. |
| src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.File.Tests.cs | Guards async hard-link extraction test with ConditionalFact using MountHelper.CanCreateHardLinks. |
| src/libraries/System.Formats.Tar/tests/TarFile/TarFile.CreateFromDirectory.File.Tests.cs | Guards CreateFromDirectory_UsesWriterOptions (which uses a hard-link fixture) with ConditionalTheory. |
| src/libraries/System.Formats.Tar/tests/TarFile/TarFile.CreateFromDirectory.Stream.Tests.cs | Guards CreateFromDirectory_UsesWriterOptions stream variant with ConditionalTheory. |
| src/libraries/System.Formats.Tar/tests/TarFile/TarFile.CreateFromDirectoryAsync.File.Tests.cs | Guards async file variant CreateFromDirectoryAsync_UsesWriterOptions with ConditionalTheory. |
| src/libraries/System.Formats.Tar/tests/TarFile/TarFile.CreateFromDirectoryAsync.Stream.Tests.cs | Guards async stream variant CreateFromDirectoryAsync_UsesWriterOptions with ConditionalTheory. |
rzikm
approved these changes
Mar 31, 2026
This was referenced Mar 31, 2026
Open
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.