Zephyr Project API
3.1.0
A Scalable Open Source RTOS
|
#include <ztest.h>
Functions | |
void | test_pipe_thread2thread (void) |
Test pipe data passing between threads. More... | |
void | test_pipe_put_fail (void) |
Test pipe put failure scenario. More... | |
void | test_pipe_get_fail (void) |
Test pipe get failure scenario. More... | |
void | test_pipe_block_put (void) |
void | test_pipe_block_put_sema (void) |
void | test_pipe_get_put (void) |
void | test_pipe_get_large (void) |
void | test_half_pipe_put_get (void) |
Test put/get with smaller pipe buffer. More... | |
void | test_half_pipe_saturating_block_put (void) |
void | test_half_pipe_block_put_sema (void) |
void | test_pipe_alloc (void) |
Test Initialization and buffer allocation of pipe, with various parameters. More... | |
void | test_pipe_reader_wait (void) |
Test pending reader in pipe. More... | |
void | test_pipe_block_writer_wait (void) |
void | test_pipe_cleanup (void) |
void | test_pipe_user_thread2thread (void) |
Test data passing using pipes between user threads. More... | |
void | test_pipe_user_put_fail (void) |
Test pipe put by a user thread. More... | |
void | test_pipe_user_get_fail (void) |
Test pipe get by a user thread. More... | |
void | test_resource_pool_auto_free (void) |
Test resource pool free. More... | |
void | test_pipe_alloc_not_init (void) |
Test k_pipe_alloc_init() failure scenario. More... | |
void | test_pipe_get_null (void) |
Test k_pipe_get() failure scenario. More... | |
void | test_pipe_get_unreach_data (void) |
Test k_pipe_get() failure scenario. More... | |
void | test_pipe_get_unreach_size (void) |
Test k_pipe_get() failure scenario. More... | |
void | test_pipe_put_null (void) |
Test k_pipe_put() failure scenario. More... | |
void | test_pipe_put_unreach_data (void) |
Test k_pipe_put() failure scenario. More... | |
void | test_pipe_put_unreach_size (void) |
Test k_pipe_put() failure scenario. More... | |
void | test_pipe_read_avail_null (void) |
Test k_pipe_read_avail() failure scenario. More... | |
void | test_pipe_write_avail_null (void) |
Test k_pipe_write_avail() failure scenario. More... | |
void | test_pipe_avail_r_lt_w (void) |
Test available read / write space for r < w. More... | |
void | test_pipe_avail_w_lt_r (void) |
Test available read / write space for w < r. More... | |
void | test_pipe_avail_r_eq_w_full (void) |
Test available read / write space for r == w and a full buffer. More... | |
void | test_pipe_avail_r_eq_w_empty (void) |
Test available read / write space for r == w and an empty buffer. More... | |
void | test_pipe_avail_no_buffer (void) |
Pipes with no buffer or size 0 should return 0 bytes available. More... | |
void | test_main (void) |
Variables | |
struct k_pipe pipe kpipe khalfpipe | put_get_pipe |
struct k_sem | end_sema |
struct k_stack | tstack |
struct k_thread | tdata |
struct k_heap | test_pool |
void test_half_pipe_block_put_sema | ( | void | ) |
void test_half_pipe_saturating_block_put | ( | void | ) |
void test_main | ( | void | ) |
test case main entry
void test_pipe_alloc | ( | void | ) |
Test Initialization and buffer allocation of pipe, with various parameters.
void test_pipe_avail_no_buffer | ( | void | ) |
Pipes with no buffer or size 0 should return 0 bytes available.
Pipes can be created to be bufferless (i.e. k_pipe::buffer is NULL
or k_pipe::size is 0).
If either of those conditions is true, then k_pipe_read_avail and k_pipe_write_avail should return 0.
void test_pipe_avail_r_eq_w_empty | ( | void | ) |
Test available read / write space for r == w
and an empty buffer.
This test case is for buffered k_pipe objects and covers the case where k_pipe::read_index is equal to k_pipe::write_index and k_pipe::bytes_used is zero.
In this case, k_pipe::bytes_used is relevant because the read and write indices are equal.
r w |a|b|c|d|e|f|g|h| |0|1|2|3|4|5|6|7|
Regardless of whether the buffer is full or empty, the following holds:
r_avail = bytes_used w_avail = N - bytes_used
Thus: r_avail = 0 would read:
w_avail = N - 0 = 8 would overwrite: e f g h a b c d
void test_pipe_avail_r_eq_w_full | ( | void | ) |
Test available read / write space for r == w
and a full buffer.
This test case is for buffered k_pipe objects and covers the case where k_pipe::read_index is equal to k_pipe::write_index and k_pipe::bytes_used is equal to k_pipe::size.
In this case, k_pipe::bytes_used is relevant because the read and write indices are equal.
r w |a|b|c|d|e|f|g|h| |0|1|2|3|4|5|6|7|
Regardless of whether the buffer is full or empty, the following holds:
r_avail = bytes_used w_avail = N - bytes_used
Thus r_avail = N = 8 would read: e f g h a b c d
w_avail = N - 8 = 0 would overwrite:
void test_pipe_avail_r_lt_w | ( | void | ) |
Test available read / write space for r < w.
This test case is for buffered k_pipe objects and covers the case where k_pipe::read_index is less than k_pipe::write_index.
In this case, k_pipe::bytes_used is not relevant.
r w |a|b|c|d|e|f|g|h| |0|1|2|3|4|5|6|7|
As shown above, the pipe will be able to read 3 bytes without blocking and write 5 bytes without blocking.
Thus r_avail = w - r = 3 would read: a b c d
w_avail = N - (w - r) = 5 would overwrite: e f g h
void test_pipe_avail_w_lt_r | ( | void | ) |
Test available read / write space for w < r.
This test case is for buffered k_pipe objects and covers the case where k_pipe::write_index is less than k_pipe::read_index.
In this case, k_pipe::bytes_used is not relevant.
w r |a|b|c|d|e|f|g|h| |0|1|2|3|4|5|6|7|
As shown above, the pipe will fbe able to read 5 bytes without blocking and write 3 bytes without blocking.
Thus r_avail = N - (r - w) = 5 would read: e f g h
w_avail = r - w = 3 would overwrite: a b c d
void test_pipe_block_put | ( | void | ) |
void test_pipe_block_put_sema | ( | void | ) |
void test_pipe_block_writer_wait | ( | void | ) |
void test_pipe_cleanup | ( | void | ) |
TESTPOINT: test if a dynamically allocated buffer can be freed
TESTPOINT: nothing to do with k_pipe_cleanup() for static buffer in pipe
|
extern |
|
extern |
|
extern |
|
extern |