From e49b28d3f6ba0fc8e61c60ec68a11fe0d7bd154f Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Sat, 24 Sep 2022 21:44:37 -0700 Subject: [PATCH 1/2] Enable System.IO.FileSystem tests for native aot Suppress file sharing tests on machines that do not have file sharing service installed. --- .../FileStreamConformanceTests.Windows.cs | 17 +++++++++++++---- src/libraries/tests.proj | 2 -- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/FileStreamConformanceTests.Windows.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/FileStreamConformanceTests.Windows.cs index 8061eb6bd16c44..5b0fefd8f75f26 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/FileStreamConformanceTests.Windows.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/FileStreamConformanceTests.Windows.cs @@ -85,15 +85,24 @@ public class UncFilePathFileStreamStandaloneConformanceTests : UnbufferedAsyncFi private static Lazy _canShareFiles = new Lazy(() => { - if (!PlatformDetection.IsWindowsAndElevated || PlatformDetection.IsWindowsNanoServer) + if (!PlatformDetection.IsWindowsAndElevated) { return false; } - // the "Server Service" allows for file sharing. It can be disabled on some of our CI machines. - using (ServiceController sharingService = new ServiceController("Server")) + try + { + // the "Server Service" allows for file sharing. It can be disabled on some machines. + using (ServiceController sharingService = new ServiceController("Server")) + { + Console.WriteLine(sharingService.Status == ServiceControllerStatus.Running); + return sharingService.Status == ServiceControllerStatus.Running; + } + } + catch (InvalidOperationException) { - return sharingService.Status == ServiceControllerStatus.Running; + // The service is not installed. + return false; } }); diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index 7e2fcb98bc99a1..bd4f28434bc479 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -485,8 +485,6 @@ - - From d547c6f43de0349a39bb132fca0938fd65ba552b Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Sun, 25 Sep 2022 13:23:32 -0700 Subject: [PATCH 2/2] Update src/libraries/System.IO.FileSystem/tests/FileStream/FileStreamConformanceTests.Windows.cs --- .../tests/FileStream/FileStreamConformanceTests.Windows.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/FileStreamConformanceTests.Windows.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/FileStreamConformanceTests.Windows.cs index 5b0fefd8f75f26..c3fea537d8c349 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/FileStreamConformanceTests.Windows.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/FileStreamConformanceTests.Windows.cs @@ -95,7 +95,6 @@ public class UncFilePathFileStreamStandaloneConformanceTests : UnbufferedAsyncFi // the "Server Service" allows for file sharing. It can be disabled on some machines. using (ServiceController sharingService = new ServiceController("Server")) { - Console.WriteLine(sharingService.Status == ServiceControllerStatus.Running); return sharingService.Status == ServiceControllerStatus.Running; } }