forked from microsoft/vstest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add platform abstraction for OS name and architecture.
Related microsoft#820 microsoft#679
- Loading branch information
Arun Mahapatra
committed
Jun 12, 2017
1 parent
d66ac59
commit 9013447
Showing
12 changed files
with
186 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/IEnvironment.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions | ||
{ | ||
using System; | ||
|
||
/// <summary> | ||
/// Operating system environment abstractions. | ||
/// </summary> | ||
public interface IEnvironment | ||
{ | ||
/// <summary> | ||
/// Operating System architecture. | ||
/// </summary> | ||
PlatformArchitecture Architecture { get; } | ||
|
||
/// <summary> | ||
/// Operating System name. | ||
/// </summary> | ||
PlatformOperatingSystem OperatingSystem { get; } | ||
} | ||
} |
File renamed without changes.
18 changes: 18 additions & 0 deletions
18
src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/PlatformArchitecture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions | ||
{ | ||
using System; | ||
|
||
/// <summary> | ||
/// Available architectures for test platform. | ||
/// </summary> | ||
public enum PlatformArchitecture | ||
{ | ||
X86, | ||
X64, | ||
ARM, | ||
ARM64 | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/PlatformOperationSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions | ||
{ | ||
using System; | ||
|
||
/// <summary> | ||
/// Available operating systems. | ||
/// </summary> | ||
public enum PlatformOperatingSystem | ||
{ | ||
Windows, | ||
Unix | ||
} | ||
} |
Binary file modified
BIN
+322 Bytes
(110%)
...soft.TestPlatform.PlatformAbstractions/Microsoft.TestPlatform.PlatformAbstractions.csproj
Binary file not shown.
File renamed without changes.
42 changes: 42 additions & 0 deletions
42
src/Microsoft.TestPlatform.PlatformAbstractions/net46/System/PlatformEnvironment.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions | ||
{ | ||
using System; | ||
|
||
/// <inheritdoc /> | ||
public class PlatformEnvironment : IEnvironment | ||
{ | ||
/// <inheritdoc /> | ||
public PlatformArchitecture Architecture | ||
{ | ||
get | ||
{ | ||
// On Mono System.Runtime.InteropServices.RuntimeInformation breaks | ||
// See https://github.com/dotnet/corefx/issues/15112 | ||
// Support just x86 and x64 for now, likely our solution for ARM is going to be | ||
// netcore based. | ||
return Environment.Is64BitOperatingSystem ? PlatformArchitecture.X64 : PlatformArchitecture.X86; | ||
} | ||
} | ||
|
||
/// <inheritdoc /> | ||
public PlatformOperatingSystem OperatingSystem | ||
{ | ||
get | ||
{ | ||
// Ensure the value is detected appropriately for Desktop CLR, Mono CLR 1.x and Mono | ||
// CLR 2.x. See below link for more information: | ||
// http://www.mono-project.com/docs/faq/technical/#how-to-detect-the-execution-platform | ||
int p = (int) System.Environment.OSVersion.Platform; | ||
if ((p == 4) || (p == 6) || (p == 128)) | ||
{ | ||
return PlatformOperatingSystem.Unix; | ||
} | ||
|
||
return PlatformOperatingSystem.Windows; | ||
} | ||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/Microsoft.TestPlatform.PlatformAbstractions/netcore/System/PlatformEnvironment.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions | ||
{ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
/// <inheritdoc /> | ||
public class PlatformEnvironment : IEnvironment | ||
{ | ||
/// <inheritdoc /> | ||
public PlatformArchitecture Architecture | ||
{ | ||
get | ||
{ | ||
switch (RuntimeInformation.OSArchitecture) | ||
{ | ||
case System.Runtime.InteropServices.Architecture.X86: | ||
return PlatformArchitecture.X86; | ||
case System.Runtime.InteropServices.Architecture.X64: | ||
return PlatformArchitecture.X64; | ||
case System.Runtime.InteropServices.Architecture.Arm: | ||
return PlatformArchitecture.ARM; | ||
case System.Runtime.InteropServices.Architecture.Arm64: | ||
return PlatformArchitecture.ARM64; | ||
default: | ||
throw new NotSupportedException(); | ||
} | ||
} | ||
} | ||
|
||
/// <inheritdoc /> | ||
public PlatformOperatingSystem OperatingSystem | ||
{ | ||
get | ||
{ | ||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | ||
{ | ||
return PlatformOperatingSystem.Windows; | ||
} | ||
|
||
return PlatformOperatingSystem.Unix; | ||
} | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/Microsoft.TestPlatform.PlatformAbstractions/netstandard1.0/System/PlatformEnvironment.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions | ||
{ | ||
using System; | ||
|
||
/// <inheritdoc /> | ||
public class PlatformEnvironment : IEnvironment | ||
{ | ||
/// <inheritdoc /> | ||
public PlatformArchitecture Architecture | ||
{ | ||
get | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
|
||
/// <inheritdoc /> | ||
public PlatformOperatingSystem OperatingSystem | ||
{ | ||
get | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.