Skip to content

Commit 2608ba2

Browse files
authored
Enable runtime tests on OpenBSD (#129621)
Contributes to #124911.
1 parent b53e2e0 commit 2608ba2

14 files changed

Lines changed: 51 additions & 67 deletions

File tree

‎eng/common/cross/build-rootfs.sh‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ __FreeBSDPackages+=" terminfo-db"
8888
__OpenBSDVersion="7.8"
8989
__OpenBSDPackages="heimdal-libs"
9090
__OpenBSDPackages+=" icu4c"
91-
__OpenBSDPackages+=" inotify-tools"
91+
__OpenBSDPackages+=" libinotify"
9292
__OpenBSDPackages+=" openssl"
93+
__OpenBSDPackages+=" e2fsprogs"
9394

9495
__IllumosPackages="icu"
9596
__IllumosPackages+=" mit-krb5"

‎eng/common/cross/toolchain.cmake‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ elseif(TARGET_ARCH_NAME STREQUAL "arm64")
5959
set(TIZEN_TOOLCHAIN "aarch64-tizen-linux-gnu")
6060
endif()
6161
elseif(FREEBSD)
62-
set(triple "aarch64-unknown-freebsd12")
62+
set(TOOLCHAIN "aarch64-unknown-freebsd14")
6363
elseif(OPENBSD)
64-
set(triple "aarch64-unknown-openbsd")
64+
set(TOOLCHAIN "aarch64-unknown-openbsd")
6565
endif()
6666
elseif(TARGET_ARCH_NAME STREQUAL "armel")
6767
set(CMAKE_SYSTEM_PROCESSOR armv7l)
@@ -117,9 +117,9 @@ elseif(TARGET_ARCH_NAME STREQUAL "x64")
117117
set(TIZEN_TOOLCHAIN "x86_64-tizen-linux-gnu")
118118
endif()
119119
elseif(FREEBSD)
120-
set(triple "x86_64-unknown-freebsd12")
120+
set(TOOLCHAIN "x86_64-unknown-freebsd14")
121121
elseif(OPENBSD)
122-
set(triple "x86_64-unknown-openbsd")
122+
set(TOOLCHAIN "x86_64-unknown-openbsd")
123123
elseif(ILLUMOS)
124124
set(TOOLCHAIN "x86_64-illumos")
125125
elseif(HAIKU)
@@ -160,8 +160,6 @@ if(TIZEN)
160160
find_toolchain_dir("${CROSS_ROOTFS}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}")
161161
endif()
162162

163-
message(STATUS "TIZEN_TOOLCHAIN_PATH set to: ${TIZEN_TOOLCHAIN_PATH}")
164-
165163
include_directories(SYSTEM ${TIZEN_TOOLCHAIN_PATH}/include/c++)
166164
include_directories(SYSTEM ${TIZEN_TOOLCHAIN_PATH}/include/c++/${TIZEN_TOOLCHAIN})
167165
endif()
@@ -206,9 +204,9 @@ if(ANDROID)
206204
include(${CROSS_ROOTFS}/../build/cmake/android.toolchain.cmake)
207205
elseif(FREEBSD OR OPENBSD)
208206
# we cross-compile by instructing clang
209-
set(CMAKE_C_COMPILER_TARGET ${triple})
210-
set(CMAKE_CXX_COMPILER_TARGET ${triple})
211-
set(CMAKE_ASM_COMPILER_TARGET ${triple})
207+
set(CMAKE_C_COMPILER_TARGET ${TOOLCHAIN})
208+
set(CMAKE_CXX_COMPILER_TARGET ${TOOLCHAIN})
209+
set(CMAKE_ASM_COMPILER_TARGET ${TOOLCHAIN})
212210
set(CMAKE_SYSROOT "${CROSS_ROOTFS}")
213211
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld")
214212
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=lld")

‎src/tests/Common/CoreCLRTestLibrary/Utilities.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public static bool Verbose
6868
public static bool IsWindows => OperatingSystem.IsWindows();
6969
public static bool IsLinux => OperatingSystem.IsLinux();
7070
public static bool IsFreeBSD => OperatingSystem.IsFreeBSD();
71+
public static bool IsOpenBSD => OperatingSystem.IsOSPlatform("OpenBSD");
7172
public static bool IsMacOSX => OperatingSystem.IsMacOS();
7273
public static bool IsWindowsNanoServer => (!IsWindowsIoTCore && GetInstallationType().Equals("Nano Server", StringComparison.OrdinalIgnoreCase));
7374

‎src/tests/Common/XUnitWrapperGenerator/ITestInfo.cs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,10 @@ private static string GetPlatformConditionFromTestPlatform(Xunit.TestPlatforms p
270270
{
271271
platformCheckConditions.Add(@"global::System.OperatingSystem.IsFreeBSD()");
272272
}
273+
if (platform.HasFlag(Xunit.TestPlatforms.OpenBSD))
274+
{
275+
platformCheckConditions.Add(@"global::System.OperatingSystem.IsOSPlatform(""OpenBSD"")");
276+
}
273277
if (platform.HasFlag(Xunit.TestPlatforms.NetBSD))
274278
{
275279
platformCheckConditions.Add(@"global::System.OperatingSystem.IsOSPlatform(""NetBSD"")");

‎src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs‎

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,25 @@ namespace Xunit
88
[Flags]
99
public enum TestPlatforms
1010
{
11-
Windows = 1,
12-
Linux = 2,
13-
OSX = 4,
14-
FreeBSD = 8,
15-
NetBSD = 16,
16-
illumos = 32,
17-
Solaris = 64,
18-
iOS = 128,
19-
tvOS = 256,
20-
Android = 512,
21-
Browser = 1024,
22-
MacCatalyst = 2048,
23-
LinuxBionic = 4096,
24-
Wasi = 8192,
25-
Haiku = 16384,
26-
AnyUnix = FreeBSD | Linux | NetBSD | OSX | illumos | Solaris | iOS | tvOS | MacCatalyst | Android | Browser | LinuxBionic | Wasi | Haiku,
11+
Windows = 1 << 0,
12+
Linux = 1 << 1,
13+
OSX = 1 << 2,
14+
FreeBSD = 1 << 3,
15+
NetBSD = 1 << 4,
16+
illumos = 1 << 5,
17+
Solaris = 1 << 6,
18+
iOS = 1 << 7,
19+
tvOS = 1 << 8,
20+
Android = 1 << 9,
21+
Browser = 1 << 10,
22+
MacCatalyst = 1 << 11,
23+
LinuxBionic = 1 << 12,
24+
Wasi = 1 << 13,
25+
Haiku = 1 << 14,
26+
OpenBSD = 1 << 15,
27+
2728
AnyApple = OSX | iOS | tvOS | MacCatalyst,
29+
AnyUnix = AnyApple | Linux | FreeBSD | NetBSD | OpenBSD | illumos | Solaris | Android | Browser | LinuxBionic | Wasi | Haiku,
2830
Any = ~0
2931
}
3032
}

‎src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,7 @@ private static Xunit.TestPlatforms GetPlatformForTargetOS(string? targetOS)
11031103
"browser" => Xunit.TestPlatforms.Browser,
11041104
"wasi" => Xunit.TestPlatforms.Wasi,
11051105
"freebsd" => Xunit.TestPlatforms.FreeBSD,
1106+
"openbsd" => Xunit.TestPlatforms.OpenBSD,
11061107
"netbsd" => Xunit.TestPlatforms.NetBSD,
11071108
null or "" or "anyos" => Xunit.TestPlatforms.Any,
11081109
_ => 0

‎src/tests/Common/scripts/bringup_runtest.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ function run_test {
716716

717717
# Get the number of processors available to the scheduler
718718
platform="$(uname -s | tr '[:upper:]' '[:lower:]')"
719-
if [[ "$platform" == "freebsd" ]]; then
719+
if [[ "$platform" == "freebsd" || "$platform" == "openbsd" ]]; then
720720
NumProc="$(($(sysctl -n hw.ncpu)+1))"
721721
elif [[ "$platform" == "netbsd" || "$platform" == "sunos" ]]; then
722722
NumProc="$(($(getconf NPROCESSORS_ONLN)+1))"

‎src/tests/Common/scripts/run-gc-reliability-framework.sh‎

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,11 @@
11
#!/usr/bin/env bash
22

3-
OSName=$(uname -s | tr '[:upper:]' '[:lower:]')
4-
case $OSName in
5-
darwin)
6-
OS=osx
7-
;;
3+
__RepoRootDir="$(cd "$(dirname "$0")/../../../.." && pwd -P)"
84

9-
freeBSD)
10-
OS=freebsd
11-
;;
5+
. "$__RepoRootDir/eng/common/native/init-os-and-arch.sh"
126

13-
linux)
14-
OS=linux
15-
;;
16-
17-
netbsd)
18-
OS=netbsd
19-
;;
20-
21-
sunos)
22-
OS=sunos
23-
;;
24-
*)
25-
echo "Unsupported OS $OSName detected, configuring as if for Linux"
26-
OS=linux
27-
;;
28-
esac
29-
30-
export CORE_ROOT=`pwd`/artifacts/tests/$OSName.$1.$2/Tests/Core_Root
31-
FRAMEWORK_DIR=`pwd`/artifacts/tests/$OSName.$1.$2/GC/Stress/Framework/ReliabilityFramework
7+
export CORE_ROOT=`pwd`/artifacts/tests/$os.$1.$2/Tests/Core_Root
8+
FRAMEWORK_DIR=`pwd`/artifacts/tests/$os.$1.$2/GC/Stress/Framework/ReliabilityFramework
329
$CORE_ROOT/corerun $FRAMEWORK_DIR/ReliabilityFramework.exe $FRAMEWORK_DIR/testmix_gc.config
3310
EXIT_CODE=$?
3411
if [ $EXIT_CODE -eq 100 ]

‎src/tests/JIT/Directed/StructABI/StructABI.csproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
<ItemGroup>
1212
<Compile Include="StructABI.cs" />
1313
<Compile Include="StructABI.Windows.cs" Condition="'$(TargetOS)' == 'windows'" />
14-
<Compile Include="StructABI.Unix.cs" Condition="'$(TargetOS)' == 'linux' Or '$(TargetOS)' == 'freebsd' Or '$(TargetOS)' == 'netbsd' Or '$(TargetOS)' == 'illumos' Or '$(TargetOS)' == 'solaris' Or '$(TargetOS)' == 'haiku'" />
1514
<Compile Include="StructABI.OSX.cs" Condition="'$(TargetOS)' == 'osx'" />
15+
<Compile Include="StructABI.Unix.cs" Condition="'$(TargetOS)' != 'windows' and '$(TargetOS)' != 'osx'" />
1616
</ItemGroup>
1717
<ItemGroup>
1818
<ProjectReference Include="$(TestLibraryProjectPath)" />

‎src/tests/build.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ fi
397397

398398
# Get the number of processors available to the scheduler
399399
platform="$(uname -s | tr '[:upper:]' '[:lower:]')"
400-
if [[ "$platform" == "freebsd" ]]; then
400+
if [[ "$platform" == "freebsd" || "$platform" == "openbsd" ]]; then
401401
__NumProc="$(($(sysctl -n hw.ncpu)+1))"
402402
elif [[ "$platform" == "netbsd" || "$platform" == "sunos" ]]; then
403403
__NumProc="$(($(getconf NPROCESSORS_ONLN)+1))"

0 commit comments

Comments
 (0)