Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/libraries/System.IO.FileSystem/tests/FileSystemTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,23 @@ public static string GetNamedPipeServerStreamName()
{
return @"LOCAL\" + Guid.NewGuid().ToString("N");
}
return Guid.NewGuid().ToString("N");

if (PlatformDetection.IsWindows)
{
return Guid.NewGuid().ToString("N");
}

const int MinUdsPathLength = 104; // required min is 92, but every platform we currently target is at least 104
const int MinAvailableForSufficientRandomness = 5; // we want enough randomness in the name to avoid conflicts between concurrent tests
string prefix = Path.Combine(Path.GetTempPath(), "CoreFxPipe_");
int availableLength = MinUdsPathLength - prefix.Length - 1; // 1 - for possible null terminator
Assert.True(availableLength >= MinAvailableForSufficientRandomness, $"UDS prefix {prefix} length {prefix.Length} is too long");

return string.Create(availableLength, 0, (span, _) =>
{
for (int i = 0; i < span.Length; i++)
span[i] = (char)('a' + Random.Shared.Next(0, 26));
});
}

/// <summary>
Expand Down