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

Functions

bool testTryPopWhenEmpty (const QueueWrapper &queueWrapper)
 Tests QueueWrapper::tryPop() when queue is empty - it must fail immediately and return EAGAIN. More...
 
bool testTryPopWhenNotEmpty (const QueueWrapper &queueWrapper)
 Tests QueueWrapper::tryPop() when queue is not empty - it must succeed immediately. More...
 
bool testTryPushWhenFull (const QueueWrapper &queueWrapper)
 Tests QueueWrapper::tryPush(..., const T&) when queue is full - it must fail immediately and return EAGAIN. More...
 
bool phase1 ()
 Phase 1 of test case. More...
 
bool phase2 ()
 Phase 2 of test case. More...
 
bool phase3 ()
 Phase 3 of test case. More...
 
bool phase4 ()
 Phase 4 of test case. More...
 
bool phase5 ()
 Phase 5 of test case. More...
 
bool phase6 ()
 Phase 6 of test case. More...
 

Variables

constexpr bool falseTrue [] {false, true}
 array with "false" and "true" bool values More...
 
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 phase1TryForUntilContextSwitchCount {2}
 
decltype(statistics::getContextSwitchCount()) constexpr phase34SoftwareTimerContextSwitchCount {2}
 

Function Documentation

◆ phase1()

bool distortos::test::anonymous_namespace{QueueOperationsTestCase.cpp}::phase1 ( )

Phase 1 of test case.

Tests whether all tryEmplace*(), tryPush*() and tryPop*() functions properly return some error when dealing with full or empty queue.

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{QueueOperationsTestCase.cpp}::phase2 ( )

Phase 2 of test case.

Tests whether all tryEmplace*(), tryPush*() and tryPop*() functions properly send data via non-full or non-empty queue.

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{QueueOperationsTestCase.cpp}::phase3 ( )

Phase 3 of test case.

Tests interrupt -> thread communication scenario. Main (current) thread waits for data to become available in queue. Software timer pushes some values to the same queue at specified time point from interrupt context, main thread is expected to receive these values (with pop(), tryPopFor() and tryPopUntil()) in the same moment.

Returns
true if test succeeded, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ phase4()

bool distortos::test::anonymous_namespace{QueueOperationsTestCase.cpp}::phase4 ( )

Phase 4 of test case.

Tests thread -> interrupt communication scenario. Main (current) thread pushes data to queue (which is initially full). Software timer pops first value (which should match the one pushed previously) from the same queue at specified time point from interrupt context, main thread is expected to succeed in pushing new value (with emplace(), push(), tryEmplaceFor(), tryEmplaceUntil(), tryPushFor() and tryPushUntil()) in the same moment.

Returns
true if test succeeded, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ phase5()

bool distortos::test::anonymous_namespace{QueueOperationsTestCase.cpp}::phase5 ( )

Phase 5 of test case.

Tests whether all *push*() and *pop*() functions of "raw" queue properly return some error when given invalid size of buffer.

Returns
true if test succeeded, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ phase6()

bool distortos::test::anonymous_namespace{QueueOperationsTestCase.cpp}::phase6 ( )

Phase 6 of test case.

Tests whether destructor of "non-raw" queue properly destructs objects that remain in the queue.

Returns
true if test succeeded, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ testTryPopWhenEmpty()

bool distortos::test::anonymous_namespace{QueueOperationsTestCase.cpp}::testTryPopWhenEmpty ( const QueueWrapper queueWrapper)

Tests QueueWrapper::tryPop() when queue is empty - it must fail immediately and return EAGAIN.

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

◆ testTryPopWhenNotEmpty()

bool distortos::test::anonymous_namespace{QueueOperationsTestCase.cpp}::testTryPopWhenNotEmpty ( const QueueWrapper queueWrapper)

Tests QueueWrapper::tryPop() when queue is not empty - it must succeed immediately.

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

◆ testTryPushWhenFull()

bool distortos::test::anonymous_namespace{QueueOperationsTestCase.cpp}::testTryPushWhenFull ( const QueueWrapper queueWrapper)

Tests QueueWrapper::tryPush(..., const T&) when queue is full - it must fail immediately and return EAGAIN.

Parameters
[in]queueWrapperis a reference to QueueWrapper that will be tested
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

◆ falseTrue

constexpr bool distortos::test::anonymous_namespace{QueueOperationsTestCase.cpp}::falseTrue[] {false, true}

array with "false" and "true" bool values

◆ longDuration

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

long duration used in tests

◆ phase1TryForUntilContextSwitchCount

decltype(statistics::getContextSwitchCount()) constexpr distortos::test::anonymous_namespace{QueueOperationsTestCase.cpp}::phase1TryForUntilContextSwitchCount {2}

expected number of context switches in phase1 block involving tryEmplaceFor(), tryEmplaceUntil(), tryPopFor(), tryPopUntil(), tryPushFor() or tryPushUntil() (excluding waitForNextTick()): 1 - main thread blocks on queue (main -> idle), 2 - main thread wakes up (idle -> main)

◆ phase34SoftwareTimerContextSwitchCount

decltype(statistics::getContextSwitchCount()) constexpr distortos::test::anonymous_namespace{QueueOperationsTestCase.cpp}::phase34SoftwareTimerContextSwitchCount {2}

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

◆ singleDuration

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

single duration used in tests

◆ waitForNextTickContextSwitchCount

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

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