diff --git a/src/ps_test/test_CorePsPlatform.cs b/src/ps_test/test_CorePsPlatform.cs index 65c2e8ce19..c408c68da1 100644 --- a/src/ps_test/test_CorePsPlatform.cs +++ b/src/ps_test/test_CorePsPlatform.cs @@ -90,6 +90,31 @@ namespace PSTests } + } + + [Fact] + public static void TestGetFQDN() + { + var startInfo = new ProcessStartInfo + { + FileName = @"/usr/bin/env", + Arguments = "hostname --fqdn", + RedirectStandardOutput = true, + UseShellExecute = false + }; + using (Process process = Process.Start(startInfo)) + { + // Get output of call to hostname without trailing newline + string hostname = process.StandardOutput.ReadToEnd().Trim(); + process.WaitForExit(); + + // The process should return an exit code of 0 on success + Assert.Equal(0, process.ExitCode); + // It should be the same as what our platform code returns + Assert.Equal(hostname, Platform.NonWindowsGetHostName()); + } + + } [Fact] @@ -181,6 +206,47 @@ namespace PSTests Assert.False(Platform.NonWindowsIsHardLink(fd)); } + [Fact] + public static void TestFileIsSymLink() + { + string path = @"/tmp/originallink"; + if (File.Exists(path)) + { + File.Delete(path); + } + + File.Create(path); + + string link = "/tmp/newlink"; + + if (File.Exists(link)) + { + File.Delete(link); + } + + var startInfo = new ProcessStartInfo + { + FileName = @"/usr/bin/env", + Arguments = "ln -s " + path + " " + link, + RedirectStandardOutput = true, + UseShellExecute = false + }; + + using (Process process = Process.Start(startInfo)) + { + process.WaitForExit(); + Assert.Equal(0, process.ExitCode); + } + + FileSystemInfo fd = new FileInfo(path); + Assert.False(Platform.NonWindowsIsSymLink(fd)); + + fd = new FileInfo(link); + Assert.True(Platform.NonWindowsIsSymLink(fd)); + + File.Delete(path); + File.Delete(link); + } [Fact] public static void TestCommandLineArgvReturnsAnElement()