#include <zephyr/ztest.h>
#include <zephyr/kernel.h>
#include <zpp/sem.hpp>
#include <zpp/thread.hpp>
#include <zpp/utils.hpp>
Go to the source code of this file.
|
| ZTEST_SUITE (test_zpp_sem, NULL, NULL, NULL, NULL, NULL) |
|
| ZTEST (test_zpp_sem, test_sem_cmp) |
|
| ZTEST (test_zpp_sem, test_sem_try_take) |
|
| ZTEST (test_zpp_sem, test_sem_try_take_fails) |
|
| ZTEST (test_zpp_sem, test_sem_try_take_for_fails) |
|
| ZTEST (test_zpp_sem, test_sem_try_take_ref) |
|
| ZTEST (test_zpp_sem, test_sem_try_take_fails_ref) |
|
| ZTEST (test_zpp_sem, test_sem_try_take_for_fails_ref) |
|
◆ ZTEST() [1/7]
ZTEST |
( |
test_zpp_sem |
, |
|
|
test_sem_cmp |
|
|
) |
| |
Definition at line 27 of file main.cpp.
31 res = simple_sem == simple_ref_sem;
32 zassert_false(res,
"unable to compare sem == sem_ref\n");
34 res = simple_sem != simple_ref_sem;
35 zassert_true(res,
"unable to compare sem != sem_ref\n");
37 res = simple_ref_sem == simple_sem;
38 zassert_false(res,
"unable to compare sem_ref == sem\n");
40 res = simple_ref_sem != simple_sem;
41 zassert_true(res,
"unable to compare sem_ref != sem\n");
43 res = simple_ref_sem == &g_sem;
44 zassert_true(res,
"unable to compare sem_ref == k_sem*\n");
46 res = simple_ref_sem != &g_sem;
47 zassert_false(res,
"unable to compare sem_ref != k_sem*\n");
49 res = simple_sem == &g_sem;
50 zassert_false(res,
"unable to compare sem == k_sem*\n");
52 res = simple_sem != &g_sem;
53 zassert_true(res,
"unable to compare sem != k_sem*\n");
55 res = &g_sem == simple_ref_sem;
56 zassert_true(res,
"unable to compare k_sem* == sem_ref\n");
58 res = &g_sem != simple_ref_sem;
59 zassert_false(res,
"unable to compare k_sem* != sem_ref\n");
61 res = &g_sem == simple_sem;
62 zassert_false(res,
"unable to compare k_sem* == sem\n");
64 res = &g_sem != simple_sem;
65 zassert_true(res,
"unable to compare k_sem* != sem\n");
◆ ZTEST() [2/7]
ZTEST |
( |
test_zpp_sem |
, |
|
|
test_sem_try_take |
|
|
) |
| |
Definition at line 69 of file main.cpp.
73 for (
int i = 0; i < 5; i++) {
76 auto signal_count = simple_sem.count();
77 zassert_true(signal_count == (i + 1),
78 "signal count missmatch Expected %d, got %d\n",
79 (i + 1), signal_count);
82 for (
int i = 4; i >= 0; i--) {
83 auto ret_value = simple_sem.try_take();
84 zassert_true(ret_value ==
true,
85 "unable to do k_sem_take which returned %d\n",
88 auto signal_count = simple_sem.count();
89 zassert_true(signal_count == i,
90 "signal count missmatch Expected %d, got %d\n",
◆ ZTEST() [3/7]
ZTEST |
( |
test_zpp_sem |
, |
|
|
test_sem_try_take_fails |
|
|
) |
| |
Definition at line 95 of file main.cpp.
99 for (
int i = 4; i >= 0; i--) {
100 auto ret_value = simple_sem.try_take();
101 zassert_true(ret_value ==
false,
102 "k_sem_take returned when not possible");
104 auto signal_count = simple_sem.count();
105 zassert_true(signal_count == 0U,
106 "signal count missmatch Expected 0, got %d\n",
◆ ZTEST() [4/7]
ZTEST |
( |
test_zpp_sem |
, |
|
|
test_sem_try_take_fails_ref |
|
|
) |
| |
Definition at line 150 of file main.cpp.
152 simple_ref_sem.reset();
154 for (
int i = 4; i >= 0; i--) {
155 auto ret_value = simple_ref_sem.try_take();
156 zassert_true(ret_value ==
false,
157 "k_sem_take returned when not possible");
159 auto signal_count = simple_ref_sem.count();
160 zassert_true(signal_count == 0U,
161 "signal count missmatch Expected 0, got %d\n",
◆ ZTEST() [5/7]
ZTEST |
( |
test_zpp_sem |
, |
|
|
test_sem_try_take_for_fails |
|
|
) |
| |
Definition at line 111 of file main.cpp.
113 using namespace std::chrono;
117 for (
int i = 4; i >= 0; i--) {
118 auto ret_value = simple_sem.try_take_for(100ms);
119 zassert_true(ret_value ==
false,
120 "k_sem_take succeeded when its not possible");
◆ ZTEST() [6/7]
ZTEST |
( |
test_zpp_sem |
, |
|
|
test_sem_try_take_for_fails_ref |
|
|
) |
| |
Definition at line 166 of file main.cpp.
168 using namespace std::chrono;
170 simple_ref_sem.reset();
172 for (
int i = 4; i >= 0; i--) {
173 auto ret_value = simple_ref_sem.try_take_for(100ms);
174 zassert_true(ret_value ==
false,
175 "k_sem_take succeeded when its not possible");
◆ ZTEST() [7/7]
ZTEST |
( |
test_zpp_sem |
, |
|
|
test_sem_try_take_ref |
|
|
) |
| |
Definition at line 124 of file main.cpp.
126 simple_ref_sem.reset();
128 for (
int i = 0; i < 5; i++) {
131 auto signal_count = simple_ref_sem.count();
132 zassert_true(signal_count == (i + 1),
133 "signal count missmatch Expected %d, got %d\n",
134 (i + 1), signal_count);
137 for (
int i = 4; i >= 0; i--) {
138 auto ret_value = simple_ref_sem.try_take();
139 zassert_true(ret_value ==
true,
140 "unable to do k_sem_take which returned %d\n",
143 auto signal_count = simple_ref_sem.count();
144 zassert_true(signal_count == i,
145 "signal count missmatch Expected %d, got %d\n",
◆ ZTEST_SUITE()
ZTEST_SUITE |
( |
test_zpp_sem |
, |
|
|
NULL |
, |
|
|
NULL |
, |
|
|
NULL |
, |
|
|
NULL |
, |
|
|
NULL |
|
|
) |
| |