Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

xplat: Adds FreeBSD support #180

Merged
merged 3 commits into from Jun 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions dir.props
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,29 @@
<ConfigurationGroup Condition="$(Configuration.EndsWith('Release'))">Release</ConfigurationGroup>
<ConfigurationGroup Condition="'$(ConfigurationGroup)'==''">$(Configuration)</ConfigurationGroup>

<OS Condition="$(Configuration.StartsWith('Windows'))">Windows_NT</OS>
<OS Condition="$(Configuration.StartsWith('Unix'))">Unix</OS>
<!-- TODO: Determine actual settings once we have Linux vs Mac specialization -->
<OS Condition="$(Configuration.StartsWith('FreeBSD'))">Unix</OS>
<OS Condition="$(Configuration.StartsWith('Linux'))">Unix</OS>
<OS Condition="$(Configuration.StartsWith('Mac'))">Unix</OS>
<OS Condition="$(Configuration.StartsWith('Windows'))">Windows_NT</OS>
<OS Condition="$(Configuration.StartsWith('Unix'))">Unix</OS>

<OSGroup Condition="'$(OSGroup)'==''">$(OS)</OSGroup>
</PropertyGroup>

<PropertyGroup Condition="'$(OS)'=='Unix'">
<!--
PDB support isn't implemented yet. https://github.com/dotnet/roslyn/issues/2449
Note that both DebugSymbols and DebugType need set or project references will assume they need to copy pdbs and fail.
-->
<DebugSymbols>false</DebugSymbols>
<DebugType>none</DebugType>
<!--
Delay signing with the ECMA key currently doesn't work.
https://github.com/dotnet/roslyn/issues/2444
-->
<UseECMAKey>false</UseECMAKey>
</PropertyGroup>

<!-- Setup Default symbol and optimization for Configuration -->
<PropertyGroup Condition="'$(ConfigurationGroup)' == 'Debug'">
<DebugSymbols Condition="'$(DebugSymbols)' == ''">true</DebugSymbols>
Expand Down
4 changes: 2 additions & 2 deletions src/EventTracer/EventTracer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.XML" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CollectTraceEventsHelper.cs" />
Expand All @@ -49,4 +49,4 @@
</ProjectReference>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<HintPath>..\..\packages\System.Reflection.Metadata.1.0.17-beta\lib\portable-net45+win8\System.Reflection.Metadata.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Forms" />
<Reference Include="System.XML" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
Expand All @@ -95,4 +95,4 @@
<Copy SourceFiles="@(NativeBinariesx86)" DestinationFolder="$(OutputPath)NativeBinaries\x86" SkipUnchangedFiles="true" />
<Copy SourceFiles="@(NativeBinariesamd64)" DestinationFolder="$(OutputPath)NativeBinaries\amd64" SkipUnchangedFiles="true" />
</Target>
</Project>
</Project>
1 change: 1 addition & 0 deletions src/PerfEventsData/Platform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace PerfEventsData
/// </summary>
public enum Platform
{
FreeBSD,
Linux,
Mac,
Windows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitA

string issue = ctorArgs.First().ToString();
PlatformID platforms = (PlatformID)ctorArgs.Last();
if ((platforms.HasFlag(PlatformID.Windows) && Interop.IsWindows) ||
if ((platforms.HasFlag(PlatformID.FreeBSD) && Interop.IsFreeBSD) ||
(platforms.HasFlag(PlatformID.Linux) && Interop.IsLinux) ||
(platforms.HasFlag(PlatformID.OSX) && Interop.IsOSX))
(platforms.HasFlag(PlatformID.OSX) && Interop.IsOSX) ||
(platforms.HasFlag(PlatformID.Windows) && Interop.IsWindows))
{
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.Failing);
yield return new KeyValuePair<string, string>(XunitConstants.ActiveIssue, issue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitA
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonLinuxTest);
if (!platform.HasFlag(PlatformID.OSX))
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonOSXTest);
if (!platform.HasFlag(PlatformID.FreeBSD))
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonFreeBSDTest);
}
}
}
24 changes: 17 additions & 7 deletions src/xunit.netcore.extensions/Interop.PlatformDetection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ internal static partial class Interop
{
internal enum OperatingSystem
{
Windows,
FreeBSD,
Linux,
OSX
OSX,
Windows
}

internal static bool IsWindows
internal static bool IsFreeBSD
{
get { return OperatingSystem.Windows == PlatformDetection.OperatingSystem; }
get { return OperatingSystem.FreeBSD == PlatformDetection.OperatingSystem; }

This comment was marked as spam.

This comment was marked as spam.

}

internal static bool IsLinux
Expand All @@ -31,6 +32,11 @@ internal static bool IsOSX
get { return OperatingSystem.OSX == PlatformDetection.OperatingSystem; }
}

internal static bool IsWindows
{
get { return OperatingSystem.Windows == PlatformDetection.OperatingSystem; }
}

internal static class PlatformDetection
{
internal static OperatingSystem OperatingSystem { get { return s_os.Value; } }
Expand All @@ -44,9 +50,13 @@ internal static class PlatformDetection
byte* buffer = stackalloc byte[8192]; // the size use with uname is platform specific; this should be large enough for any OS
if (uname(buffer) == 0)
{
return Marshal.PtrToStringAnsi((IntPtr)buffer) == "Darwin" ?
OperatingSystem.OSX :
OperatingSystem.Linux;
string os = Marshal.PtrToStringAnsi((IntPtr)buffer);
if (os == "FreeBSD")
return OperatingSystem.FreeBSD;
else if (os == "Darwin")
return OperatingSystem.OSX;
else
return OperatingSystem.Linux;
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/xunit.netcore.extensions/PlatformID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public enum PlatformID
Windows = 1,
Linux = 2,
OSX = 4,
AnyUnix = Linux | OSX,
Any = Windows | Linux | OSX
FreeBSD = 8,
AnyUnix = FreeBSD | Linux | OSX,
Any = ~0
}
}
3 changes: 2 additions & 1 deletion src/xunit.netcore.extensions/XunitConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ namespace Xunit.NetCore.Extensions
{
internal struct XunitConstants
{
public const string NonWindowsTest = "nonwindowstests";
public const string NonFreeBSDTest = "nonfreebsdtests";
public const string NonLinuxTest = "nonlinuxtests";
public const string NonOSXTest = "nonosxtests";
public const string NonWindowsTest = "nonwindowstests";
public const string Category = "category";
public const string Failing = "failing";
public const string ActiveIssue = "activeissue";
Expand Down