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

Typedefs

using SendSignal = int(Thread &, uint8_t, int)
 type of function used to send signal to selected thread More...
 
using TestReceivedSignalInformation = bool(const SignalInformation &, uint8_t, int)
 type of function used to test received SignalInformation object More...
 
using Stage = std::pair< const SendSignal &, const TestReceivedSignalInformation & >
 pair with functions for one stage More...
 

Functions

int generateSignalWrapper (Thread &thread, const uint8_t signalNumber, int)
 Wrapper for Thread::generateSignal(). More...
 
int queueSignalWrapper (Thread &thread, const uint8_t signalNumber, const int value)
 Wrapper for Thread::queueSignal(). More...
 
bool testReceivedGeneratedSignal (const SignalInformation &signalInformation, const uint8_t signalNumber, int)
 Tests whether received SignalInformation object matches the signal that was generated. More...
 
bool testReceivedQueuedSignal (const SignalInformation &signalInformation, const uint8_t signalNumber, const int value)
 Tests whether received SignalInformation object matches the signal that was queued. More...
 
bool testSelfNoSignalsPending ()
 Tests whether no signals are pending for current thread. More...
 
bool testSelfSendSignal (const SendSignal &sendSignal, const uint8_t signalNumber, const int value)
 Tests sending of signal to current thread. More...
 
void tryWaitWrapper (const SignalSet &signalSet, int &sharedRet)
 Wrapper for ThisThread::Signals::tryWait() that can be used in phase3(). More...
 
void tryWaitForWrapper (const SignalSet &signalSet, int &sharedRet)
 Wrapper for ThisThread::Signals::tryWaitFor() that can be used in phase3(). More...
 
void tryWaitUntilWrapper (const SignalSet &signalSet, int &sharedRet)
 Wrapper for ThisThread::Signals::tryWaitUntil() that can be used in phase3(). More...
 
void waitWrapper (const SignalSet &signalSet, int &sharedRet)
 Wrapper for ThisThread::Signals::wait() that can be used in phase3(). More...
 
bool phase1 (const SendSignal &sendSignal, const TestReceivedSignalInformation &testReceivedSignalInformation)
 Phase 1 of test case. More...
 
bool phase2 (const SendSignal &sendSignal, const TestReceivedSignalInformation &testReceivedSignalInformation)
 Phase 2 of test case. More...
 
bool phase3 (const SendSignal &sendSignal, const TestReceivedSignalInformation &)
 Phase 3 of test case. More...
 
bool phase4 (const SendSignal &sendSignal, const TestReceivedSignalInformation &)
 Phase 4 of test case. More...
 

Variables

constexpr size_t testThreadStackSize {512}
 size of stack for test thread, bytes 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 phase1TimedOutWaitContextSwitchCount {2}
 
decltype(statistics::getContextSwitchCount()) constexpr phase2SoftwareTimerContextSwitchCount {2}
 
decltype(statistics::getContextSwitchCount()) constexpr phase3ThreadContextSwitchCount {2}
 
constexpr size_t stagesSize {2}
 size of stages array More...
 
const std::array< Stage, stagesSizestages
 test stages More...
 

Typedef Documentation

◆ SendSignal

using distortos::test::anonymous_namespace{SignalsWaitOperationsTestCase.cpp}::SendSignal = typedef int(Thread&, uint8_t, int)

type of function used to send signal to selected thread

◆ Stage

using distortos::test::anonymous_namespace{SignalsWaitOperationsTestCase.cpp}::Stage = typedef std::pair<const SendSignal&, const TestReceivedSignalInformation&>

pair with functions for one stage

◆ TestReceivedSignalInformation

using distortos::test::anonymous_namespace{SignalsWaitOperationsTestCase.cpp}::TestReceivedSignalInformation = typedef bool(const SignalInformation&, uint8_t, int)

type of function used to test received SignalInformation object

Function Documentation

◆ generateSignalWrapper()

int distortos::test::anonymous_namespace{SignalsWaitOperationsTestCase.cpp}::generateSignalWrapper ( Thread thread,
const uint8_t  signalNumber,
int   
)

Wrapper for Thread::generateSignal().

Parameters
[in]threadis a reference to Thread for which the signal will be generated
[in]signalNumberis the signal that will be generated, [0; 31]
[in]valueis the signal value (ignored)
Returns
values returned by Thread::generateSignal()
Here is the call graph for this function:

◆ phase1()

bool distortos::test::anonymous_namespace{SignalsWaitOperationsTestCase.cpp}::phase1 ( const SendSignal sendSignal,
const TestReceivedSignalInformation testReceivedSignalInformation 
)

Phase 1 of test case.

Tests whether all ThisThread::Signals::tryWait*() functions properly ignore pending signal that is not included in SignalSet and accept it otherwise.

Parameters
[in]sendSignalis a reference to function used to send signal to current thread
[in]testReceivedSignalInformationis a reference to TestReceivedSignalInformation function used to test received SignalInformation object
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{SignalsWaitOperationsTestCase.cpp}::phase2 ( const SendSignal sendSignal,
const TestReceivedSignalInformation testReceivedSignalInformation 
)

Phase 2 of test case.

Tests interrupt -> thread communication scenario. Main (current) thread waits for signals. Software timer generates signal for main thread at specified time point from interrupt context, main thread is expected to accept this signal (with ThisThread::Signals::wait(), ThisThread::Signals::tryWaitFor() and ThisThread::Signals::tryWaitUntil()) in the same moment.

Parameters
[in]sendSignalis a reference to function used to send signal to current thread
[in]testReceivedSignalInformationis a reference to TestReceivedSignalInformation function used to test received SignalInformation object
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{SignalsWaitOperationsTestCase.cpp}::phase3 ( const SendSignal sendSignal,
const TestReceivedSignalInformation  
)

Phase 3 of test case.

Tests various error cases:

Parameters
[in]sendSignalis a reference to function used to send signal to selected thread
[in]testReceivedSignalInformationis a reference to TestReceivedSignalInformation function used to test received SignalInformation object (ignored)
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{SignalsWaitOperationsTestCase.cpp}::phase4 ( const SendSignal sendSignal,
const TestReceivedSignalInformation  
)

Phase 4 of test case.

Tests ignoring of pending signal and sending of ignored signal.

Parameters
[in]sendSignalis a reference to function used to send signal to selected thread
[in]testReceivedSignalInformationis a reference to TestReceivedSignalInformation function used to test received SignalInformation object (ignored)
Returns
true if test succeeded, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ queueSignalWrapper()

int distortos::test::anonymous_namespace{SignalsWaitOperationsTestCase.cpp}::queueSignalWrapper ( Thread thread,
const uint8_t  signalNumber,
const int  value 
)

Wrapper for Thread::queueSignal().

Parameters
[in]threadis a reference to Thread for which the signal will be queued
[in]signalNumberis the signal that will be queued, [0; 31]
[in]valueis the signal value
Returns
values returned by Thread::queueSignal()
Here is the call graph for this function:

◆ testReceivedGeneratedSignal()

bool distortos::test::anonymous_namespace{SignalsWaitOperationsTestCase.cpp}::testReceivedGeneratedSignal ( const SignalInformation signalInformation,
const uint8_t  signalNumber,
int   
)

Tests whether received SignalInformation object matches the signal that was generated.

Parameters
[in]signalInformationis a reference to received SignalInformation object
[in]signalNumberis the signal number that was generated
[in]valueis the signal value that was sent (ignored)
Returns
true if test succeeded, false otherwise
Here is the call graph for this function:

◆ testReceivedQueuedSignal()

bool distortos::test::anonymous_namespace{SignalsWaitOperationsTestCase.cpp}::testReceivedQueuedSignal ( const SignalInformation signalInformation,
const uint8_t  signalNumber,
const int  value 
)

Tests whether received SignalInformation object matches the signal that was queued.

Parameters
[in]signalInformationis a reference to received SignalInformation object
[in]signalNumberis the signal number that was queued
[in]valueis the signal value that was queued
Returns
true if test succeeded, false otherwise
Here is the call graph for this function:

◆ testSelfNoSignalsPending()

bool distortos::test::anonymous_namespace{SignalsWaitOperationsTestCase.cpp}::testSelfNoSignalsPending ( )

Tests whether no signals are pending for current thread.

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

◆ testSelfSendSignal()

bool distortos::test::anonymous_namespace{SignalsWaitOperationsTestCase.cpp}::testSelfSendSignal ( const SendSignal sendSignal,
const uint8_t  signalNumber,
const int  value 
)

Tests sending of signal to current thread.

Initially no signals may be pending for current thread. After call to sendSignal() exactly one signal - signalNumber - must be pending.

Parameters
[in]sendSignalis a reference to function used to send signal to current thread
[in]signalNumberis the signal number that will be generated
[in]valueis the signal value
Returns
true if test succeeded, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tryWaitForWrapper()

void distortos::test::anonymous_namespace{SignalsWaitOperationsTestCase.cpp}::tryWaitForWrapper ( const SignalSet signalSet,
int &  sharedRet 
)

Wrapper for ThisThread::Signals::tryWaitFor() that can be used in phase3().

Parameters
[in]signalSetis a reference to SignalSet passed to ThisThread::Signals::tryWaitFor()
[out]sharedRetis a reference to variable in which error code from ThisThread::Signals::tryWaitFor() will be saved
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tryWaitUntilWrapper()

void distortos::test::anonymous_namespace{SignalsWaitOperationsTestCase.cpp}::tryWaitUntilWrapper ( const SignalSet signalSet,
int &  sharedRet 
)

Wrapper for ThisThread::Signals::tryWaitUntil() that can be used in phase3().

Parameters
[in]signalSetis a reference to SignalSet passed to ThisThread::Signals::tryWaitUntil()
[out]sharedRetis a reference to variable in which error code from ThisThread::Signals::tryWaitUntil() will be saved
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tryWaitWrapper()

void distortos::test::anonymous_namespace{SignalsWaitOperationsTestCase.cpp}::tryWaitWrapper ( const SignalSet signalSet,
int &  sharedRet 
)

Wrapper for ThisThread::Signals::tryWait() that can be used in phase3().

Parameters
[in]signalSetis a reference to SignalSet passed to ThisThread::Signals::tryWait()
[out]sharedRetis a reference to variable in which error code from ThisThread::Signals::tryWait() will be saved
Here is the call graph for this function:
Here is the caller graph for this function:

◆ waitWrapper()

void distortos::test::anonymous_namespace{SignalsWaitOperationsTestCase.cpp}::waitWrapper ( const SignalSet signalSet,
int &  sharedRet 
)

Wrapper for ThisThread::Signals::wait() that can be used in phase3().

Parameters
[in]signalSetis a reference to SignalSet passed to ThisThread::Signals::wait()
[out]sharedRetis a reference to variable in which error code from ThisThread::Signals::wait() will be saved
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{SignalsWaitOperationsTestCase.cpp}::longDuration = singleDuration * 10

long duration used in tests

◆ phase1TimedOutWaitContextSwitchCount

decltype(statistics::getContextSwitchCount()) constexpr distortos::test::anonymous_namespace{SignalsWaitOperationsTestCase.cpp}::phase1TimedOutWaitContextSwitchCount {2}

expected number of context switches in phase1 block involving timed-out tryWaitFor() or tryWaitUntil() (excluding waitForNextTick()): 1 - main thread blocks waiting for signals (main -> idle), 2 - main thread wakes up (idle -> main)

◆ phase2SoftwareTimerContextSwitchCount

decltype(statistics::getContextSwitchCount()) constexpr distortos::test::anonymous_namespace{SignalsWaitOperationsTestCase.cpp}::phase2SoftwareTimerContextSwitchCount {2}

expected number of context switches in phase2 block involving software timer (excluding waitForNextTick()): 1 - main thread blocks waiting for signals (main -> idle), 2 - main thread is unblocked by interrupt (idle -> main)

◆ phase3ThreadContextSwitchCount

decltype(statistics::getContextSwitchCount()) constexpr distortos::test::anonymous_namespace{SignalsWaitOperationsTestCase.cpp}::phase3ThreadContextSwitchCount {2}

expected number of context switches in phase3 block involving thread: 1 - main thread is preempted by test thread (main -> test), 2 - test thread terminates (test -> main)

◆ singleDuration

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

single duration used in tests

◆ stages

const std::array<Stage, stagesSize> distortos::test::anonymous_namespace{SignalsWaitOperationsTestCase.cpp}::stages
Initial value:
{{
}}
bool testReceivedQueuedSignal(const SignalInformation &signalInformation, const uint8_t signalNumber, const int value)
Tests whether received SignalInformation object matches the signal that was queued.
Definition: SignalsWaitOperationsTestCase.cpp:151
int queueSignalWrapper(Thread &thread, const uint8_t signalNumber, const int value)
Wrapper for Thread::queueSignal().
Definition: SignalsWaitOperationsTestCase.cpp:116
int generateSignalWrapper(Thread &thread, const uint8_t signalNumber, int)
Wrapper for Thread::generateSignal().
Definition: SignalsWaitOperationsTestCase.cpp:99
bool testReceivedGeneratedSignal(const SignalInformation &signalInformation, const uint8_t signalNumber, int)
Tests whether received SignalInformation object matches the signal that was generated.
Definition: SignalsWaitOperationsTestCase.cpp:133

test stages

◆ stagesSize

constexpr size_t distortos::test::anonymous_namespace{SignalsWaitOperationsTestCase.cpp}::stagesSize {2}

size of stages array

◆ testThreadStackSize

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

size of stack for test thread, bytes

◆ waitForNextTickContextSwitchCount

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

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