Skip to content

Commit

Permalink
Add test validating against regression in dotnet#46469
Browse files Browse the repository at this point in the history
  • Loading branch information
eiriktsarpalis committed Feb 1, 2021
1 parent 0b23cdb commit e4f2d69
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,25 @@ public void TestProcessRecycledPid()
Assert.True(foundRecycled);
}

[PlatformSpecific(TestPlatforms.AnyUnix)]
[ConditionalTheory(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
[InlineData("/dev/stdin")]
[InlineData("/dev/stdout")]
[InlineData("/dev/stderr")]
public void ChildProcessRedirectedIO_FilePathOpenShouldSucceed(string filename)
{
var options = new RemoteInvokeOptions { StartInfo = new ProcessStartInfo { RedirectStandardOutput = true, RedirectStandardInput = true, RedirectStandardError = true }};
using (RemoteInvokeHandle handle = RemoteExecutor.Invoke(ExecuteChildProcess, filename, options))
{ }

static void ExecuteChildProcess(string filename)
{
int flags = filename == "/dev/stdin" ? /* O_WRONLY */ 1 : /* O_RDONLY */ 0;
int result = open(filename, flags);
Assert.True(result >= 0);
}
}

[ConditionalTheory(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
[InlineData(true)]
[InlineData(false)]
Expand Down Expand Up @@ -941,6 +960,9 @@ private static unsafe HashSet<uint> GetGroups()
[DllImport("libc", SetLastError = true)]
private static extern int kill(int pid, int sig);

[DllImport("libc", SetLastError = true)]
private static extern int open(string pathname, int flags);

private static readonly string[] s_allowedProgramsToRun = new string[] { "xdg-open", "gnome-open", "kfmclient" };

private string WriteScriptFile(string directory, string name, int returnValue)
Expand Down

0 comments on commit e4f2d69

Please sign in to comment.