{
CreateDefaultProcess();
- AssertNonZeroAllZeroDarwin(_process.PeakWorkingSet64);
+ if (OperatingSystem.IsMacOS())
+ {
+ Assert.Equal(0, _process.PeakWorkingSet64);
+ return;
+ }
+
+ // On recent Linux kernels (6.2+) working set can be zero just after the process started.
+ ExecuteWithRetryOnLinux(() =>
+ {
+ try
+ {
+ Assert.NotEqual(0, _process.PeakWorkingSet64);
+ }
+ catch
+ {
+ _process.Refresh();
+ throw;
+ }
+ });
}
[Fact]
return;
}
- Assert.InRange(_process.WorkingSet64, 1, long.MaxValue);
+ // On recent Linux kernels (6.2+) working set can be zero just after the process started.
+ ExecuteWithRetryOnLinux(() =>
+ {
+ try
+ {
+ Assert.InRange(_process.WorkingSet64, 1, long.MaxValue);
+ }
+ catch
+ {
+ _process.Refresh();
+ throw;
+ }
+ });
}
[Fact]
{
CreateDefaultProcess();
+ if (OperatingSystem.IsMacOS())
+ {
#pragma warning disable 0618
- AssertNonZeroAllZeroDarwin(_process.PeakWorkingSet);
+ Assert.Equal(0, _process.PeakWorkingSet);
#pragma warning restore 0618
+ return;
+ }
+
+ // On recent Linux kernels (6.2+) working set can be zero just after the process started.
+ ExecuteWithRetryOnLinux(() =>
+ {
+ try
+ {
+#pragma warning disable 0618
+ Assert.NotEqual(0, _process.PeakWorkingSet);
+#pragma warning restore 0618
+ }
+ catch
+ {
+ _process.Refresh();
+ throw;
+ }
+ });
}
[Fact]
return;
}
+ // On recent Linux kernels (6.2+) working set can be zero just after the process started.
+ ExecuteWithRetryOnLinux(() =>
+ {
+ try
+ {
#pragma warning disable 0618
- Assert.InRange(_process.WorkingSet, 1, int.MaxValue);
+ Assert.InRange(_process.WorkingSet, 1, int.MaxValue);
#pragma warning restore 0618
+ }
+ catch
+ {
+ _process.Refresh();
+ throw;
+ }
+ });
}
[Fact]
return secureString;
}
+
+ private static void ExecuteWithRetryOnLinux(Action test)
+ {
+ if (OperatingSystem.IsLinux())
+ {
+ RetryHelper.Execute(test, retryWhen: ex => ex is XunitException);
+ }
+ else
+ {
+ test();
+ }
+ }
}
}