SuperTinyKernel™ RTOS 1.05.3
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
stk::test::TestContext Class Reference

Common context for a test suite. More...

#include <stktest_context.h>

Collaboration diagram for stk::test::TestContext:

Public Types

enum  EConsts {
  SUCCESS_EXIT_CODE = 0 ,
  DEFAULT_FAILURE_EXIT_CODE = 1
}

Public Member Functions

 TestContext ()
void ExpectAssert (bool expect)
 Start expecting assertion for the test case.
bool IsExpectingAssert () const
 Check if test case is expecting assertion.
void ExpectPanic (bool expect)
 Start expecting kernel panic for the test case.
bool IsExpectingPanic () const
 Check if test case is expecting kernel panic.
void RethrowAssertException (bool rethrow)
 Re-throw assert's exception for the test case.
bool IsRethrowingAssertException () const
 Check if exception must be thrown if assertion is hit.

Static Public Member Functions

static void ShowTestSuitePrologue ()
 Show text string as prologue before tests start.
static void ShowTestSuiteEpilogue (int32_t result)
 Show text string as epilogue after tests end.
static void ForceExitTestSuite (int32_t result)
 Exit test suite process forcibly.

Private Attributes

bool m_expect_assert
 assert expectation flag
bool m_expect_panic
 panic expectation flag
bool m_rethrow_assert
 rethrow assert's exception

Static Private Attributes

static TestContext m_instance
 global instance of the TestContext

Detailed Description

Common context for a test suite.

Definition at line 24 of file stktest_context.h.

Member Enumeration Documentation

◆ EConsts

Enumerator
SUCCESS_EXIT_CODE 

exit code for exit() to denote the success of the test

DEFAULT_FAILURE_EXIT_CODE 

default exit code for exit() to denote failure of the test

Definition at line 27 of file stktest_context.h.

28 {
31 };
@ DEFAULT_FAILURE_EXIT_CODE
default exit code for exit() to denote failure of the test
@ SUCCESS_EXIT_CODE
exit code for exit() to denote the success of the test

Constructor & Destructor Documentation

◆ TestContext()

stk::test::TestContext::TestContext ( )
inlineexplicit

Definition at line 33 of file stktest_context.h.

33 : m_expect_assert(false), m_expect_panic(false), m_rethrow_assert(true)
34 {}
bool m_rethrow_assert
rethrow assert's exception
bool m_expect_assert
assert expectation flag
bool m_expect_panic
panic expectation flag

References m_expect_assert, m_expect_panic, and m_rethrow_assert.

Member Function Documentation

◆ ExpectAssert()

void stk::test::TestContext::ExpectAssert ( bool expect)
inline

Start expecting assertion for the test case.

Parameters
[in]expectTrue to expect otherwise False.

Definition at line 39 of file stktest_context.h.

39{ m_expect_assert = expect; }

References m_expect_assert.

◆ ExpectPanic()

void stk::test::TestContext::ExpectPanic ( bool expect)
inline

Start expecting kernel panic for the test case.

Parameters
[in]expectTrue to expect otherwise False.

Definition at line 48 of file stktest_context.h.

48{ m_expect_panic = expect; }

References m_expect_panic.

◆ ForceExitTestSuite()

void stk::test::TestContext::ForceExitTestSuite ( int32_t result)
inlinestatic

Exit test suite process forcibly.

Parameters
[in]result0 if no tests are failed otherwise number of failed tests.

Definition at line 86 of file stktest_context.h.

87 {
89 exit(result);
90 }
static void ShowTestSuiteEpilogue(int32_t result)
Show text string as epilogue after tests end.

References ShowTestSuiteEpilogue().

Referenced by stk::test::switch_::TestTask< _AccessMode >::Run().

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

◆ IsExpectingAssert()

bool stk::test::TestContext::IsExpectingAssert ( ) const
inline

Check if test case is expecting assertion.

Definition at line 43 of file stktest_context.h.

43{ return m_expect_assert; }

References m_expect_assert.

◆ IsExpectingPanic()

bool stk::test::TestContext::IsExpectingPanic ( ) const
inline

Check if test case is expecting kernel panic.

Definition at line 52 of file stktest_context.h.

52{ return m_expect_panic; }

References m_expect_panic.

◆ IsRethrowingAssertException()

bool stk::test::TestContext::IsRethrowingAssertException ( ) const
inline

Check if exception must be thrown if assertion is hit.

Definition at line 61 of file stktest_context.h.

61{ return m_rethrow_assert; }

References m_rethrow_assert.

◆ RethrowAssertException()

void stk::test::TestContext::RethrowAssertException ( bool rethrow)
inline

Re-throw assert's exception for the test case.

Parameters
[in]expectTrue to rethrow otherwise False.

Definition at line 57 of file stktest_context.h.

57{ m_rethrow_assert = rethrow; }

References m_rethrow_assert.

◆ ShowTestSuiteEpilogue()

void stk::test::TestContext::ShowTestSuiteEpilogue ( int32_t result)
inlinestatic

Show text string as epilogue after tests end.

Parameters
[in]result0 if no tests are failed otherwise number of failed tests.

Definition at line 78 of file stktest_context.h.

79 {
80 printf("STKTEST-RESULT: %d\n", (int)result);
81 }

Referenced by ForceExitTestSuite(), and main().

Here is the caller graph for this function:

◆ ShowTestSuitePrologue()

void stk::test::TestContext::ShowTestSuitePrologue ( )
inlinestatic

Show text string as prologue before tests start.

Definition at line 65 of file stktest_context.h.

66 {
67 // required to show log in Eclipse IDE Console for 64-bit binary
68 #if defined(_WIN32) || defined(WIN32)
69 setbuf(stdout, NULL);
70 #endif
71
72 printf("STKTEST-START\n");
73 }

Referenced by main().

Here is the caller graph for this function:

Member Data Documentation

◆ m_expect_assert

bool stk::test::TestContext::m_expect_assert
private

assert expectation flag

Definition at line 94 of file stktest_context.h.

Referenced by ExpectAssert(), IsExpectingAssert(), and TestContext().

◆ m_expect_panic

bool stk::test::TestContext::m_expect_panic
private

panic expectation flag

Definition at line 95 of file stktest_context.h.

Referenced by ExpectPanic(), IsExpectingPanic(), and TestContext().

◆ m_instance

TestContext stk::test::TestContext::m_instance
staticprivate

global instance of the TestContext

Definition at line 93 of file stktest_context.h.

◆ m_rethrow_assert

bool stk::test::TestContext::m_rethrow_assert
private

rethrow assert's exception

Definition at line 96 of file stktest_context.h.

Referenced by IsRethrowingAssertException(), RethrowAssertException(), and TestContext().


The documentation for this class was generated from the following file: