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

Functions

bool testMutexAndUnlock (Mutex &mutex)
 Tests whether supplied mutex is properly locked and unlocks it. More...
 
bool phase1 (Mutex &mutex)
 Phase 1 of test case. More...
 
bool phase2 (Mutex &mutex)
 Phase 2 of test case. More...
 
bool phase3 (Mutex &mutex)
 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...
 
decltype(statistics::getContextSwitchCount()) constexpr waitForNextTickContextSwitchCount {2}
 expected number of context switches in waitForNextTick(): main -> idle -> main More...
 
decltype(statistics::getContextSwitchCount()) constexpr testMutexAndUnlockContextSwitchCount
 expected number of context switches in testMutexAndUnlock(): main -> idle -> main More...
 
decltype(statistics::getContextSwitchCount()) constexpr phase1WaitForUntilContextSwitchCount {2}
 
decltype(statistics::getContextSwitchCount()) constexpr phase2ThreadContextSwitchCount {5}
 
decltype(statistics::getContextSwitchCount()) constexpr phase3SoftwareTimerContextSwitchCount {2}
 

Function Documentation

◆ phase1()

bool distortos::test::anonymous_namespace{ConditionVariableOperationsTestCase.cpp}::phase1 ( Mutex mutex)

Phase 1 of test case.

Tests whether both waitFor() and waitUntil() functions properly return some error and properly handle mutex when timing out without notification.

Parameters
[in]mutexis a reference to mutex used with condition variable, must 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:

◆ phase2()

bool distortos::test::anonymous_namespace{ConditionVariableOperationsTestCase.cpp}::phase2 ( Mutex mutex)

Phase 2 of test case.

Tests thread-thread signaling scenario. Main (current) thread waits for condition variable notification (using wait(), waitFor() and waitUntil()). Test thread notifies one waiter at specified time point, main thread is expected to wake up and acquire ownership of the mutex in the same moment.

Parameters
[in]mutexis a reference to mutex used with condition variable, must 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:

◆ phase3()

bool distortos::test::anonymous_namespace{ConditionVariableOperationsTestCase.cpp}::phase3 ( Mutex mutex)

Phase 3 of test case.

Tests interrupt-thread signaling scenario. Main (current) thread waits for condition variable notification (using wait(), waitFor() and waitUntil()). Software timer is used to notify one waiter at specified time point from interrupt context, main thread is expected to wake up and acquire ownership of the mutex in the same moment.

Parameters
[in]mutexis a reference to mutex used with condition variable, must 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:

◆ testMutexAndUnlock()

bool distortos::test::anonymous_namespace{ConditionVariableOperationsTestCase.cpp}::testMutexAndUnlock ( Mutex mutex)

Tests whether supplied mutex is properly locked and unlocks it.

Parameters
[in]mutexis a reference to mutex that will be tested and unlocked
Returns
true if test succeeded and mutex was sucessfully unlocked, 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{ConditionVariableOperationsTestCase.cpp}::longDuration = singleDuration * 10

long duration used in tests

◆ phase1WaitForUntilContextSwitchCount

decltype(statistics::getContextSwitchCount()) constexpr distortos::test::anonymous_namespace{ConditionVariableOperationsTestCase.cpp}::phase1WaitForUntilContextSwitchCount {2}

expected number of context switches in phase1 block involving waitFor() or waitUntil() (excluding waitForNextTick() and testMutexAndUnlock()): 1 - main thread blocks on condition variable (main -> idle), 2 - main thread wakes up (idle -> main)

◆ phase2ThreadContextSwitchCount

decltype(statistics::getContextSwitchCount()) constexpr distortos::test::anonymous_namespace{ConditionVariableOperationsTestCase.cpp}::phase2ThreadContextSwitchCount {5}

expected number of context switches in phase2 block involving test thread (excluding waitForNextTick() and testMutexAndUnlock()): 1 - test thread starts (main -> test), 2 - test thread goes to sleep (test -> main), 3 - main thread blocks on condition variable (main -> idle), 4 - test thread wakes (idle -> test), 5 - test thread terminates (test -> main)

◆ phase3SoftwareTimerContextSwitchCount

decltype(statistics::getContextSwitchCount()) constexpr distortos::test::anonymous_namespace{ConditionVariableOperationsTestCase.cpp}::phase3SoftwareTimerContextSwitchCount {2}

expected number of context switches in phase3 block involving software timer (excluding waitForNextTick() and testMutexAndUnlock()): 1 - main thread blocks on condition variable (main -> idle), 2 - main thread is unblocked by interrupt (idle -> main)

◆ singleDuration

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

single duration used in tests

◆ testMutexAndUnlockContextSwitchCount

decltype(statistics::getContextSwitchCount()) constexpr distortos::test::anonymous_namespace{ConditionVariableOperationsTestCase.cpp}::testMutexAndUnlockContextSwitchCount
Initial value:
{
}
decltype(statistics::getContextSwitchCount()) constexpr waitForNextTickContextSwitchCount
expected number of context switches in waitForNextTick(): main -> idle -> main
Definition: ConditionVariableOperationsTestCase.cpp:46

expected number of context switches in testMutexAndUnlock(): main -> idle -> main

◆ waitForNextTickContextSwitchCount

decltype(statistics::getContextSwitchCount()) constexpr distortos::test::anonymous_namespace{ConditionVariableOperationsTestCase.cpp}::waitForNextTickContextSwitchCount {2}

expected number of context switches in waitForNextTick(): main -> idle -> main