#include <zephyr/ztest.h>
#include <zephyr/kernel.h>
#include <zpp/mutex.hpp>
#include <zpp/thread.hpp>
#include <zpp/lock_guard.hpp>
#include <zpp/utils.hpp>
Go to the source code of this file.
|
| ZTEST_SUITE (test_zpp_mutex, NULL, NULL, NULL, NULL, NULL) |
|
| ZTEST (test_zpp_mutex, test_mutex_cmp) |
|
| ZTEST (test_zpp_mutex, test_mutex) |
|
| ZTEST (test_zpp_mutex, test_mutex_ref) |
|
| ZTEST (test_zpp_mutex, test_lock_guard) |
|
◆ ZTEST() [1/4]
ZTEST |
( |
test_zpp_mutex |
, |
|
|
test_lock_guard |
|
|
) |
| |
Definition at line 93 of file main.cpp.
lock_guard using zpp::mutex as a lock.
◆ ZTEST() [2/4]
ZTEST |
( |
test_zpp_mutex |
, |
|
|
test_mutex |
|
|
) |
| |
Definition at line 71 of file main.cpp.
75 zassert_true(!!rc,
"Failed to lock mutex: %d\n", rc.error());
79 zassert_true(!!rc,
"Failed to unlock mutex: %d\n", rc.error());
◆ ZTEST() [3/4]
ZTEST |
( |
test_zpp_mutex |
, |
|
|
test_mutex_cmp |
|
|
) |
| |
Definition at line 29 of file main.cpp.
34 zassert_false(res,
"unable to compare mutex == mutex_ref\n");
37 zassert_true(res,
"unable to compare mutex != mutex_ref\n");
40 zassert_false(res,
"unable to compare mutex_ref == mutex\n");
43 zassert_true(res,
"unable to compare mutex_ref != mutex\n");
45 res = m_ref == &g_mutex;
46 zassert_true(res,
"unable to compare mutex_ref == k_condvar*\n");
48 res = m_ref != &g_mutex;
49 zassert_false(res,
"unable to compare mutex_ref != k_condvar*\n");
52 zassert_false(res,
"unable to compare mutex == k_condvar*\n");
55 zassert_true(res,
"unable to compare mutex != k_mutex*\n");
57 res = &g_mutex == m_ref;
58 zassert_true(res,
"unable to compare k_condvar* == mutex_ref\n");
60 res = &g_mutex != m_ref;
61 zassert_false(res,
"unable to compare k_condvar* != mutex_ref\n");
64 zassert_false(res,
"unable to compare mutex == k_condvar* == mutex\n");
67 zassert_true(res,
"unable to compare k_mutex* != mutex\n");
◆ ZTEST() [4/4]
ZTEST |
( |
test_zpp_mutex |
, |
|
|
test_mutex_ref |
|
|
) |
| |
Definition at line 82 of file main.cpp.
84 auto rc = m_ref.lock();
86 zassert_true(!!rc,
"Failed to lock mutex_ref: %d\n", rc.error());
90 zassert_true(!!rc,
"Failed to unlock mutex_ref: %d\n", rc.error());
◆ ZTEST_SUITE()
ZTEST_SUITE |
( |
test_zpp_mutex |
, |
|
|
NULL |
, |
|
|
NULL |
, |
|
|
NULL |
, |
|
|
NULL |
, |
|
|
NULL |
|
|
) |
| |