diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index 119ef243..24f8ef6f 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -1,2 +1,5 @@ add_subdirectory(internal) -add_subdirectory(tests) \ No newline at end of file + +if(LINK_CATCH2) + add_subdirectory(tests) +endif() \ No newline at end of file diff --git a/unittest/internal/UnittDefinitions.cpp b/unittest/internal/UnittDefinitions.cpp index 517f561a..ed4b59c1 100644 --- a/unittest/internal/UnittDefinitions.cpp +++ b/unittest/internal/UnittDefinitions.cpp @@ -5,7 +5,7 @@ sif::error << "Unit Tester error: Failed at test ID " << errorId << std::endl; #else - sif::printError("Unit Tester error: Failed at test ID 0x%08x", errorId); + sif::printError("Unit Tester error: Failed at test ID %s\n", errorId.c_str()); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ return HasReturnvaluesIF::RETURN_FAILED; } diff --git a/unittest/internal/osal/IntTestMutex.cpp b/unittest/internal/osal/IntTestMutex.cpp index 2a1584b8..13d87a8b 100644 --- a/unittest/internal/osal/IntTestMutex.cpp +++ b/unittest/internal/osal/IntTestMutex.cpp @@ -3,8 +3,8 @@ #include #include -#if defined(hosted) -#include +#if defined(WIN32) || defined(UNIX) +#include #include #include #endif @@ -19,10 +19,11 @@ void testmutex::testMutex() { } // timed_mutex from the C++ library specifies undefined behaviour if // the timed mutex is locked twice from the same thread. -#if defined(hosted) + // TODO: we should pass a define like FSFW_OSAL_HOST to the build. +#if defined(WIN32) || defined(UNIX) // This calls the function from // another thread and stores the returnvalue in a future. - auto future = std::async(&MutexIF::lockMutex, mutex, 1); + auto future = std::async(&MutexIF::lockMutex, mutex, MutexIF::TimeoutType::WAITING, 1); result = future.get(); #else result = mutex->lockMutex(MutexIF::TimeoutType::WAITING, 1); @@ -35,8 +36,12 @@ void testmutex::testMutex() { if(result != HasReturnvaluesIF::RETURN_OK) { unitt::put_error(id); } - result = mutex->unlockMutex(); + + // TODO: we should pass a define like FSFW_OSAL_HOST to the build. +#if !defined(WIN32) && !defined(UNIX) + result = mutex->unlockMutex(); if(result != MutexIF::CURR_THREAD_DOES_NOT_OWN_MUTEX) { unitt::put_error(id); } +#endif }