Cleanup NonWindowsGetDomainName() (#6948)

Add an optional extended description…
This commit is contained in:
Ilya
2018-05-31 10:18:33 +05:00
committed by GitHub
parent 115d0715dc
commit c297eac50e
2 changed files with 0 additions and 39 deletions
@@ -545,22 +545,6 @@ namespace System.Management.Automation
return Unix.NativeMethods.SetDate(&tm) == 0;
}
internal static string NonWindowsGetDomainName()
{
string name = Unix.NativeMethods.GetFullyQualifiedName();
if (!string.IsNullOrEmpty(name))
{
// name is hostname.domainname, so extract domainname
int index = name.IndexOf('.');
if (index >= 0)
{
return name.Substring(index + 1);
}
}
// if the domain name could not be found, do not throw, just return empty
return string.Empty;
}
// Hostname in this context seems to be the FQDN
internal static string NonWindowsGetHostName()
{
-23
View File
@@ -86,29 +86,6 @@ namespace PSTests.Parallel
}
}
[Fact]
public static void TestGetDomainName()
{
var startInfo = new ProcessStartInfo
{
FileName = @"/usr/bin/env",
Arguments = "dnsdomainname",
RedirectStandardOutput = true,
UseShellExecute = false
};
using (Process process = Process.Start(startInfo))
{
// Get output of call to hostname without trailing newline
string domainName = 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(domainName, Platform.NonWindowsGetDomainName());
}
}
[Fact]
public static void TestIsExecutable()
{