From 2b491cce5df657c7e20b8628f656c35678888234 Mon Sep 17 00:00:00 2001 From: Pavlo Kleymonov Date: Wed, 29 Jan 2025 16:43:13 +0100 Subject: [PATCH] add support for QNX 7.1/8.0 --- extras/catch_amalgamated.cpp | 4 +- extras/catch_amalgamated.hpp | 5 ++- src/catch2/internal/catch_console_colour.cpp | 2 +- src/catch2/internal/catch_debugger.cpp | 2 +- src/catch2/internal/catch_debugger.hpp | 2 +- src/catch2/internal/catch_platform.hpp | 3 ++ tests/CMakeLists.txt | 40 +++++++++++++++++ tests/ExtraTests/CMakeLists.txt | 45 +++++++++++++++++++- 8 files changed, 96 insertions(+), 7 deletions(-) diff --git a/extras/catch_amalgamated.cpp b/extras/catch_amalgamated.cpp index c080ad19..3a0c33a5 100644 --- a/extras/catch_amalgamated.cpp +++ b/extras/catch_amalgamated.cpp @@ -3509,7 +3509,7 @@ namespace { #endif // Windows/ ANSI/ None -#if defined( CATCH_PLATFORM_LINUX ) || defined( CATCH_PLATFORM_MAC ) +#if defined( CATCH_PLATFORM_LINUX ) || defined( CATCH_PLATFORM_MAC ) || defined( CATCH_PLATFORM_QNX ) # define CATCH_INTERNAL_HAS_ISATTY # include #endif @@ -3757,7 +3757,7 @@ namespace Catch { #endif } // namespace Catch -#elif defined(CATCH_PLATFORM_LINUX) +#elif defined(CATCH_PLATFORM_LINUX) || defined( CATCH_PLATFORM_QNX ) #include #include diff --git a/extras/catch_amalgamated.hpp b/extras/catch_amalgamated.hpp index 6cc67e76..cf8e4389 100644 --- a/extras/catch_amalgamated.hpp +++ b/extras/catch_amalgamated.hpp @@ -101,6 +101,9 @@ #elif defined(linux) || defined(__linux) || defined(__linux__) # define CATCH_PLATFORM_LINUX +#elif defined(__QNX__) +# define CATCH_PLATFORM_QNX + #elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__) # define CATCH_PLATFORM_WINDOWS @@ -9359,7 +9362,7 @@ namespace Catch { #define CATCH_TRAP() __asm__(".inst 0xde01") #endif -#elif defined(CATCH_PLATFORM_LINUX) +#elif defined(CATCH_PLATFORM_LINUX) || defined(CATCH_PLATFORM_QNX) // If we can use inline assembler, do it because this allows us to break // directly at the location of the failing check instead of breaking inside // raise() called from it, i.e. one stack frame below. diff --git a/src/catch2/internal/catch_console_colour.cpp b/src/catch2/internal/catch_console_colour.cpp index b19e01ec..c339135e 100644 --- a/src/catch2/internal/catch_console_colour.cpp +++ b/src/catch2/internal/catch_console_colour.cpp @@ -161,7 +161,7 @@ namespace { #endif // Windows/ ANSI/ None -#if defined( CATCH_PLATFORM_LINUX ) || defined( CATCH_PLATFORM_MAC ) +#if defined( CATCH_PLATFORM_LINUX ) || defined( CATCH_PLATFORM_MAC ) || defined( CATCH_PLATFORM_QNX ) # define CATCH_INTERNAL_HAS_ISATTY # include #endif diff --git a/src/catch2/internal/catch_debugger.cpp b/src/catch2/internal/catch_debugger.cpp index bd3be172..da22c7fd 100644 --- a/src/catch2/internal/catch_debugger.cpp +++ b/src/catch2/internal/catch_debugger.cpp @@ -69,7 +69,7 @@ #endif } // namespace Catch -#elif defined(CATCH_PLATFORM_LINUX) +#elif defined(CATCH_PLATFORM_LINUX) || defined(CATCH_PLATFORM_QNX) #include #include diff --git a/src/catch2/internal/catch_debugger.hpp b/src/catch2/internal/catch_debugger.hpp index 25c5a260..ef0ddc27 100644 --- a/src/catch2/internal/catch_debugger.hpp +++ b/src/catch2/internal/catch_debugger.hpp @@ -38,7 +38,7 @@ namespace Catch { #define CATCH_TRAP() __asm__(".inst 0xde01") #endif -#elif defined(CATCH_PLATFORM_LINUX) +#elif defined(CATCH_PLATFORM_LINUX) || defined(CATCH_PLATFORM_QNX) // If we can use inline assembler, do it because this allows us to break // directly at the location of the failing check instead of breaking inside // raise() called from it, i.e. one stack frame below. diff --git a/src/catch2/internal/catch_platform.hpp b/src/catch2/internal/catch_platform.hpp index b653a58c..ba4717f0 100644 --- a/src/catch2/internal/catch_platform.hpp +++ b/src/catch2/internal/catch_platform.hpp @@ -25,6 +25,9 @@ #elif defined(linux) || defined(__linux) || defined(__linux__) # define CATCH_PLATFORM_LINUX +#elif defined(__QNX__) +# define CATCH_PLATFORM_QNX + #elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__) # define CATCH_PLATFORM_WINDOWS diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 37a5977e..bc1b65ad 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -681,3 +681,43 @@ endforeach() list(APPEND CATCH_WARNING_TARGETS SelfTest) set(CATCH_WARNING_TARGETS ${CATCH_WARNING_TARGETS} PARENT_SCOPE) + +if (QNX) + #path to tests on target + set(tests_path ${CMAKE_INSTALL_BINDIR}/catch2_tests) + + #list of ut test targets + set(list_tests_targets + Catch2 + Catch2WithMain + SelfTest + ) + + #install tests and libs + install( + TARGETS ${list_tests_targets} + LIBRARY DESTINATION ${tests_path}/lib + RUNTIME DESTINATION ${tests_path} + ) + + #install tests execution script + install( + PROGRAMS ${QNX_TEST_SCRIPT} ${QNX_CTEST_MODULE} ${QNX_DECODE_CTEST_MODULE} + DESTINATION ${tests_path} + ) + + #install SelfTest Misc artifacts + install( + DIRECTORY ${SELF_TEST_DIR}/Misc + DESTINATION ${tests_path} + ) + + #install CTests files + install( + DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DESTINATION ${tests_path} + FILES_MATCHING PATTERN "CTestTestfile.cmake" + PATTERN "CMakeFiles" EXCLUDE + PATTERN "surrogates" EXCLUDE + ) +endif() diff --git a/tests/ExtraTests/CMakeLists.txt b/tests/ExtraTests/CMakeLists.txt index 9f6d8173..805b1c04 100644 --- a/tests/ExtraTests/CMakeLists.txt +++ b/tests/ExtraTests/CMakeLists.txt @@ -110,7 +110,7 @@ foreach(target DisabledExceptions-DefaultHandler DisabledExceptions-CustomHandle target_compile_options( ${target} PUBLIC $<$:/EHs-c-;/D_HAS_EXCEPTIONS=0> - $<$,$,$>:-fno-exceptions> + $<$,$,$,$>:-fno-exceptions> ) target_link_libraries(${target} Catch2_buildall_interface) endforeach() @@ -576,3 +576,46 @@ set_tests_properties( PROPERTIES PASS_REGULAR_EXPRESSION "All tests passed \\(14 assertions in 3 test cases\\)" ) + +if (QNX) + #path to tests on target + set(tests_path ${CMAKE_INSTALL_BINDIR}/catch2_tests) + + set(list_tests_targets ${list_tests_targets} + ListenerStdoutCaptureInMultireporter + AssertionStartingEventGoesBeforeAssertionIsEvaluated + PartialTestCaseEvents + DuplicatedReporters + DuplicatedTestCases-DuplicatedTestCaseMethods + ReportingCrashWithJunitReporter + DuplicatedTestCases-SameNameDifferentTags + CapturedStdoutInTestCaseEvents + AllSkipped + DisabledExceptions-CustomHandler + DisableStringification + DuplicatedTestCases-DifferentFixtures + DisabledMacros + AmalgamatedTestCompilation + BazelReporter + FallbackStringifier + CustomArgumentsForReporters + DisabledExceptions-DefaultHandler + ListenerCanAskForCapturedStdout + BenchmarksInCumulativeReporter + DuplicatedTestCases-SameNameAndTags + ListenersGetEventsBeforeReporters + CasingInReporterNames + NoTests + ReporterPreferencesForPassingAssertionsIsRespected + BazelReporterNoCatchConfig + DeferredStaticChecks + PrefixedMacros + ) + + #install tests and libs + install( + TARGETS ${list_tests_targets} + LIBRARY DESTINATION ${tests_path}/lib + RUNTIME DESTINATION ${tests_path} + ) +endif()