Skip to content
Draft
Show file tree
Hide file tree
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
2 changes: 0 additions & 2 deletions eng/testing/tests.browser.targets
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@
<_AppArgs Condition="'$(WasmTestAppArgs)' != ''">$(_AppArgs) $(WasmTestAppArgs)</_AppArgs>

<WasmXHarnessMonoArgs Condition="'$(XunitShowProgress)' == 'true'">$(WasmXHarnessMonoArgs) --setenv=XHARNESS_LOG_TEST_START=true</WasmXHarnessMonoArgs>
<!-- help unit test with PlatformDetection.IsThreadingSupported via IsBrowserThreadingSupported env variable -->
<WasmXHarnessMonoArgs Condition="'$(WasmEnableThreads)' == 'true'">$(WasmXHarnessMonoArgs) --setenv=IsBrowserThreadingSupported=true</WasmXHarnessMonoArgs>
<WasmXHarnessMaxParallelThreads Condition="'$(WasmEnableThreads)' == 'true' and '$(WasmXHarnessMaxParallelThreads)' == ''">8</WasmXHarnessMaxParallelThreads>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private void StartCallback()
/// </summary>
public static void SpinWait(int iterations)
{
if (Thread.IsSingleThreaded) return;
if (!RuntimeFeature.IsMultithreadingSupported) return;

if (iterations < SpinWaitCoopThreshold)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ public virtual async Task Flush_MultipleTimes_Idempotent(ReadWriteMode mode)
await FlushAsync(mode, stream);
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
public virtual async Task Flush_SetLengthAtEndOfBuffer_OperatesOnValidData()
{
if (!CanSeek || !CanSetLengthGreaterThanCapacity)
Expand Down Expand Up @@ -1734,7 +1734,7 @@ public virtual async Task ReadAsync_CancelPendingValueTask_ThrowsCancellationExc
await ValidateCancelableReadAsyncValueTask_AfterInvocation_ThrowsCancellationException(readable, cancellationDelay);
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
[SkipOnPlatform(TestPlatforms.LinuxBionic, "SElinux blocks UNIX sockets in our CI environment")]
[SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "iOS/tvOS blocks binding to UNIX sockets")]
public virtual async Task ReadWriteByte_Success()
Expand Down Expand Up @@ -1919,7 +1919,7 @@ public virtual async Task ReadWrite_MessagesSmallerThanReadBuffer_Success(ReadWr
}
}

[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
[MemberData(nameof(AllReadWriteModesAndValue), false)]
[MemberData(nameof(AllReadWriteModesAndValue), true)]
[SkipOnPlatform(TestPlatforms.LinuxBionic, "SElinux blocks UNIX sockets in our CI environment")]
Expand Down Expand Up @@ -2400,7 +2400,7 @@ public virtual async Task ZeroByteWrite_OtherDataReceivedSuccessfully(ReadWriteM
await writes;
}

[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
[InlineData(false)]
[InlineData(true)]
[SkipOnPlatform(TestPlatforms.LinuxBionic, "SElinux blocks UNIX sockets in our CI environment")]
Expand Down Expand Up @@ -2519,13 +2519,13 @@ public static IEnumerable<object[]> CopyToAsync_AllDataCopied_MemberData() =>

[OuterLoop("May take several seconds", ~TestPlatforms.Browser)]
[SkipOnPlatform(TestPlatforms.Browser, "Not supported on browser")]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
[InlineData(false)]
[InlineData(true)]
public virtual async Task CopyToAsync_AllDataCopied_Large(bool useAsync) =>
await CopyToAsync_AllDataCopied(1024 * 1024, useAsync);

[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
[MemberData(nameof(CopyToAsync_AllDataCopied_MemberData))]
[SkipOnPlatform(TestPlatforms.LinuxBionic, "SElinux blocks UNIX sockets in our CI environment")]
[SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "iOS/tvOS blocks binding to UNIX sockets")]
Expand Down Expand Up @@ -2564,7 +2564,7 @@ public virtual async Task CopyToAsync_AllDataCopied(int byteCount, bool useAsync
}

[OuterLoop("May take several seconds")]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
[SkipOnPlatform(TestPlatforms.LinuxBionic, "SElinux blocks UNIX sockets in our CI environment")]
[SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "iOS/tvOS blocks binding to UNIX sockets")]
public virtual async Task Parallel_ReadWriteMultipleStreamsConcurrently()
Expand Down Expand Up @@ -2730,7 +2730,7 @@ public virtual async Task ClosedConnection_WritesFailImmediately_ThrowException(
await Assert.ThrowsAsync<IOException>(async () => { await Task.Factory.FromAsync(writeable.BeginWrite, writeable.EndWrite, new byte[1], 0, 1, null); });
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
[SkipOnPlatform(TestPlatforms.LinuxBionic, "SElinux blocks UNIX sockets in our CI environment")]
[SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "iOS/tvOS blocks binding to UNIX sockets")]
public virtual async Task ReadAsync_DuringReadAsync_ThrowsIfUnsupported()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void EmptyData_RoundTrips()
}
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
public virtual void FlushAsync_DuringWriteAsync()
{
byte[] buffer = new byte[100000];
Expand Down Expand Up @@ -98,7 +98,7 @@ public virtual void FlushAsync_DuringWriteAsync()
}
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
public async Task FlushAsync_DuringReadAsync()
{
byte[] buffer = new byte[32];
Expand All @@ -125,7 +125,7 @@ public async Task FlushAsync_DuringReadAsync()
}
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
public async Task FlushAsync_DuringFlushAsync()
{
byte[] buffer = null;
Expand Down Expand Up @@ -166,7 +166,7 @@ public async Task FlushAsync_DuringFlushAsync()
}
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
public virtual async Task Dispose_WithUnfinishedReadAsync()
{
string compressedPath = CompressedTestFile(UncompressedTestFile());
Expand Down
12 changes: 6 additions & 6 deletions src/libraries/Common/tests/System/TimeProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static IEnumerable<object[]> TimersProvidersData()
yield return new object[] { new FastClock(), 600 }; // At least 4-periods of of 150ms. fast clock cut time by half
}

[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
[MemberData(nameof(TimersProvidersData))]
public void TestProviderTimer(TimeProvider provider, int minMilliseconds)
{
Expand Down Expand Up @@ -213,7 +213,7 @@ private static void CancelAfter(TimeProvider provider, CancellationTokenSource c
}
#endif // NETFRAMEWORK

[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
[MemberData(nameof(TimersProvidersListData))]
public static void CancellationTokenSourceWithTimer(TimeProvider provider)
{
Expand Down Expand Up @@ -294,7 +294,7 @@ public static void CancellationTokenSourceWithTimer(TimeProvider provider)
cts.Dispose();
}

[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
[MemberData(nameof(TimersProvidersWithTaskFactorData))]
public static void RunDelayTests(TimeProvider provider, ITestTaskFactory taskFactory)
{
Expand Down Expand Up @@ -333,7 +333,7 @@ public static void RunDelayTests(TimeProvider provider, ITestTaskFactory taskFac
Assert.False(task4.IsCompleted, "RunDelayTests: > FAILED. Delay(10000) appears to have completed too soon(2).");
}

[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
[MemberData(nameof(TimersProvidersWithTaskFactorData))]
public static async Task RunWaitAsyncTests(TimeProvider provider, ITestTaskFactory taskFactory)
{
Expand Down Expand Up @@ -396,7 +396,7 @@ public static async Task RunWaitAsyncTests(TimeProvider provider, ITestTaskFacto
}

#if !NETFRAMEWORK
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
[MemberData(nameof(TimersProvidersListData))]
public static async Task PeriodicTimerTests(TimeProvider provider)
{
Expand Down Expand Up @@ -662,7 +662,7 @@ public static IEnumerable<object[]> TaskFactoryData()
#endif // TESTEXTENSIONS
}

[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
[MemberData(nameof(TaskFactoryData))]
public async Task TestDelayTaskContinuation(ITestTaskFactory taskFactory)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,12 @@ public static int SlowRuntimeTimeoutModifier
public static bool FileCreateCaseSensitive => IsCaseSensitiveOS;
#endif

public static bool IsThreadingSupported => (!IsWasi && !IsBrowser) || IsWasmThreadingSupported;
public static bool IsWasmThreadingSupported => IsBrowser && IsEnvironmentVariableTrue("IsBrowserThreadingSupported");
public static bool IsNotWasmThreadingSupported => !IsWasmThreadingSupported;
#if NET && !TARGETS_NET10
public static bool IsMultithreadingSupported => RuntimeFeature.IsMultithreadingSupported;
#else
public static bool IsMultithreadingSupported => IsNotBrowser && IsNotWasi && !IsEnvironmentVariableTrue("IsBrowserThreadingSupported");
#endif
public static bool IsNotMultithreadingSupported => !IsMultithreadingSupported;

private static readonly Lazy<bool> s_isBinaryFormatterSupported = new Lazy<bool>(DetermineBinaryFormatterSupport);
public static bool IsBinaryFormatterSupported => s_isBinaryFormatterSupported.Value;
Expand Down
3 changes: 3 additions & 0 deletions src/libraries/Common/tests/TestUtilities/TestUtilities.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<!-- For some reason, xunit.core.props isn't excluded in VS and sets this to true. -->
<IsTestProject>false</IsTestProject>
</PropertyGroup>
<PropertyGroup>
<DefineConstants Condition="'$(TargetFramework)' == 'net10.0'">$(DefineConstants);TARGETS_NET10</DefineConstants>
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)ILLink.Substitutions.AggressiveTrimming.xml"
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/Common/tests/Tests/System/StringTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ void Validate(string result)
Validate(string.Concat<string>((IEnumerable<string>)values)); // Call the generic IEnumerable<T>-based overload
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
[OuterLoop] // mini-stress test that likely runs for several seconds
public static void Concat_String_ConcurrencySafe()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public void AddEnvironmentVariablesUsingPrefixWithDoubleUnderscores_Bind_PrefixM
}
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
public void BindingDoesNotThrowIfReloadedDuringBinding()
{
var dic = new Dictionary<string, string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public void DisposesProvidersOnRemoval()
Assert.True(provider5.IsDisposed);
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
public async Task ProviderCanBlockLoadWaitingOnConcurrentRead()
{
using var mre = new ManualResetEventSlim(false);
Expand Down Expand Up @@ -209,7 +209,7 @@ public static TheoryData<Action<IConfiguration>> ConcurrentReadActions
}
}

[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
[MemberData(nameof(ConcurrentReadActions))]
public async Task ProviderDisposeDelayedWaitingOnConcurrentRead(Action<IConfiguration> concurrentReadAction)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ await WaitForChange(
Assert.True(token.HasChanged);
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
public void BindingDoesNotThrowIfReloadedDuringBinding()
{
WriteTestFiles();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ public void CreateCallSite_EnumberableCachedAtLowestLevel(ServiceDescriptor[] de
Assert.Equal(typeof(IEnumerable<FakeService>), callSite.Cache.Key.ServiceIdentifier.ServiceType);
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
public void CallSitesAreUniquePerServiceTypeAndSlot()
{
// Connected graph
Expand Down Expand Up @@ -828,7 +828,7 @@ public void CallSitesAreUniquePerServiceTypeAndSlot()
}
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
public void CallSitesAreUniquePerServiceTypeAndSlotWithOpenGenericInGraph()
{
// Connected graph
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public void GetService_DisposeOnSameThread_Throws()
});
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
public void GetAsyncService_DisposeAsyncOnSameThread_ThrowsAndDoesNotHangAndDisposeAsyncGetsCalled()
{
// Arrange
Expand All @@ -398,7 +398,7 @@ public void GetAsyncService_DisposeAsyncOnSameThread_ThrowsAndDoesNotHangAndDisp
Assert.True(asyncDisposableResource.DisposeAsyncCalled, "!DisposeAsyncCalled");
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
public void GetService_DisposeOnSameThread_ThrowsAndDoesNotHangAndDisposeGetsCalled()
{
// Arrange
Expand Down Expand Up @@ -525,7 +525,7 @@ public InnerSingleton(ManualResetEvent mre1, ManualResetEvent mre2)
}
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
public async Task GetRequiredService_ResolvingSameSingletonInTwoThreads_SameServiceReturned()
{
using (var mreForThread1 = new ManualResetEvent(false))
Expand Down Expand Up @@ -581,7 +581,7 @@ public async Task GetRequiredService_ResolvingSameSingletonInTwoThreads_SameServ
}
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
public async Task GetRequiredService_UsesSingletonAndLazyLocks_NoDeadlock()
{
using (var mreForThread1 = new ManualResetEvent(false))
Expand Down Expand Up @@ -669,7 +669,7 @@ public async Task GetRequiredService_UsesSingletonAndLazyLocks_NoDeadlock()
}
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
public async Task GetRequiredService_BiggerObjectGraphWithOpenGenerics_NoDeadlock()
{
// Test is similar to GetRequiredService_UsesSingletonAndLazyLocks_NoDeadlock (but for open generics and a larger object graph)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ public async Task TokenNotFiredForInvalidPathStartingWithSlash_Windows(string sl
await TokenNotFiredForInvalidPathStartingWithSlash(slashes);
}

[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
[InlineData("/\0/")]
// Testing Unix specific behaviour on leading slashes.
[PlatformSpecific(TestPlatforms.AnyUnix)]
Expand Down
Loading
Loading