#include <zephyr/ztest.h>
#include <zephyr/sys/__assert.h>
#include <string.h>
#include <zephyr/kernel.h>
#include <zpp.hpp>
Go to the source code of this file.
|  | 
|  | ZTEST_SUITE (test_zpp_condition_variable, NULL, NULL, NULL, NULL, NULL) | 
|  | 
|  | ZTEST (test_zpp_condition_variable, test_condition_variable_cmp) | 
|  | 
|  | ZTEST (test_zpp_condition_variable, test_condition_variable) | 
|  | 
◆ ZTEST() [1/2]
      
        
          | ZTEST | ( | test_zpp_condition_variable | , | 
        
          |  |  | test_condition_variable |  | 
        
          |  | ) |  |  | 
      
 
Definition at line 66 of file main.cpp.
   69   using namespace std::chrono;
 
   85         auto rc = cv.wait(m, []{
return ready;});
 
   86         __ASSERT_NO_MSG(rc == 
true);
 
   89         print(
"Worker thread is processing data\n");
 
   91         strcat(data, 
" after processing");
 
   95         print(
"Worker thread signals data processing completed\n");
 
   98       auto rc = cv.notify_one();
 
   99       __ASSERT_NO_MSG(rc == 
true);
 
  102     strcpy(data, 
"Example data");
 
  107       print(
"main() signals data ready for processing\n");
 
  109     auto rc = cv.notify_one();
 
  110     __ASSERT_NO_MSG(rc == 
true);
 
  115       rc = cv.wait(m, []{
return processed;});
 
  116       __ASSERT_NO_MSG(rc == 
true);
 
  118     print(
"Back in main(), data = {}\n", data);
 
  121     __ASSERT_NO_MSG(rc == 
true);
 
lock_guard using zpp::mutex as a lock.
Thread creation attributes.
static constexpr thread_prio preempt(int prio) noexcept
Create a preemptive priority value.
The class thread repecents a single Zephyr thread.
void print(const char *fmt, T_Args &&... args) noexcept
simple typesafe print function
 
References zpp::no, zpp::thread_prio::preempt(), and zpp::print().
 
 
◆ ZTEST() [2/2]
      
        
          | ZTEST | ( | test_zpp_condition_variable | , | 
        
          |  |  | test_condition_variable_cmp |  | 
        
          |  | ) |  |  | 
      
 
Definition at line 43 of file main.cpp.
   48   zassert_false(res, 
"unable to compare condition_variable == condition_variable_ref\n");
 
   51   zassert_true(res, 
"unable to compare condition_variable != condition_variable_ref\n");
 
   53   res = cv_ref == &g_condvar;
 
   54   zassert_true(res, 
"unable to compare condition_variable_ref == k_condvar*\n");
 
   56   res = cv_ref != &g_condvar;
 
   57   zassert_false(res, 
"unable to compare condition_variable_ref != k_condvar*\n");
 
   59   res = cv == &g_condvar;
 
   60   zassert_false(res, 
"unable to compare condition_variable == k_condvar*\n");
 
   62   res = cv != &g_condvar;
 
   63   zassert_true(res, 
"unable to compare condition_variable != k_condvar*\n");
 
 
 
 
◆ ZTEST_SUITE()
      
        
          | ZTEST_SUITE | ( | test_zpp_condition_variable | , | 
        
          |  |  | NULL | , | 
        
          |  |  | NULL | , | 
        
          |  |  | NULL | , | 
        
          |  |  | NULL | , | 
        
          |  |  | NULL |  | 
        
          |  | ) |  |  |