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

Go to the source code of this file.

Classes

class  stk::test::hrt::TimeInfo
 Task pass time info. More...
class  stk::test::hrt::TestTask< _AccessMode >
 HRT test task. More...

Namespaces

namespace  stk
 Namespace of STK package.
namespace  stk::test
 Namespace of the test inventory.
namespace  stk::test::hrt
 Namespace of HRT test.

Macros

#define _STK_HRT_TEST_TASKS_MAX   3
#define _STK_HRT_TEST_PERIODICITY   100
#define _STK_HRT_TEST_SLEEP   10
#define _STK_HRT_TEST_ITRS   3
#define TICKS(MS)

Functions

int main (int argc, char **argv)

Variables

 STK_TEST_DECL_ASSERT
static TimeInfo stk::test::hrt::g_Time [3][3] = {}
static Kernel< KERNEL_DYNAMIC|KERNEL_HRT, 3, SwitchStrategyRoundRobin, PlatformDefaultstk::test::hrt::kernel
 Kernel.
static TestTask< ACCESS_PRIVILEGEDstk::test::hrt::task1 (0)
 Tasks (threads).
static TestTask< ACCESS_PRIVILEGEDstk::test::hrt::task2 (1)
static TestTask< ACCESS_PRIVILEGEDstk::test::hrt::task3 (2)

Macro Definition Documentation

◆ _STK_HRT_TEST_ITRS

#define _STK_HRT_TEST_ITRS   3

Definition at line 24 of file stktest_hrt.cpp.

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

◆ _STK_HRT_TEST_PERIODICITY

#define _STK_HRT_TEST_PERIODICITY   100

Definition at line 22 of file stktest_hrt.cpp.

Referenced by main().

◆ _STK_HRT_TEST_SLEEP

#define _STK_HRT_TEST_SLEEP   10

Definition at line 23 of file stktest_hrt.cpp.

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

◆ _STK_HRT_TEST_TASKS_MAX

#define _STK_HRT_TEST_TASKS_MAX   3

Definition at line 21 of file stktest_hrt.cpp.

Referenced by main().

◆ TICKS

#define TICKS ( MS)
Value:
Ticks GetTicksFromMs(int64_t ms, int32_t resolution)
Convert milliseconds to ticks.
Definition stk_helper.h:239
@ PERIODICITY_DEFAULT
Default periodicity (microseconds), 1 millisecond.
Definition stk_common.h:82

Referenced by main().

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 94 of file stktest_hrt.cpp.

95{
96 (void)argc;
97 (void)argv;
98
100
101 using namespace stk;
102 using namespace stk::test;
103 using namespace stk::test::hrt;
104
105 kernel.Initialize();
106
107#define TICKS(MS) GetTicksFromMs((MS), PERIODICITY_DEFAULT)
108
110
113
116
117 kernel.Start();
118
119 int32_t result = TestContext::SUCCESS_EXIT_CODE;
120 for (int32_t t = 0; t < _STK_HRT_TEST_TASKS_MAX; ++t)
121 {
122 for (int32_t i = 0; i < _STK_HRT_TEST_ITRS; ++i)
123 {
125
126 int32_t diff_start = g_Time[t][i].start - expect;
127 if (diff_start < 0)
128 diff_start = -diff_start;
129
130 int32_t diff_sleep = g_Time[t][i].diff - (_STK_HRT_TEST_SLEEP * (t + 1));
131 if (diff_sleep < 0)
132 diff_sleep = -diff_sleep;
133
134 // check if time difference for every task is not more than 3 ms
135 if ((diff_start > 10) || (diff_sleep > 10))
136 {
137 printf("failed time (%d): id=%d diff_start=%d diff_sleep=%d (>10)\n", (int)i,
138 g_Time[t][i].id, (int)diff_start, (int)diff_sleep);
139
141 }
142 }
143 }
144
146 return result;
147}
#define TICKS(MS)
#define _STK_HRT_TEST_SLEEP
#define _STK_HRT_TEST_ITRS
#define _STK_HRT_TEST_TASKS_MAX
#define _STK_HRT_TEST_PERIODICITY
Namespace of STK package.
Namespace of the test inventory.
Namespace of HRT test.
static TestTask< ACCESS_PRIVILEGED > task2(1)
static TestTask< ACCESS_PRIVILEGED > task1(0)
Tasks (threads).
static TimeInfo g_Time[3][3]
static Kernel< KERNEL_DYNAMIC|KERNEL_HRT, 3, SwitchStrategyRoundRobin, PlatformDefault > kernel
Kernel.
static TestTask< ACCESS_PRIVILEGED > task3(2)
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_HRT_TEST_ITRS, _STK_HRT_TEST_PERIODICITY, _STK_HRT_TEST_SLEEP, _STK_HRT_TEST_TASKS_MAX, stk::test::TestContext::DEFAULT_FAILURE_EXIT_CODE, stk::test::hrt::g_Time, stk::test::hrt::kernel, stk::test::TestContext::ShowTestSuiteEpilogue(), stk::test::TestContext::ShowTestSuitePrologue(), stk::test::TestContext::SUCCESS_EXIT_CODE, stk::test::hrt::task1, stk::test::hrt::task2, stk::test::hrt::task3, and TICKS.

Here is the call graph for this function:

Variable Documentation

◆ STK_TEST_DECL_ASSERT

STK_TEST_DECL_ASSERT

Definition at line 19 of file stktest_hrt.cpp.