Zephyr API Documentation
2.7.0-rc2
A Scalable Open Source RTOS
|
#include <ztest.h>
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 |
Test Initialization and buffer allocation of pipe, with various parameters.
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.
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 indeces 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
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 indeces 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:
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
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
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 |