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_chain.cpp File Reference
#include <stk_config.h>
#include <stk.h>
#include <assert.h>
#include "stktest_context.h"
Include dependency graph for stktest_chain.cpp:

Go to the source code of this file.

Classes

class  stk::test::chain::TestTask< _AccessMode >
 Chain test task. More...

Namespaces

namespace  stk
 Namespace of STK package.
namespace  stk::test
 Namespace of the test inventory.
namespace  stk::test::chain
 Namespace of Chain test.

Macros

#define _STK_CHAIN_TEST_TASKS_MAX   3
#define _STK_CHAIN_TEST_DELAY_TIME   100

Functions

void STK_ASSERT_HANDLER (const char *message, const char *file, int32_t line)
int main (int argc, char **argv)

Variables

static volatile uint8_t stk::test::chain::g_TaskSwitch = 0
static Kernel< KERNEL_DYNAMIC, 3, SwitchStrategyRoundRobin, PlatformDefaultstk::test::chain::kernel
 Kernel.
static TestTask< ACCESS_PRIVILEGEDstk::test::chain::task1 (0)
 Tasks (threads).
static TestTask< ACCESS_PRIVILEGEDstk::test::chain::task2 (1)
static TestTask< ACCESS_PRIVILEGEDstk::test::chain::task3 (2)
static int64_t stk::test::chain::g_Time [3] = {}
 Execution time of the task.

Macro Definition Documentation

◆ _STK_CHAIN_TEST_DELAY_TIME

#define _STK_CHAIN_TEST_DELAY_TIME   100

Definition at line 22 of file stktest_chain.cpp.

Referenced by main(), and stk::test::chain::TestTask< _AccessMode >::Run().

◆ _STK_CHAIN_TEST_TASKS_MAX

#define _STK_CHAIN_TEST_TASKS_MAX   3

Definition at line 21 of file stktest_chain.cpp.

Referenced by main().

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 86 of file stktest_chain.cpp.

87{
88 (void)argc;
89 (void)argv;
90
92
93 using namespace stk;
94 using namespace stk::test;
95 using namespace stk::test::chain;
96
97 kernel.Initialize();
98 kernel.AddTask(&task1);
99 kernel.Start();
100
101 int32_t result = TestContext::SUCCESS_EXIT_CODE;
102 for (int32_t i = 0; i < _STK_CHAIN_TEST_TASKS_MAX; ++i)
103 {
104 int32_t diff = g_Time[i] - (i * _STK_CHAIN_TEST_DELAY_TIME);
105
106 if (diff < 0)
107 diff = -diff;
108
109 // check if time difference for every task is not more than 15 ms
110 if (diff > 25)
111 {
112 printf("failed time: id=%d diff=%d (>25)\n", (int)i, (int)diff);
114 }
115 }
116
118 return result;
119}
#define _STK_CHAIN_TEST_DELAY_TIME
#define _STK_CHAIN_TEST_TASKS_MAX
Namespace of STK package.
Namespace of the test inventory.
Namespace of Chain test.
static Kernel< KERNEL_DYNAMIC, 3, SwitchStrategyRoundRobin, PlatformDefault > kernel
Kernel.
static TestTask< ACCESS_PRIVILEGED > task1(0)
Tasks (threads).
static int64_t g_Time[3]
Execution time of the task.
static void ShowTestSuitePrologue()
Show text string as prologue before tests start.
@ 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
static void ShowTestSuiteEpilogue(int32_t result)
Show text string as epilogue after tests end.

References _STK_CHAIN_TEST_DELAY_TIME, _STK_CHAIN_TEST_TASKS_MAX, stk::test::TestContext::DEFAULT_FAILURE_EXIT_CODE, stk::test::chain::g_Time, stk::test::chain::kernel, stk::test::TestContext::ShowTestSuiteEpilogue(), stk::test::TestContext::ShowTestSuitePrologue(), stk::test::TestContext::SUCCESS_EXIT_CODE, and stk::test::chain::task1.

Here is the call graph for this function:

◆ STK_ASSERT_HANDLER()

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

Definition at line 19 of file stktest_chain.cpp.

References STK_TEST_DECL_ASSERT.