Skip to content

Commit

Permalink
check if Server Service is running for tests that use file sharing
Browse files Browse the repository at this point in the history
  • Loading branch information
adamsitnik authored and github-actions committed Jun 25, 2021
1 parent 1a4c35f commit 19d9ee5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
using Microsoft.Win32.SafeHandles;
using System.ComponentModel;
using System.IO.Pipes;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.ServiceProcess;
using System.Threading.Tasks;
using Xunit;

Expand Down Expand Up @@ -76,9 +78,26 @@ protected override string GetTestFilePath(int? index = null, [CallerMemberName]
[PlatformSpecific(TestPlatforms.Windows)] // the test setup is Windows-specifc
[Collection("NoParallelTests")] // don't run in parallel, as file sharing logic is not thread-safe
[OuterLoop("Requires admin privileges to create a file share")]
[ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsAdmin_IsNotNano))]
[ConditionalClass(typeof(UncFilePathFileStreamStandaloneConformanceTests), nameof(UncFilePathFileStreamStandaloneConformanceTests.CanShareFiles))]
public class UncFilePathFileStreamStandaloneConformanceTests : UnbufferedAsyncFileStreamStandaloneConformanceTests
{
public static bool CanShareFiles
{
get
{
if (!PlatformDetection.IsAdmin_IsNotNano)
{
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"))
{
return sharingService.Status == ServiceControllerStatus.Running;
}
}
}

protected override string GetTestFilePath(int? index = null, [CallerMemberName] string memberName = null, [CallerLineNumber] int lineNumber = 0)
{
string testDirectoryPath = Path.GetFullPath(TestDirectory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.GetFileInformationByHandleEx.cs" Link="Common\Interop\Windows\Interop.GetFileInformationByHandleEx.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.MemOptions.cs" Link="Common\Interop\Windows\Interop.MemOptions.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.VirtualAlloc_Ptr.cs" Link="Common\Interop\Windows\Interop.VirtualAlloc_Ptr.cs" />
<ProjectReference Include="$(LibrariesProjectRoot)System.ServiceProcess.ServiceController\src\System.ServiceProcess.ServiceController.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsBrowser)' == 'true'">
<Compile Remove="..\**\*.Unix.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.GetFileInformationByHandleEx.cs" Link="Common\Interop\Windows\Interop.GetFileInformationByHandleEx.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.MemOptions.cs" Link="Common\Interop\Windows\Interop.MemOptions.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.VirtualAlloc_Ptr.cs" Link="Common\Interop\Windows\Interop.VirtualAlloc_Ptr.cs" />
<ProjectReference Include="$(LibrariesProjectRoot)System.ServiceProcess.ServiceController\src\System.ServiceProcess.ServiceController.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsBrowser)' == 'true'">
<Compile Include="FileSystemTest.Browser.cs" />
Expand Down

0 comments on commit 19d9ee5

Please sign in to comment.