Skip to content

Commit 5171b77

Browse files
committed
OpenBSD does not have native backtrace support.
There is libexecinfo as a 3rd-party package, but don't expect it be available for now. This requires removing the -fexeceptions flag on this platform also. While we are doing this, introduce the necessary boilerplate to mark tests as expected failures.
1 parent d274eab commit 5171b77

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

CoreFoundation/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ add_compile_options($<$<COMPILE_LANGUAGE:C>:-fblocks>)
5151
if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")
5252
add_compile_options($<$<COMPILE_LANGUAGE:C>:/EHsc>)
5353
else()
54-
add_compile_options($<$<COMPILE_LANGUAGE:C>:-fexceptions>)
54+
if(NOT CMAKE_SYSTEM_NAME STREQUAL OpenBSD)
55+
add_compile_options($<$<COMPILE_LANGUAGE:C>:-fexceptions>)
56+
endif()
5557
endif()
5658

5759
if(NOT "${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")

Tests/Foundation/Tests/TestThread.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,16 @@ class TestThread : XCTestCase {
160160
("test_currentThread", test_currentThread),
161161
("test_threadStart", test_threadStart),
162162
("test_mainThread", test_mainThread),
163-
("test_callStackSymbols", testExpectedToFailOnAndroid(test_callStackSymbols, "Android doesn't support backtraces at the moment.")),
164-
("test_callStackReturnAddresses", testExpectedToFailOnAndroid(test_callStackReturnAddresses, "Android doesn't support backtraces at the moment.")),
163+
("test_callStackSymbols", testExpectedToFailOnOpenBSD(
164+
testExpectedToFailOnAndroid(
165+
test_callStackSymbols,
166+
"Android doesn't support backtraces at the moment."),
167+
"And not currently on OpenBSD.")),
168+
("test_callStackReturnAddresses", testExpectedToFailOnOpenBSD(
169+
testExpectedToFailOnAndroid(
170+
test_callStackReturnAddresses,
171+
"Android doesn't support backtraces at the moment."),
172+
"And not currently on OpenBSD.")),
165173
("test_sleepForTimeInterval", test_sleepForTimeInterval),
166174
("test_sleepUntilDate", test_sleepUntilDate),
167175
("test_threadName", test_threadName),

Tests/Foundation/Utilities.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,14 @@ func shouldAttemptAndroidXFailTests(_ reason: String) -> Bool {
557557
#endif
558558
}
559559

560+
func shouldAttemptOpenBSDXFailTests(_ reason: String) -> Bool {
561+
#if os(OpenBSD)
562+
return shouldAttemptXFailTests(reason)
563+
#else
564+
return true
565+
#endif
566+
}
567+
560568
#if !DARWIN_COMPATIBILITY_TESTS
561569
func testCaseExpectedToFail<T: XCTestCase>(_ allTests: [(String, (T) -> () throws -> Void)], _ reason: String) -> XCTestCaseEntry {
562570
return testCase(allTests.map { ($0.0, testExpectedToFail($0.1, "This test suite is disabled: \(reason)")) })
@@ -581,6 +589,10 @@ func testExpectedToFailOnAndroid<T>(_ test: @escaping (T) -> () throws -> Void,
581589
testExpectedToFailWithCheck(check: shouldAttemptAndroidXFailTests(_:), test, reason)
582590
}
583591

592+
func testExpectedToFailOnOpenBSD<T>(_ test: @escaping (T) -> () throws -> Void, _ reason: String) -> (T) -> () throws -> Void {
593+
testExpectedToFailWithCheck(check: shouldAttemptOpenBSDXFailTests(_:), test, reason)
594+
}
595+
584596
func testExpectedToFailWithCheck<T>(check: (String) -> Bool, _ test: @escaping (T) -> () throws -> Void, _ reason: String) -> (T) -> () throws -> Void {
585597
if check(reason) {
586598
return test

0 commit comments

Comments
 (0)