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

Classes

struct  TestStep
 single test step for test thread More...
 

Typedefs

using TestStepRange = estd::ContiguousRange< const TestStep >
 range with test steps More...
 

Functions

void thread (const TickClock::time_point sleepUntil, SequenceAsserter &sequenceAsserter, const TestStepRange &steps)
 Test thread. More...
 
DynamicThread makeAndStartTestThread (const uint8_t priority, const TickClock::time_point sleepUntil, SequenceAsserter &sequenceAsserter, const TestStepRange &steps)
 Makes and starts test thread. More...
 
bool testRunner (const std::array< int, totalThreads > &delays, const std::array< TestStepRange, totalThreads > &stepsRanges, const size_t expectedContextSwitchesCount)
 Common code to run the test. More...
 
bool priorityInheritancePhase ()
 Test phase of PriorityInheritance protocol. More...
 
bool priorityProtectPhase ()
 Test phase of PriorityProtect protocol. More...
 

Variables

constexpr size_t testThreadStackSize {512}
 size of stack for test thread, bytes More...
 
constexpr size_t totalThreads {5}
 total number of test threads More...
 
constexpr TickClock::duration durationUnit {10}
 duration unit used in test More...
 
const std::array< int, totalThreadsthreadDelays
 array with delays of test threads (in durationUnit) More...
 
constexpr size_t delayedStartContextSwitchesCount {4}
 number of context switches caused by delayed start of test threads More...
 

Typedef Documentation

◆ TestStepRange

using distortos::test::anonymous_namespace{MutexPriorityProtocolTestCase.cpp}::TestStepRange = typedef estd::ContiguousRange<const TestStep>

range with test steps

Function Documentation

◆ makeAndStartTestThread()

DynamicThread distortos::test::anonymous_namespace{MutexPriorityProtocolTestCase.cpp}::makeAndStartTestThread ( const uint8_t  priority,
const TickClock::time_point  sleepUntil,
SequenceAsserter sequenceAsserter,
const TestStepRange steps 
)

Makes and starts test thread.

Parameters
[in]priorityis the priority of thread
[in]sleepUntilis the time_point at which test steps will start to be executed by thread
[in]sequenceAsserteris a reference to SequenceAsserter shared object
[in]stepsis a reference to TestStepRange with test steps for this instance
Returns
constructed and started DynamicThread object
Here is the call graph for this function:
Here is the caller graph for this function:

◆ priorityInheritancePhase()

bool distortos::test::anonymous_namespace{MutexPriorityProtocolTestCase.cpp}::priorityInheritancePhase ( )

Test phase of PriorityInheritance protocol.

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

◆ priorityProtectPhase()

bool distortos::test::anonymous_namespace{MutexPriorityProtocolTestCase.cpp}::priorityProtectPhase ( )

Test phase of PriorityProtect protocol.

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

◆ testRunner()

bool distortos::test::anonymous_namespace{MutexPriorityProtocolTestCase.cpp}::testRunner ( const std::array< int, totalThreads > &  delays,
const std::array< TestStepRange, totalThreads > &  stepsRanges,
const size_t  expectedContextSwitchesCount 
)

Common code to run the test.

Parameters
[in]delaysis an array with delays for each test thread
[in]stepsRangesis an array with TestStepRange elements for each test thread
[in]expectedContextSwitchesCountis the expected count of context switches for the whole test
Returns
true if the test case succeeded, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ thread()

void distortos::test::anonymous_namespace{MutexPriorityProtocolTestCase.cpp}::thread ( const TickClock::time_point  sleepUntil,
SequenceAsserter sequenceAsserter,
const TestStepRange steps 
)

Test thread.

First thing done is going to sleep for requested amount of time. Then all steps from provided TestStepRange are executed:

  • mark "before" sequence point,
  • if provided, execute function on mutex,
  • mark "after" sequence point,
  • waste time.
Parameters
[in]sleepUntilis the time_point at which test steps will start to be executed
[in]sequenceAsserteris a reference to SequenceAsserter shared object
[in]stepsis a reference to TestStepRange with test steps for this instance
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ delayedStartContextSwitchesCount

constexpr size_t distortos::test::anonymous_namespace{MutexPriorityProtocolTestCase.cpp}::delayedStartContextSwitchesCount {4}

number of context switches caused by delayed start of test threads

◆ durationUnit

constexpr TickClock::duration distortos::test::anonymous_namespace{MutexPriorityProtocolTestCase.cpp}::durationUnit {10}

duration unit used in test

◆ testThreadStackSize

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

size of stack for test thread, bytes

◆ threadDelays

const std::array<int, totalThreads> distortos::test::anonymous_namespace{MutexPriorityProtocolTestCase.cpp}::threadDelays
Initial value:
{{
0, 3, 6, 10, 11,
}}

array with delays of test threads (in durationUnit)

◆ totalThreads

constexpr size_t distortos::test::anonymous_namespace{MutexPriorityProtocolTestCase.cpp}::totalThreads {5}

total number of test threads