distortos  v0.5.0
object-oriented C++ RTOS for microcontrollers
distortos::test::anonymous_namespace{MutexOperationsTestCase.cpp} Namespace Reference

Functions

void lockUnlockThread (Mutex &mutex, bool &sharedRet, Mutex &semaphoreMutex)
 Simple thread that locks and unlocks the mutex, with additional correctness checks. More...
 
bool testUnlock (Mutex &mutex)
 Tests Mutex::unlock() - it must succeed immediately. More...
 
bool phase1 (const Mutex::Type type, const Mutex::Protocol protocol, const uint8_t priorityCeiling)
 Phase 1 of test case. More...
 
bool phase2 (const Mutex::Type type, const Mutex::Protocol protocol, const uint8_t priorityCeiling)
 Phase 2 of test case. More...
 
bool phase3 (const Mutex::Type type, const Mutex::Protocol protocol, const uint8_t priorityCeiling)
 Phase 3 of test case. More...
 

Variables

constexpr auto singleDuration = TickClock::duration{1}
 single duration used in tests More...
 
constexpr auto longDuration = singleDuration * 10
 long duration used in tests More...
 
constexpr uint8_t testThreadPriority {MutexOperationsTestCase::getTestCasePriority()}
 priority of current test thread and lock-unlock test thread More...
 
constexpr size_t testThreadStackSize {512}
 size of stack for test thread, bytes More...
 

Function Documentation

◆ lockUnlockThread()

void distortos::test::anonymous_namespace{MutexOperationsTestCase.cpp}::lockUnlockThread ( Mutex mutex,
bool &  sharedRet,
Mutex semaphoreMutex 
)

Simple thread that locks and unlocks the mutex, with additional correctness checks.

First the mutex is locked and this operation is checked - it must happen immediately and it must return 0. Result of that check can be read from sharedRet. In case of failure, thread returns at this point.

Then thread waits for semaphoreMutex to be unlocked.

Last operation is unlocking of the mutex, which is checked in the same way as locking. Result can be read from sharedRet after this thread terminates.

Parameters
[in]mutexis a reference to mutex that will be locked and unlocked, mut be unlocked
[out]sharedRetis a reference to variable used to return result of operations
[in]semaphoreMutexis a mutex used as semaphore, must be locked
Here is the call graph for this function:
Here is the caller graph for this function:

◆ phase1()

bool distortos::test::anonymous_namespace{MutexOperationsTestCase.cpp}::phase1 ( const Mutex::Type  type,
const Mutex::Protocol  protocol,
const uint8_t  priorityCeiling 
)

Phase 1 of test case.

Tests whether all tryLock*() functions properly return some error when dealing with locked mutex.

Parameters
[in]typeis the type of mutex
[in]protocolis the mutex protocol
[in]priorityCeilingis the priority ceiling of mutex, ignored when protocol != Protocol::priorityProtect
Returns
true if test succeeded, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ phase2()

bool distortos::test::anonymous_namespace{MutexOperationsTestCase.cpp}::phase2 ( const Mutex::Type  type,
const Mutex::Protocol  protocol,
const uint8_t  priorityCeiling 
)

Phase 2 of test case.

Tests whether all tryLock*() functions properly lock unlocked mutex.

Parameters
[in]typeis the type of mutex
[in]protocolis the mutex protocol
[in]priorityCeilingis the priority ceiling of mutex, ignored when protocol != Protocol::priorityProtect
Returns
true if test succeeded, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ phase3()

bool distortos::test::anonymous_namespace{MutexOperationsTestCase.cpp}::phase3 ( const Mutex::Type  type,
const Mutex::Protocol  protocol,
const uint8_t  priorityCeiling 
)

Phase 3 of test case.

Tests typical lock transfer scenario in lock(), tryLockFor() and tryLockUntil() functions. Mutex is locked in another thread and main (current) thread waits for this mutex to become available. Test thread unlocks the mutex at specified time point, main thread is expected to acquire ownership of this mutex in the same moment.

Parameters
[in]typeis the type of mutex
[in]protocolis the mutex protocol
[in]priorityCeilingis the priority ceiling of mutex, ignored when protocol != Protocol::priorityProtect
Returns
true if test succeeded, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ testUnlock()

bool distortos::test::anonymous_namespace{MutexOperationsTestCase.cpp}::testUnlock ( Mutex mutex)

Tests Mutex::unlock() - it must succeed immediately.

Parameters
[in]mutexis a reference to mutex that will be unlocked
Returns
true if test succeeded, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ longDuration

constexpr auto distortos::test::anonymous_namespace{MutexOperationsTestCase.cpp}::longDuration = singleDuration * 10

long duration used in tests

◆ singleDuration

constexpr auto distortos::test::anonymous_namespace{MutexOperationsTestCase.cpp}::singleDuration = TickClock::duration{1}

single duration used in tests

◆ testThreadPriority

constexpr uint8_t distortos::test::anonymous_namespace{MutexOperationsTestCase.cpp}::testThreadPriority {MutexOperationsTestCase::getTestCasePriority()}

priority of current test thread and lock-unlock test thread

◆ testThreadStackSize

constexpr size_t distortos::test::anonymous_namespace{MutexOperationsTestCase.cpp}::testThreadStackSize {512}

size of stack for test thread, bytes