distortos  v0.4.0
object-oriented C++ RTOS for microcontrollers
distortos::test Namespace Reference

Functional tests of distortos project. More...

Namespaces

Classes

class  CallOnceFunctionTypesTestCase
 Tests various types of functions that can be used for callOnce(). More...
 
class  CallOnceOperationsTestCase
 Tests callOnce() functionality. More...
 
class  ConditionVariableOperationsTestCase
 Tests various condition variable operations. More...
 
class  ConditionVariablePriorityTestCase
 Tests priority scheduling of conditional variables. More...
 
class  DynamicFifoQueueWrapper
 DynamicFifoQueueWrapper class is a variant of FifoQueueWrapper that has dynamic storage for queue's contents. More...
 
class  DynamicMessageQueueWrapper
 DynamicMessageQueueWrapper class is a variant of MessageQueueWrapper that has dynamic storage for queue's contents. More...
 
class  DynamicRawFifoQueueWrapper
 DynamicRawFifoQueueWrapper class is a variant of RawFifoQueueWrapper that has dynamic storage for queue's contents. More...
 
class  DynamicRawMessageQueueWrapper
 DynamicRawMessageQueueWrapper class is a variant of RawMessageQueueWrapper that has dynamic storage for queue's contents. More...
 
class  FifoQueuePriorityTestCase
 Tests priority scheduling of FIFO queue (raw and non-raw). More...
 
class  FifoQueueWrapper
 implementation of QueueWrapper for FifoQueue More...
 
class  FpuSignalTestCase
 Tests saving of FPU context between thread, signal sender (interrupt or another thread) and signal handler. More...
 
class  FpuThreadTestCase
 Tests saving of FPU context between threads. More...
 
class  MessageQueuePriorityTestCase
 Tests priority scheduling of message queue (raw and non-raw). More...
 
class  MessageQueueWrapper
 implementation of QueueWrapper for MessageQueue More...
 
class  MutexErrorCheckingOperationsTestCase
 Tests operations in scenarios specific for ErrorChecking type of mutex. More...
 
class  MutexOperationsTestCase
 Tests various mutex operations. More...
 
class  MutexPriorityInheritanceOperationsTestCase
 Tests operations in scenarios specific for PriorityInheritance protocol of mutex. More...
 
class  MutexPriorityProtectOperationsTestCase
 Tests operations in scenarios specific for PriorityProtect protocol of mutex. More...
 
class  MutexPriorityProtocolTestCase
 Executes typical "priority inversion" scenario using mutexes with PriorityInheritance or PriorityProtect protocol. More...
 
class  MutexPriorityTestCase
 Tests priority scheduling of mutexes. More...
 
class  MutexRecursiveOperationsTestCase
 Tests operations in scenarios specific for Recursive type of mutex. More...
 
class  NonRawQueueWrapper
 common implementation of QueueWrapper for {Fifo,Message}Queue More...
 
class  OperationCountingType
 
class  PrioritizedTestCase
 PrioritizedTestCase class is a TestCase which runs at specific priority, restoring original priority of main test thread afterwards. More...
 
class  QueueOperationsTestCase
 Tests various [Raw]{Fifo,Message}Queue operations. More...
 
class  QueueWrapper
 wrapper for [Raw]{Fifo,Message}Queue More...
 
class  RawFifoQueueWrapper
 implementation of RawQueueWrapper for RawFifoQueue More...
 
class  RawMessageQueueWrapper
 implementation of RawQueueWrapper for RawMessageQueue More...
 
class  RawQueueWrapper
 common implementation of QueueWrapper for Raw{Fifo,Message}Queue More...
 
class  SemaphoreOperationsTestCase
 Tests various semaphore operations. More...
 
class  SemaphorePriorityTestCase
 Tests priority scheduling of semaphores. More...
 
class  SequenceAsserter
 SequenceAsserter class is used to assert that some sequencePoint of events are performed in specific order. More...
 
class  SignalCatchingOperationsTestCase
 Tests operations specific to catching signals. More...
 
class  SignalsCatchingTestCase
 Tests operations specific to catching of signals. More...
 
class  SignalsGenerationOperationsTestCase
 Tests operations specific to generated signals. More...
 
class  SignalsInterruptionTestCase
 Tests interruption of various "blocking" functions by an unmasked, caught signal. More...
 
class  SignalsQueuedOperationsTestCase
 Tests operations specific to queued signals. More...
 
class  SignalsTestCaseCommon
 SignalsTestCaseCommon class is a TestCase with initialization and finalization steps required for signals. More...
 
class  SignalsWaitOperationsTestCase
 Tests various operations related to waiting for signals. More...
 
class  SignalsWaitTestCase
 Tests waiting for signals. More...
 
class  SoftwareTimerFunctionTypesTestCase
 Tests various types of functions that can be used for software timers. More...
 
class  SoftwareTimerOperationsTestCase
 Tests various functions of software timers. More...
 
class  SoftwareTimerOrderingTestCase
 Tests ordering of software timers. More...
 
class  SoftwareTimerPeriodicTestCase
 Tests behavior of periodic software timers. More...
 
class  StaticFifoQueueWrapper
 StaticFifoQueueWrapper class is a variant of FifoQueueWrapper that has automatic storage for queue's contents. More...
 
class  StaticMessageQueueWrapper
 StaticMessageQueueWrapper class is a variant of MessageQueueWrapper that has automatic storage for queue's contents. More...
 
class  StaticRawFifoQueueWrapper
 StaticRawFifoQueueWrapper class is a variant of RawFifoQueueWrapper that has automatic storage for queue's contents. More...
 
class  StaticRawMessageQueueWrapper
 StaticRawMessageQueueWrapper class is a variant of RawMessageQueueWrapper that has automatic storage for queue's contents. More...
 
class  TestCase
 TestCase class is an interface class for test cases. More...
 
class  TestCaseCommon
 TestCaseCommon class implements common parts of TestCase. More...
 
class  TestCaseGroup
 TestCaseGroup class is a group of TestCase objects. More...
 
class  ThreadFunctionTypesTestCase
 Tests various types of functions that can be used for threads. More...
 
class  ThreadOperationsTestCase
 Tests various functions of threads. More...
 
class  ThreadPriorityChangeTestCase
 Tests changing of thread priority. More...
 
class  ThreadPriorityTestCase
 Tests priority scheduling of threads. More...
 
class  ThreadSchedulingPolicyTestCase
 Tests round-robin scheduling of threads. More...
 
class  ThreadSleepForTestCase
 Tests "sleep for" functionality of threads. More...
 
class  ThreadSleepUntilTestCase
 Tests "sleep for" functionality of threads. More...
 

Typedefs

using ThreadParameters = std::pair< uint8_t, uint8_t >
 parameters of test thread - priority, sequence point More...
 
using TestPhase = std::pair< const std::array< ThreadParameters, totalThreads > &, std::array< uint8_t, totalThreads > >
 description of test phase - reference to array with ThreadParameters, sequence of indexes for this array More...
 
using QueueWrapperUniquePointer = std::unique_ptr< QueueWrapper >
 unique_ptr with QueueWrapper More...
 
using RawQueueWrapperUniquePointer = std::unique_ptr< RawQueueWrapper >
 unique_ptr with RawQueueWrapper More...
 

Functions

bool checkFpuRegisters (uint32_t value, uint32_t fpscr)
 Checks whether all FPU registers contain given value. More...
 
uint32_t setFpuRegisters (uint32_t value, bool full)
 Sets FPU registers (including fpscr) to given value. More...
 
bool mutexTestTryLockWhenLocked (Mutex &mutex, uint8_t priority=UINT8_MAX)
 Tests Mutex::tryLock() when mutex is locked - it must succeed immediately and return EBUSY. More...
 
bool mutexTestUnlockFromWrongThread (Mutex &mutex)
 Tests unlocking of ErrorChecking or Recursive mutex from a wrong thread. More...
 
bool operator!= (const OperationCountingType &left, const OperationCountingType &right)
 Inequality comparison operator for OperationCountingType. More...
 
template<size_t QueueSize>
RawQueueWrapperUniquePointer makeRawQueueWrapper (const bool dynamic, const bool fifo)
 RawQueueWrapper's factory function. More...
 
template<size_t QueueSize>
QueueWrapperUniquePointer makeQueueWrapper (const bool dynamic, const bool raw, const bool fifo)
 QueueWrapper's factory function. More...
 
void abortSignalHandler (const SignalInformation &signalInformation)
 Signal handler that is never supposed to be executed - it calls abort(). More...
 
bool signalsTestSelfOneSignalPending (uint8_t signalNumber)
 Tests whether exactly one signal is pending for current thread. More...
 
void waitForNextTick ()
 Waits for beginning of next tick. More...
 
void wasteTime (TickClock::duration duration)
 Wastes time. More...
 
void wasteTime (TickClock::time_point timePoint)
 Wastes time. More...
 
template<typename Rep , typename Period >
void wasteTime (const std::chrono::duration< Rep, Period > duration)
 Wastes time. More...
 
template<typename Duration >
void wasteTime (const std::chrono::time_point< TickClock, Duration > timePoint)
 Wastes time. More...
 

Variables

const TestCaseGroup architectureTestCases {TestCaseGroup::Range{threadTestCases_}}
 group of architecture-specific test cases More...
 
const TestCaseGroup callOnceTestCases {TestCaseGroup::Range{callOnceTestCases_}}
 group of test cases related to callOnce() More...
 
const TestCaseGroup conditionVariableTestCases {TestCaseGroup::Range{conditionVariableTestCases_}}
 group of test cases related to condition variables More...
 
const TestCaseGroup mutexTestCases {TestCaseGroup::Range{mutexTestCases_}}
 group of test cases related to mutexes More...
 
const std::array< TestPhase, totalPhasespriorityTestPhases
 array with test phases More...
 
constexpr size_t totalThreads {8}
 number of test threads More...
 
constexpr size_t totalPhases {8}
 number of test phases More...
 
constexpr uint8_t maxPhasePriority {UINT8_MAX - 1}
 max priority used in test phases More...
 
const TestCaseGroup queueTestCases {TestCaseGroup::Range{queueTestCases_}}
 group of test cases related to queue More...
 
const TestCaseGroup semaphoreTestCases {TestCaseGroup::Range{semaphoreTestCases_}}
 group of test cases related to semaphores More...
 
const TestCaseGroup signalsTestCases {TestCaseGroup::Range{messageQueueTestCases_}}
 group of test cases related to signals More...
 
const TestCaseGroup softwareTimerTestCases {TestCaseGroup::Range{softwareTimerTestCases_}}
 group of test cases related to software timers More...
 
const TestCaseGroup testCases {TestCaseGroup::Range{testCases_}}
 top-level group of test cases More...
 
const TestCaseGroup threadTestCases {TestCaseGroup::Range{threadTestCases_}}
 group of test cases related to threads More...
 

Detailed Description

Functional tests of distortos project.

Typedef Documentation

◆ QueueWrapperUniquePointer

using distortos::test::QueueWrapperUniquePointer = typedef std::unique_ptr<QueueWrapper>

unique_ptr with QueueWrapper

◆ RawQueueWrapperUniquePointer

unique_ptr with RawQueueWrapper

◆ TestPhase

using distortos::test::TestPhase = typedef std::pair<const std::array<ThreadParameters, totalThreads>&, std::array<uint8_t, totalThreads> >

description of test phase - reference to array with ThreadParameters, sequence of indexes for this array

◆ ThreadParameters

using distortos::test::ThreadParameters = typedef std::pair<uint8_t, uint8_t>

parameters of test thread - priority, sequence point

Function Documentation

◆ abortSignalHandler()

void distortos::test::abortSignalHandler ( const SignalInformation signalInformation)

Signal handler that is never supposed to be executed - it calls abort().

Parameters
[in]signalInformationis a reference to received SignalInformation object
Here is the caller graph for this function:

◆ checkFpuRegisters()

bool distortos::test::checkFpuRegisters ( uint32_t  value,
uint32_t  fpscr 
)

Checks whether all FPU registers contain given value.

Parameters
[in]valueis the expected value for s0-s31 registers
[in]fpscris the expected value for fpscr register
Returns
true if values of all FPU registers are equal to expected values, false otherwise
Here is the caller graph for this function:

◆ makeQueueWrapper()

template<size_t QueueSize>
QueueWrapperUniquePointer distortos::test::makeQueueWrapper ( const bool  dynamic,
const bool  raw,
const bool  fifo 
)

QueueWrapper's factory function.

Template Parameters
QueueSizeis the maximum number of elements in queue
Parameters
[in]dynamicselects whether static (false) or dynamic (true) queue type will be constructed
[in]rawselects whether non-raw (false) or raw (true) queue type will be constructed
[in]fifoselects whether message (false) or fifo (true) queue type will be constructed
Returns
QueueWrapperUniquePointer with constructed object - {Dynamic,Static}[Raw]{Fifo,Message}QueueWrapper

◆ makeRawQueueWrapper()

template<size_t QueueSize>
RawQueueWrapperUniquePointer distortos::test::makeRawQueueWrapper ( const bool  dynamic,
const bool  fifo 
)

RawQueueWrapper's factory function.

Template Parameters
QueueSizeis the maximum number of elements in queue
Parameters
[in]dynamicselects whether static (false) or dynamic (true) queue type will be constructed
[in]fifoselects whether message (false) or fifo (true) queue type will be constructed
Returns
RawQueueWrapperUniquePointer with constructed object - {Dynamic,Static}Raw{Fifo,Message}QueueWrapper

◆ mutexTestTryLockWhenLocked()

bool distortos::test::mutexTestTryLockWhenLocked ( Mutex mutex,
uint8_t  priority = UINT8_MAX 
)

Tests Mutex::tryLock() when mutex is locked - it must succeed immediately and return EBUSY.

Mutex::tryLock() is called from another thread.

Parameters
[in]mutexis a reference to mutex that will be tested
[in]priorityis the priority of the created thread, default - max
Returns
true if test succeeded, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mutexTestUnlockFromWrongThread()

bool distortos::test::mutexTestUnlockFromWrongThread ( Mutex mutex)

Tests unlocking of ErrorChecking or Recursive mutex from a wrong thread.

Such operation must fail with EPERM immediately.

Parameters
[in]mutexis a reference to mutex that will checked, must be ErrorChecking or Recursive type!
Returns
true if test succeeded, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator!=()

bool distortos::test::operator!= ( const OperationCountingType left,
const OperationCountingType right 
)
inline

Inequality comparison operator for OperationCountingType.

Parameters
[in]leftis a reference to left operand of inequality comparison
[in]rightis a reference to right operand of inequality comparison
Returns
true if operands are not equal, false otherwise

◆ setFpuRegisters()

uint32_t distortos::test::setFpuRegisters ( uint32_t  value,
bool  full 
)

Sets FPU registers (including fpscr) to given value.

Parameters
[in]valueis the value that will be written to FPU registers
[in]fullselects whether all FPU registers will be modified (true) or only s0-s15 and fpscr (false)
Returns
value read from fpscr register (not all fields of this register are writable)
Here is the caller graph for this function:

◆ signalsTestSelfOneSignalPending()

bool distortos::test::signalsTestSelfOneSignalPending ( uint8_t  signalNumber)

Tests whether exactly one signal is pending for current thread.

Parameters
[in]signalNumberis the signal number that may be 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:

◆ waitForNextTick()

void distortos::test::waitForNextTick ( )

Waits for beginning of next tick.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wasteTime() [1/4]

void distortos::test::wasteTime ( TickClock::duration  duration)

Wastes time.

Note
Wasted duration must not be shorter, so one additional tick is always added to the duration.
Parameters
[in]durationis the duration of time to waste
Todo:
implement something more precise and reliable
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wasteTime() [2/4]

void distortos::test::wasteTime ( TickClock::time_point  timePoint)

Wastes time.

Parameters
[in]timePointis the time point at which the function will return
Here is the call graph for this function:

◆ wasteTime() [3/4]

template<typename Rep , typename Period >
void distortos::test::wasteTime ( const std::chrono::duration< Rep, Period >  duration)

Wastes time.

Note
Wasted duration must not be shorter, so one additional tick is always added to the duration.
Template Parameters
Repis type of tick counter
Periodis std::ratio type representing the tick period of the clock, seconds
Parameters
[in]durationis the duration of time to waste
Here is the call graph for this function:

◆ wasteTime() [4/4]

template<typename Duration >
void distortos::test::wasteTime ( const std::chrono::time_point< TickClock, Duration >  timePoint)

Wastes time.

Template Parameters
Durationis a std::chrono::duration type used to measure duration
Parameters
[in]timePointis the time point at which the function will return
Here is the call graph for this function:

Variable Documentation

◆ architectureTestCases

const TestCaseGroup distortos::test::architectureTestCases {TestCaseGroup::Range{threadTestCases_}}

group of architecture-specific test cases

◆ callOnceTestCases

const TestCaseGroup distortos::test::callOnceTestCases {TestCaseGroup::Range{callOnceTestCases_}}

group of test cases related to callOnce()

◆ conditionVariableTestCases

const TestCaseGroup distortos::test::conditionVariableTestCases {TestCaseGroup::Range{conditionVariableTestCases_}}

group of test cases related to condition variables

◆ maxPhasePriority

constexpr uint8_t distortos::test::maxPhasePriority {UINT8_MAX - 1}

max priority used in test phases

◆ mutexTestCases

const TestCaseGroup distortos::test::mutexTestCases {TestCaseGroup::Range{mutexTestCases_}}

group of test cases related to mutexes

◆ priorityTestPhases

const std::array< TestPhase, totalPhases > distortos::test::priorityTestPhases
Initial value:
{{
{uniquePriorities, {0, 1, 2, 3, 4, 5, 6, 7}},
{uniquePriorities, {7, 6, 5, 4, 3, 2, 1, 0}},
{uniquePriorities, {6, 3, 5, 0, 2, 1, 7, 4}},
{nonUniquePriorities, {0, 1, 2, 3, 4, 5, 6, 7}},
{nonUniquePriorities, {4, 5, 6, 7, 0, 1, 2, 3}},
{nonUniquePriorities, {0, 4, 1, 5, 2, 6, 3, 7}},
{nonUniquePriorities, {4, 0, 5, 1, 6, 2, 7, 3}},
{nonUniquePriorities, {4, 5, 6, 0, 1, 7, 2, 3}},
}}
const std::array< ThreadParameters, totalThreads > uniquePriorities
array with unique priorities and expected sequence points
Definition: priorityTestPhases.cpp:29
const std::array< ThreadParameters, totalThreads > nonUniquePriorities
array with non-unique priorities and expected sequence points
Definition: priorityTestPhases.cpp:42

array with test phases

◆ queueTestCases

const TestCaseGroup distortos::test::queueTestCases {TestCaseGroup::Range{queueTestCases_}}

group of test cases related to queue

◆ semaphoreTestCases

const TestCaseGroup distortos::test::semaphoreTestCases {TestCaseGroup::Range{semaphoreTestCases_}}

group of test cases related to semaphores

◆ signalsTestCases

const TestCaseGroup distortos::test::signalsTestCases {TestCaseGroup::Range{messageQueueTestCases_}}

group of test cases related to signals

◆ softwareTimerTestCases

const TestCaseGroup distortos::test::softwareTimerTestCases {TestCaseGroup::Range{softwareTimerTestCases_}}

group of test cases related to software timers

◆ testCases

const TestCaseGroup distortos::test::testCases {TestCaseGroup::Range{testCases_}}

top-level group of test cases

◆ threadTestCases

const TestCaseGroup distortos::test::threadTestCases {TestCaseGroup::Range{threadTestCases_}}

group of test cases related to threads

◆ totalPhases

constexpr size_t distortos::test::totalPhases {8}

number of test phases

◆ totalThreads

constexpr size_t distortos::test::totalThreads {8}

number of test threads