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
stktest.cpp File Reference
#include "stktest.h"
#include <CppUTest/CommandLineTestRunner.h>
Include dependency graph for stktest.cpp:

Go to the source code of this file.

Functions

void STK_ASSERT_HANDLER (const char *message, const char *file, int32_t line)
void STK_PANIC_HANDLER_DEFAULT (EKernelPanicId id)
 Default panic handler: disable interrupts, record the id, and spin in a tight loop — a defined, detectable safe state.
int main (int argc, char **argv)

Variables

void(* g_RelaxCpuHandler )() = NULL
 __stk_relax_cpu handler.
uintptr_t g_Tls = 0

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 108 of file stktest.cpp.

109{
110 (void)argc;
111 (void)argv;
112
114
115 int32_t result = RUN_ALL_TESTS(argc, argv);
116
118
119 return result;
120}
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.

References stk::test::TestContext::ShowTestSuiteEpilogue(), and stk::test::TestContext::ShowTestSuitePrologue().

Here is the call graph for this function:

◆ STK_ASSERT_HANDLER()

void STK_ASSERT_HANDLER ( const char * message,
const char * file,
int32_t line )

Definition at line 27 of file stktest.cpp.

28{
29 if (g_TestContext.IsExpectingAssert())
30 {
31 #if CPPUTEST_HAVE_EXCEPTIONS
32 if (g_TestContext.IsRethrowingAssertException())
33 throw TestAssertPassed();
34 else
35 return;
36 #else
37 return;
38 #endif
39 }
40
41 SimpleString what = "Assertion failed!\n";
42 what += "\twhat: ";
43 what += message;
44 what += "\n\tfile: ";
45 what += file;
46 what += "\n\tline: ";
47 what += StringFrom(line);
48
49 CHECK_TEXT(false, what.asCharString());
50}
TestContext g_TestContext
Global instance of the TestContext.
Definition stktest.cpp:16
Throwable class for catching assertions from STK_ASSERT_HANDLER().
Definition stktest.h:67

References stk::test::g_TestContext.

◆ STK_PANIC_HANDLER_DEFAULT()

void STK_PANIC_HANDLER_DEFAULT ( stk::EKernelPanicId id)

Default panic handler: disable interrupts, record the id, and spin in a tight loop — a defined, detectable safe state.

Note
On a system with a watchdog enabled this will trigger a watchdog reset after the watchdog period, which is the desired behaviour.
Replace with a platform-specific handler (e.g. one that writes a fault log to non-volatile memory and calls NVIC_SystemReset()) by defining STK_PANIC_HANDLER in stk_config.h.

Definition at line 55 of file stktest.cpp.

56{
57 g_PanicValue = id;
58
59 if (g_TestContext.IsExpectingPanic())
60 return;
61
62 SimpleString what = "Kernel panic!\n";
63 what += "\n\tid: ";
64 what += StringFrom(id);
65
66 CHECK_TEXT(false, what.asCharString());
67}
EKernelPanicId g_PanicValue
Panic value.
Definition stktest.cpp:20

References stk::test::g_PanicValue, and stk::test::g_TestContext.

Variable Documentation

◆ g_RelaxCpuHandler

◆ g_Tls

uintptr_t g_Tls = 0

Definition at line 22 of file stktest.cpp.