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

Go to the source code of this file.

Classes

class  stk::test::sleep::TestTask< _AccessMode >
 Sleep test task. More...

Namespaces

namespace  stk
 Namespace of STK package.
namespace  stk::test
 Namespace of the test inventory.
namespace  stk::test::sleep
 Namespace of Sleep test.

Macros

#define _STK_SLEEP_TEST_TASKS_MAX   3
#define _STK_SLEEP_TEST_SLEEP_TIME   100

Functions

int main (int argc, char **argv)

Variables

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

Macro Definition Documentation

◆ _STK_SLEEP_TEST_SLEEP_TIME

#define _STK_SLEEP_TEST_SLEEP_TIME   100

Definition at line 22 of file stktest_sleep.cpp.

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

◆ _STK_SLEEP_TEST_TASKS_MAX

#define _STK_SLEEP_TEST_TASKS_MAX   3

Definition at line 21 of file stktest_sleep.cpp.

Referenced by main().

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 79 of file stktest_sleep.cpp.

80{
81 (void)argc;
82 (void)argv;
83
85
86 using namespace stk;
87 using namespace stk::test;
88 using namespace stk::test::sleep;
89
90 kernel.Initialize();
91
92 kernel.AddTask(&task1);
93 kernel.AddTask(&task2);
94 kernel.AddTask(&task3);
95
96 kernel.Start();
97
98 int32_t result = TestContext::SUCCESS_EXIT_CODE;
99 for (int32_t i = 0; i < _STK_SLEEP_TEST_TASKS_MAX; ++i)
100 {
101 int32_t diff = g_Time[i] - ((i + 1) * _STK_SLEEP_TEST_SLEEP_TIME);
102
103 if (diff < 0)
104 diff = -diff;
105
106 // check if time difference for every task is not more than 15 ms
107 if (diff > 20)
108 {
109 printf("failed time: id=%d diff=%d (>20)\n", (int)i, (int)diff);
111 }
112 }
113
115 return result;
116}
#define _STK_SLEEP_TEST_TASKS_MAX
#define _STK_SLEEP_TEST_SLEEP_TIME
Namespace of STK package.
Namespace of the test inventory.
Namespace of Sleep test.
static Kernel< KERNEL_DYNAMIC, 3, SwitchStrategyRoundRobin, PlatformDefault > kernel
Kernel.
static TestTask< ACCESS_PRIVILEGED > task2(1)
static TestTask< ACCESS_PRIVILEGED > task3(2)
static int32_t g_Time[3]
static TestTask< ACCESS_PRIVILEGED > task1(0)
Tasks (threads).
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_SLEEP_TEST_SLEEP_TIME, _STK_SLEEP_TEST_TASKS_MAX, stk::test::TestContext::DEFAULT_FAILURE_EXIT_CODE, stk::test::sleep::g_Time, stk::test::sleep::kernel, stk::test::TestContext::ShowTestSuiteEpilogue(), stk::test::TestContext::ShowTestSuitePrologue(), stk::test::TestContext::SUCCESS_EXIT_CODE, stk::test::sleep::task1, stk::test::sleep::task2, and stk::test::sleep::task3.

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_sleep.cpp.