repaired internal unit test
This commit is contained in:
@ -3,8 +3,8 @@
|
||||
#include <fsfw/ipc/MutexFactory.h>
|
||||
#include <fsfw/unittest/internal/UnittDefinitions.h>
|
||||
|
||||
#if defined(hosted)
|
||||
#include <fsfw/osal/hosted/Mutex.h>
|
||||
#if defined(WIN32) || defined(UNIX)
|
||||
#include <fsfw/osal/host/Mutex.h>
|
||||
#include <thread>
|
||||
#include <future>
|
||||
#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
|
||||
}
|
||||
|
Reference in New Issue
Block a user