Skip to content

Commit

Permalink
Try Fix Cpu Usage Test (#105891)
Browse files Browse the repository at this point in the history
* Try Fix Cpu Usage Test

* fix tvos case
  • Loading branch information
tarekgh authored Aug 7, 2024
1 parent 87e9c5f commit 51e99e1
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -584,14 +584,14 @@ public void TestCpuUsage()
if (usage.UserTime == TimeSpan.Zero)
{
// Environment should return 0 for all values
Assert.Equal(TimeSpan.Zero, usage.PrivilegedTime);
Assert.Equal(TimeSpan.Zero, usage.TotalTime);
Assert.True(usage.PrivilegedTime == TimeSpan.Zero, $"Unexpected privileged time: {usage.PrivilegedTime} while having user time: {usage.UserTime}");
Assert.True(usage.TotalTime == TimeSpan.Zero, $"Unexpected Zero Total while having privileged time: {usage.PrivilegedTime} and user time: {usage.UserTime}");
}
else
{
// Mobile platforms emulators may return non-zero values
Assert.NotEqual(TimeSpan.Zero, usage.PrivilegedTime);
Assert.Equal(usage.TotalTime, usage.UserTime + usage.PrivilegedTime);
// Mobile platforms emulators may return non-zero values. tvOS is possible returning Zero privileged time though.
Assert.True(PlatformDetection.IstvOS || TimeSpan.Zero != usage.PrivilegedTime, $"Unexpected Zero privileged time while having user time: {usage.UserTime}");
Assert.True(usage.TotalTime == usage.UserTime + usage.PrivilegedTime, $"Unexpected Total time: {usage.TotalTime} while having privileged time: {usage.PrivilegedTime} and user time: {usage.UserTime}");
}
}
else
Expand Down

0 comments on commit 51e99e1

Please sign in to comment.