7 #include <zephyr/ztest.h>
27 ZTEST(zpp_thread_tests, test_thread_creation)
30 using namespace std::chrono;
43 tcb, tstack(), attr, &theap,
44 [&dummy, &done]() noexcept {
45 print(
"Hello from thread tid={}\n",
48 print(
"dummy = {}\n", (
void*)&dummy);
49 print(
"done = {}\n", (
void*)&done);
51 zassert_true(dummy == 42,
"dummy not 42\n");
60 zassert_true(rc ==
true,
"join failed");
65 ZTEST(zpp_thread_tests, test_thread_creation_void)
68 using namespace std::chrono;
80 print(
"Hello from thread tid={}\n",
85 zassert_true(rc ==
true,
"join failed");
90 ZTEST(zpp_thread_tests, test_thread_creation_pointer)
93 using namespace std::chrono;
104 print(
"S() {} {} {}",
108 S(
const S& other) noexcept : a(other.a), b(other.b) {
109 print(
"S(&{} {} {}) {} {} {}",
110 (
void*)&other, other.a, other.b,
114 print(
"~S() {} {} {}",
127 print(
"Hello from thread tid={} s->a={} s->b={}\n",
137 zassert_true(rc ==
true,
"join failed");
139 zassert_true(s.a == 21,
"s.a != 21\n");
140 zassert_true(s.b == 43,
"s.a != 43\n");
146 ZTEST(zpp_thread_tests, test_thread_creation_params)
149 using namespace std::chrono;
160 print(
"S() {} {} {}",
164 S(
const S& other) noexcept : a(other.a), b(other.b) {
165 print(
"S(&{} {} {}) {} {} {}",
166 (
void*)&other, other.a, other.b,
170 print(
"~S() {} {} {}",
185 tcb, tstack(), attr, &theap,
186 [&done](S s,
int a,
int b) noexcept {
187 print(
"Hello from thread tid={} s.a={} s.b={} a={} b={}\n",
201 zassert_true(rc ==
true,
"join failed");
A counting semaphore class.
Thread creation attributes.
thread_data holds the stack and thread control block memory
static constexpr thread_prio preempt(int prio) noexcept
Create a preemptive priority value.
The class thread repecents a single Zephyr thread.
auto join() noexcept
join the thread this object mamages.
auto get_id() noexcept
Get the thread ID of the current thread.
void print(const char *fmt, T_Args &&... args) noexcept
simple typesafe print function
ZTEST(zpp_atomic_tests, test_atomic_bitset)
ZTEST_SUITE(zpp_atomic_tests, NULL, NULL, NULL, NULL, NULL)
#define ZPP_THREAD_STACK_DEFINE(sym, size)