Skip to content

Commit

Permalink
[browser][MT] enable timer tests (#94217)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelsavara authored Nov 1, 2023
1 parent 872b1fd commit dd72781
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public static bool IsPrivilegedProcess

public static bool IsThreadingSupported => (!IsWasi && !IsBrowser) || IsWasmThreadingSupported;
public static bool IsWasmThreadingSupported => IsBrowser && IsEnvironmentVariableTrue("IsBrowserThreadingSupported");
public static bool IsNotWasmThreadingSupported => !IsWasmThreadingSupported;
public static bool IsBinaryFormatterSupported => IsNotMobile && !IsNativeAot;

public static bool IsStartingProcessesSupported => !IsiOS && !IstvOS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public static IEnumerable<object[]> TestCases()
yield return new object[] { new[] { 800, 600, 400, 200, 100 }, 5, 13, 9 };
}

[Theory]
[MemberData(nameof(TestCases))]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWasmThreadingSupported))] // this test only makes sense with ST TimerQueue
public async Task TestTimers(int[] timeouts, int? expectedSetCounter, int? expectedSetCounterAfterCleanUp, int? expectedHitCount)
{
int wasCalled = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public void Timer_Change_AfterDispose_Test()
}

[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/91545", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
[InlineData(0)]
[InlineData(1)]
[InlineData(2)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public void DisposeAsync_SignalsImmediatelyWhenTaskNotRunning()
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/91545", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public async Task DisposeAsync_DisposeDelayedUntilCallbacksComplete()
{
using (var b = new Barrier(2))
Expand All @@ -73,7 +72,6 @@ public async Task DisposeAsync_DisposeDelayedUntilCallbacksComplete()
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/91545", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public async Task DisposeAsync_MultipleDisposesBeforeCompletionReturnSameTask()
{
using (var b = new Barrier(2))
Expand All @@ -99,7 +97,6 @@ public async Task DisposeAsync_MultipleDisposesBeforeCompletionReturnSameTask()
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/91545", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public async Task DisposeAsync_AfterDisposeWorks()
{
using (var b = new Barrier(2))
Expand All @@ -123,7 +120,6 @@ public async Task DisposeAsync_AfterDisposeWorks()
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/91545", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public async Task DisposeAsync_AfterDisposeWaitHandleThrows()
{
using (var b = new Barrier(2))
Expand All @@ -146,7 +142,6 @@ public async Task DisposeAsync_AfterDisposeWaitHandleThrows()
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/91545", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public async Task DisposeAsync_ThenDisposeWaitHandleReturnsFalse()
{
using (var b = new Barrier(2))
Expand Down
10 changes: 0 additions & 10 deletions src/libraries/System.Threading.Timer/tests/TimerFiringTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public class TimerFiringTests
internal const int MaxPositiveTimeoutInMs = 30000;

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/91545", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void Timer_Fires_After_DueTime_Ellapses()
{
AutoResetEvent are = new AutoResetEvent(false);
Expand All @@ -32,7 +31,6 @@ public void Timer_Fires_After_DueTime_Ellapses()
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/91545", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void Timer_Fires_AndPassesStateThroughCallback()
{
AutoResetEvent are = new AutoResetEvent(false);
Expand All @@ -49,7 +47,6 @@ public void Timer_Fires_AndPassesStateThroughCallback()
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/91545", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void Timer_Fires_AndPassesNullStateThroughCallback()
{
AutoResetEvent are = new AutoResetEvent(false);
Expand Down Expand Up @@ -125,7 +122,6 @@ public void Timer_ChangeToDelete_DoesntFire()
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/91545", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void Timer_CanDisposeSelfInCallback()
{
Timer t = null;
Expand Down Expand Up @@ -153,7 +149,6 @@ public void Timer_CanBeDisposedMultipleTimes()
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/91545", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void NonRepeatingTimer_ThatHasAlreadyFired_CanChangeAndFireAgain()
{
AutoResetEvent are = new AutoResetEvent(false);
Expand All @@ -168,7 +163,6 @@ public void NonRepeatingTimer_ThatHasAlreadyFired_CanChangeAndFireAgain()
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/91545", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void MultpleTimers_PeriodicTimerIsntBlockedByBlockedCallback()
{
int callbacks = 2;
Expand All @@ -189,7 +183,6 @@ public void MultpleTimers_PeriodicTimerIsntBlockedByBlockedCallback()
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/91545", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void ManyTimers_EachTimerDoesFire()
{
int maxTimers = 10000;
Expand All @@ -207,7 +200,6 @@ public void ManyTimers_EachTimerDoesFire()
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/91545", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void Timer_Constructor_CallbackOnly_Change()
{
var e = new ManualResetEvent(false);
Expand All @@ -225,7 +217,6 @@ public void Timer_Dispose_WaitHandle_Negative()
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/91545", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void Timer_Dispose_WaitHandle()
{
int tickCount = 0;
Expand Down Expand Up @@ -371,7 +362,6 @@ orderby groupedByDueTime.Key
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/91545", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public static void TimersCreatedConcurrentlyOnDifferentThreadsAllFire()
{
int processorCount = Environment.ProcessorCount;
Expand Down

0 comments on commit dd72781

Please sign in to comment.