diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index a1648c1da6d8b2..7e352915ac39e3 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -43,6 +43,7 @@ public static partial class PlatformDetection public static bool IsNotCoreClrInterpreter => !IsCoreClrInterpreter; public static bool IsFreeBSD => RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD")); public static bool IsNetBSD => RuntimeInformation.IsOSPlatform(OSPlatform.Create("NETBSD")); + public static bool IsOpenBSD => RuntimeInformation.IsOSPlatform(OSPlatform.Create("OPENBSD")); public static bool IsAndroid => RuntimeInformation.IsOSPlatform(OSPlatform.Create("ANDROID")); public static bool IsNotAndroid => !IsAndroid; public static bool IsAndroidX86 => IsAndroid && IsX86Process; @@ -64,7 +65,7 @@ public static partial class PlatformDetection public static bool IsAppleMobile => IsMacCatalyst || IsiOS || IstvOS; public static bool IsNotAppleMobile => !IsAppleMobile; public static bool IsNotNetFramework => !IsNetFramework; - public static bool IsBsdLike => IsApplePlatform || IsFreeBSD || IsNetBSD; + public static bool IsBsdLike => IsApplePlatform || IsFreeBSD || IsNetBSD || IsOpenBSD; public static bool IsArmProcess => RuntimeInformation.ProcessArchitecture == Architecture.Arm; public static bool IsNotArmProcess => !IsArmProcess; diff --git a/src/libraries/System.IO.FileSystem.Watcher/src/System.IO.FileSystem.Watcher.csproj b/src/libraries/System.IO.FileSystem.Watcher/src/System.IO.FileSystem.Watcher.csproj index c8fd0e835ddbbe..71b0bcd53fd14f 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/src/System.IO.FileSystem.Watcher.csproj +++ b/src/libraries/System.IO.FileSystem.Watcher/src/System.IO.FileSystem.Watcher.csproj @@ -1,7 +1,7 @@  - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-linux;$(NetCoreAppCurrent)-osx;$(NetCoreAppCurrent)-maccatalyst;$(NetCoreAppCurrent)-freebsd;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-linux;$(NetCoreAppCurrent)-osx;$(NetCoreAppCurrent)-maccatalyst;$(NetCoreAppCurrent)-freebsd;$(NetCoreAppCurrent)-openbsd;$(NetCoreAppCurrent) true false @@ -77,7 +77,7 @@ Link="Common\Interop\Unix\Interop.PathConf.cs" /> - + diff --git a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.Directory.Move.cs b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.Directory.Move.cs index 7c3d9415d1b8b3..466a9e97ad5bb1 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.Directory.Move.cs +++ b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.Directory.Move.cs @@ -53,7 +53,7 @@ public void Directory_Move_Multiple_From_Watched_To_Unwatched(int filesCount) } [Theory] - [SkipOnPlatform(TestPlatforms.FreeBSD, "Not supported on FreeBSD.")] + [SkipOnPlatform(TestPlatforms.FreeBSD | TestPlatforms.OpenBSD, "Not supported on FreeBSD and OpenBSD.")] [InlineData(1)] [InlineData(2)] [InlineData(3)] diff --git a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.File.Move.cs b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.File.Move.cs index 7c7bbfc5529e29..848d95d0741a56 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.File.Move.cs +++ b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.File.Move.cs @@ -58,6 +58,7 @@ public void File_Move_Multiple_From_Watched_To_Unwatched(int filesCount) } [Theory] + [SkipOnPlatform(TestPlatforms.OpenBSD, "libinotify on OpenBSD does not preserve event ordering.")] [InlineData(1)] [InlineData(2)] [InlineData(3)] diff --git a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.cs b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.cs index cde4fff57c5966..2e92932211a032 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.cs +++ b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.cs @@ -171,6 +171,7 @@ public void BeginInit_PausesEnableRaisingEvents() [Theory] [InlineData(true)] [InlineData(false)] + [SkipOnPlatform(TestPlatforms.OpenBSD, "libinotify on OpenBSD can lose the Created event for a file that is created and immediately deleted on a freshly-started watch.")] public void EndInit_ResumesPausedEnableRaisingEvents(bool setBeforeBeginInit) { FileSystemWatcherTest.Execute(() => diff --git a/src/libraries/System.IO.FileSystem.Watcher/tests/System.IO.FileSystem.Watcher.Tests.csproj b/src/libraries/System.IO.FileSystem.Watcher/tests/System.IO.FileSystem.Watcher.Tests.csproj index 1e43fca4491b34..e69c3da9b186d8 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/tests/System.IO.FileSystem.Watcher.Tests.csproj +++ b/src/libraries/System.IO.FileSystem.Watcher/tests/System.IO.FileSystem.Watcher.Tests.csproj @@ -2,7 +2,7 @@ true true - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-linux;$(NetCoreAppCurrent)-osx;$(NetCoreAppCurrent)-maccatalyst;$(NetCoreAppCurrent)-freebsd + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-linux;$(NetCoreAppCurrent)-osx;$(NetCoreAppCurrent)-maccatalyst;$(NetCoreAppCurrent)-freebsd;$(NetCoreAppCurrent)-openbsd true diff --git a/src/native/libs/System.Native/extra_libs.cmake b/src/native/libs/System.Native/extra_libs.cmake index b9d18b61a429bc..29f32ce928e403 100644 --- a/src/native/libs/System.Native/extra_libs.cmake +++ b/src/native/libs/System.Native/extra_libs.cmake @@ -8,6 +8,8 @@ macro(append_extra_system_libs NativeLibsExtra) list(APPEND ${NativeLibsExtra} ${INOTIFY_LIBRARY}) elseif (CLR_CMAKE_TARGET_OPENBSD) list(APPEND ${NativeLibsExtra} pthread) + find_library(INOTIFY_LIBRARY inotify HINTS ${CROSS_ROOTFS}/usr/local/lib/inotify) + list(APPEND ${NativeLibsExtra} ${INOTIFY_LIBRARY}) elseif (CLR_CMAKE_TARGET_SUNOS) list(APPEND ${NativeLibsExtra} socket nsl) elseif (CLR_CMAKE_TARGET_HAIKU) diff --git a/src/native/libs/configure.cmake b/src/native/libs/configure.cmake index 4dcb1409f99233..03d10f36842c12 100644 --- a/src/native/libs/configure.cmake +++ b/src/native/libs/configure.cmake @@ -22,8 +22,8 @@ elseif (CLR_CMAKE_TARGET_FREEBSD) include_directories(SYSTEM ${CROSS_ROOTFS}/usr/local/include) set(CMAKE_REQUIRED_INCLUDES ${CROSS_ROOTFS}/usr/local/include) elseif (CLR_CMAKE_TARGET_OPENBSD) - include_directories(SYSTEM ${CROSS_ROOTFS}/usr/local/include ${CROSS_ROOTFS}/usr/local/heimdal/include) - set(CMAKE_REQUIRED_INCLUDES ${CROSS_ROOTFS}/usr/local/include ${CROSS_ROOTFS}/usr/local/heimdal/include) + include_directories(SYSTEM ${CROSS_ROOTFS}/usr/local/include ${CROSS_ROOTFS}/usr/local/heimdal/include ${CROSS_ROOTFS}/usr/local/include/inotify) + set(CMAKE_REQUIRED_INCLUDES ${CROSS_ROOTFS}/usr/local/include ${CROSS_ROOTFS}/usr/local/heimdal/include ${CROSS_ROOTFS}/usr/local/include/inotify) elseif (CLR_CMAKE_TARGET_SUNOS) # requires /opt/tools when building in Global Zone (GZ) include_directories(SYSTEM /opt/local/include /opt/tools/include) @@ -1052,8 +1052,10 @@ endif() set (CMAKE_REQUIRED_LIBRARIES ${PREVIOUS_CMAKE_REQUIRED_LIBRARIES}) set (PREVIOUS_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) -if (HAVE_SYS_INOTIFY_H AND (CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_OPENBSD)) +if (HAVE_SYS_INOTIFY_H AND CLR_CMAKE_TARGET_FREEBSD) set (CMAKE_REQUIRED_LIBRARIES "-linotify -L${CROSS_ROOTFS}/usr/local/lib") +elseif (HAVE_SYS_INOTIFY_H AND CLR_CMAKE_TARGET_OPENBSD) + set (CMAKE_REQUIRED_LIBRARIES "-linotify -lpthread -L${CROSS_ROOTFS}/usr/local/lib/inotify") endif() check_symbol_exists(