Fix EndToEnd tests for RHEL.

This commit is contained in:
Sridhar Periyasamy 2016-03-07 20:23:41 -05:00
parent c4cb1f2d53
commit 53fd607584

View file

@ -83,15 +83,8 @@ namespace Microsoft.DotNet.Tests.EndToEnd
[Fact] [Fact]
public void TestDotnetBuildNativeRyuJit() public void TestDotnetBuildNativeRyuJit()
{ {
if(IsCentOSorRHEL()) if(!IsNativeCompilationSupported())
{ {
Console.WriteLine("Skipping native compilation tests on CentOS/RHEL - https://github.com/dotnet/cli/issues/453");
return;
}
if (IsWinX86())
{
Console.WriteLine("Skipping native compilation tests on Windows x86 - https://github.com/dotnet/cli/issues/1550");
return; return;
} }
@ -105,15 +98,8 @@ namespace Microsoft.DotNet.Tests.EndToEnd
[Fact] [Fact]
public void TestDotnetBuildNativeCpp() public void TestDotnetBuildNativeCpp()
{ {
if(IsCentOSorRHEL()) if(!IsNativeCompilationSupported())
{ {
Console.WriteLine("Skipping native compilation tests on CentOS/RHEL - https://github.com/dotnet/cli/issues/453");
return;
}
if (IsWinX86())
{
Console.WriteLine("Skipping native compilation tests on Windows x86 - https://github.com/dotnet/cli/issues/1550");
return; return;
} }
@ -127,15 +113,8 @@ namespace Microsoft.DotNet.Tests.EndToEnd
[Fact] [Fact]
public void TestDotnetCompileNativeCppIncremental() public void TestDotnetCompileNativeCppIncremental()
{ {
if (IsCentOSorRHEL()) if(!IsNativeCompilationSupported())
{ {
Console.WriteLine("Skipping native compilation tests on CentOS/RHEL - https://github.com/dotnet/cli/issues/453");
return;
}
if (IsWinX86())
{
Console.WriteLine("Skipping native compilation tests on Windows x86 - https://github.com/dotnet/cli/issues/1550");
return; return;
} }
@ -236,26 +215,26 @@ namespace Microsoft.DotNet.Tests.EndToEnd
Directory.SetCurrentDirectory(currentDirectory); Directory.SetCurrentDirectory(currentDirectory);
} }
private bool IsCentOSorRHEL() private bool IsNativeCompilationSupported()
{ {
if(RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) bool isSupported = true;
var platform = PlatformServices.Default.Runtime.OperatingSystem.ToLower();
switch (platform)
{ {
const string OSIDFILE = "/etc/os-release"; case "centos":
case "rhel":
if(File.Exists(OSIDFILE)) Console.WriteLine("Skipping native compilation tests on CentOS/RHEL - https://github.com/dotnet/cli/issues/453");
{ isSupported = false;
string osidcontent = File.ReadAllText(OSIDFILE).ToLower(); break;
return osidcontent.Contains("centos") || osidcontent.Contains("rhel"); case "windows":
} Console.WriteLine("Skipping native compilation tests on Windows x86 - https://github.com/dotnet/cli/issues/1550");
isSupported = RuntimeInformation.ProcessArchitecture != Architecture.X86;
break;
default:
break;
} }
return false; return isSupported;
}
private bool IsWinX86()
{
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
RuntimeInformation.ProcessArchitecture == Architecture.X86;
} }
private static DateTime GetLastWriteTimeUtcOfDirectoryFiles(string outputDirectory) private static DateTime GetLastWriteTimeUtcOfDirectoryFiles(string outputDirectory)