Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
test_pipe.c File Reference
#include <zephyr/ztest.h>

Data Structures

struct  pipe_sequence
 

Macros

#define STACK_SIZE   (512 + CONFIG_TEST_EXTRA_STACK_SIZE)
 
#define PIPE_SIZE   (256)
 
#define TOTAL_ELEMENTS   (sizeof(single_elements) / sizeof(struct pipe_sequence))
 
#define TOTAL_WAIT_ELEMENTS
 
#define TOTAL_TIMEOUT_ELEMENTS
 
#define NO_CONSTRAINT   (0U)
 
#define ATLEAST_1   (1U)
 
#define ALL_BYTES   (sizeof(tx_buffer))
 
#define RETURN_SUCCESS   (0)
 
#define TIMEOUT_VAL   (K_MSEC(10))
 
#define TIMEOUT_200MSEC   (K_MSEC(200))
 

Functions

 K_PIPE_DEFINE (test_pipe, 256, 4)
 Define and initialize test_pipe at compile time.
 
 K_PIPE_DEFINE (small_pipe, 10, 4)
 
 K_THREAD_STACK_DEFINE (stack_1,(512+CONFIG_TEST_EXTRA_STACK_SIZE))
 
 K_SEM_DEFINE (get_sem, 0, 1)
 
 K_SEM_DEFINE (put_sem, 1, 1)
 
 K_SEM_DEFINE (sync_sem, 0, 1)
 
 K_SEM_DEFINE (multiple_send_sem, 0, 1)
 
uint32_t rx_buffer_check (char *buffer, uint32_t size)
 
void pipe_put_single (void)
 
void pipe_get_single (void *p1, void *p2, void *p3)
 
void pipe_put_multiple (void)
 
void pipe_get_multiple (void *p1, void *p2, void *p3)
 
void pipe_put_forever_wait (void)
 
void pipe_get_forever_wait (void *pi, void *p2, void *p3)
 
void pipe_put_timeout (void)
 
void pipe_get_timeout (void *pi, void *p2, void *p3)
 
void pipe_get_on_empty_pipe (void)
 
void pipe_put_forever_timeout (void)
 
void pipe_get_forever_timeout (void *p1, void *p2, void *p3)
 
void pipe_put_get_timeout (void)
 
void k_sys_fatal_error_handler (unsigned int reason, const struct arch_esf *pEsf)
 Fatal error policy handler.
 
 ZTEST_USER (pipe, test_pipe_on_single_elements)
 Verify pipe with 1 element insert.
 
 ZTEST_USER (pipe, test_pipe_on_multiple_elements)
 Test when multiple items are present in the pipe.
 
 ZTEST_USER (pipe, test_pipe_forever_wait)
 Test when multiple items are present with wait.
 
 ZTEST_USER (pipe, test_pipe_timeout)
 Test pipes with timeout.
 
 ZTEST_USER (pipe, test_pipe_get_on_empty_pipe)
 Test pipe get from a empty pipe.
 
 ZTEST_USER (pipe, test_pipe_forever_timeout)
 Test the pipe_get with K_FOREVER as timeout.
 
 ZTEST_USER (pipe, test_pipe_get_timeout)
 k_pipe_get timeout test
 
 ZTEST_USER (pipe, test_pipe_get_invalid_size)
 Test pipe get of invalid size.
 
 ZTEST_USER (pipe, test_pipe_get_min_xfer)
 Test pipe get returns immediately if >= min_xfer is available.
 
 ZTEST_USER (pipe, test_pipe_put_min_xfer)
 Test pipe put returns immediately if >= min_xfer is available.
 
 ZTEST (pipe, test_pipe_define_at_runtime)
 Test defining and initializing pipes at run time.
 
void test_pipe_flush_helper (void *p1, void *p2, void *p3)
 Helper thread to test k_pipe_flush() and k_pipe_buffer_flush()
 
 ZTEST (pipe, test_pipe_flush)
 Test flushing a pipe.
 

Variables

ZTEST_BMEM uint8_t tx_buffer [(256)+1]
 
ZTEST_BMEM uint8_t rx_buffer [(256)+1]
 
static const struct pipe_sequence single_elements []
 
static const struct pipe_sequence multiple_elements []
 
static const struct pipe_sequence wait_elements []
 
static const struct pipe_sequence timeout_elements []
 
struct k_thread get_single_tid
 
ZTEST_BMEM bool valid_fault
 

Macro Definition Documentation

◆ ALL_BYTES

#define ALL_BYTES   (sizeof(tx_buffer))

◆ ATLEAST_1

#define ATLEAST_1   (1U)

◆ NO_CONSTRAINT

#define NO_CONSTRAINT   (0U)

◆ PIPE_SIZE

#define PIPE_SIZE   (256)

◆ RETURN_SUCCESS

#define RETURN_SUCCESS   (0)

◆ STACK_SIZE

#define STACK_SIZE   (512 + CONFIG_TEST_EXTRA_STACK_SIZE)

◆ TIMEOUT_200MSEC

#define TIMEOUT_200MSEC   (K_MSEC(200))

◆ TIMEOUT_VAL

#define TIMEOUT_VAL   (K_MSEC(10))

◆ TOTAL_ELEMENTS

#define TOTAL_ELEMENTS   (sizeof(single_elements) / sizeof(struct pipe_sequence))

◆ TOTAL_TIMEOUT_ELEMENTS

#define TOTAL_TIMEOUT_ELEMENTS
Value:
(sizeof(timeout_elements) / \
sizeof(struct pipe_sequence))
Definition test_pipe.c:50
static const struct pipe_sequence timeout_elements[]
Definition test_pipe.c:105

◆ TOTAL_WAIT_ELEMENTS

#define TOTAL_WAIT_ELEMENTS
Value:
(sizeof(wait_elements) / \
sizeof(struct pipe_sequence))
static const struct pipe_sequence wait_elements[]
Definition test_pipe.c:96

Function Documentation

◆ K_PIPE_DEFINE() [1/2]

K_PIPE_DEFINE ( small_pipe  ,
10  ,
 
)

◆ K_PIPE_DEFINE() [2/2]

K_PIPE_DEFINE ( test_pipe  ,
256  ,
 
)

Define and initialize test_pipe at compile time.

◆ K_SEM_DEFINE() [1/4]

K_SEM_DEFINE ( get_sem  ,
,
 
)

◆ K_SEM_DEFINE() [2/4]

K_SEM_DEFINE ( multiple_send_sem  ,
,
 
)

◆ K_SEM_DEFINE() [3/4]

K_SEM_DEFINE ( put_sem  ,
,
 
)

◆ K_SEM_DEFINE() [4/4]

K_SEM_DEFINE ( sync_sem  ,
,
 
)

◆ K_THREAD_STACK_DEFINE()

K_THREAD_STACK_DEFINE ( stack_1  ,
(512+CONFIG_TEST_EXTRA_STACK_SIZE)   
)

◆ pipe_get_forever_timeout()

void pipe_get_forever_timeout ( void *  p1,
void *  p2,
void *  p3 
)

◆ pipe_get_forever_wait()

void pipe_get_forever_wait ( void *  pi,
void *  p2,
void *  p3 
)

◆ pipe_get_multiple()

void pipe_get_multiple ( void *  p1,
void *  p2,
void *  p3 
)

◆ pipe_get_on_empty_pipe()

void pipe_get_on_empty_pipe ( void  )

◆ pipe_get_single()

void pipe_get_single ( void *  p1,
void *  p2,
void *  p3 
)

◆ pipe_get_timeout()

void pipe_get_timeout ( void *  pi,
void *  p2,
void *  p3 
)

◆ pipe_put_forever_timeout()

void pipe_put_forever_timeout ( void  )

◆ pipe_put_forever_wait()

void pipe_put_forever_wait ( void  )

◆ pipe_put_get_timeout()

void pipe_put_get_timeout ( void  )

◆ pipe_put_multiple()

void pipe_put_multiple ( void  )

◆ pipe_put_single()

void pipe_put_single ( void  )

◆ pipe_put_timeout()

void pipe_put_timeout ( void  )

◆ rx_buffer_check()

uint32_t rx_buffer_check ( char *  buffer,
uint32_t  size 
)

◆ test_pipe_flush_helper()

void test_pipe_flush_helper ( void *  p1,
void *  p2,
void *  p3 
)

Helper thread to test k_pipe_flush() and k_pipe_buffer_flush()

This helper thread attempts to write 50 bytes to the pipe identified by [p1], which has an internal buffer size of 10. This helper thread is expected to fill the internal buffer, and then block until it can complete the write.

Variable Documentation

◆ get_single_tid

struct k_thread get_single_tid

◆ multiple_elements

const struct pipe_sequence multiple_elements[]
static
Initial value:
= {
{ (256) / 3, (sizeof(tx_buffer)) , (256) / 3, (0) , },
{ (256) / 3, (sizeof(tx_buffer)) , (256) / 3, (0) , },
{ (256) / 3, (sizeof(tx_buffer)) , (256) / 3, (0) , },
{ (256) / 3, (sizeof(tx_buffer)) , 0, -EIO },
{ (256) / 3, (1U) , (256) / 3, (0) },
{ (256) / 3, (1U) , (256) / 3, (0) },
{ (256) / 3, (1U) , (256) / 3, (0) },
{ (256) / 3, (1U) , 1, (0) },
{ (256) / 3, (1U) , 0, -EIO },
{ (256) / 3, (0U) , (256) / 3, (0) },
{ (256) / 3, (0U) , (256) / 3, (0) },
{ (256) / 3, (0U) , (256) / 3, (0) },
{ (256) / 3, (0U) , 1, (0) },
{ (256) / 3, (0U) , 0, (0) }
}
#define EIO
I/O error.
Definition errno.h:43
ZTEST_BMEM uint8_t tx_buffer[(256)+1]
Definition test_pipe.c:26

◆ rx_buffer

ZTEST_BMEM uint8_t rx_buffer[(256)+1]

◆ single_elements

const struct pipe_sequence single_elements[]
static
Initial value:
= {
{ 0, (sizeof(tx_buffer)) , 0, 0 },
{ 1, (sizeof(tx_buffer)) , 1, (0) },
{ (256) - 1, (sizeof(tx_buffer)) , (256) - 1, (0) },
{ (256) , (sizeof(tx_buffer)) , (256) , (0) },
{ (256) + 1, (sizeof(tx_buffer)) , 0, -EIO },
{ 1, (1U) , 1, (0) },
{ (256) - 1, (1U) , (256) - 1, (0) },
{ (256) , (1U) , (256) , (0) },
{ (256) + 1, (1U) , (256) , (0) },
{ 0, (0U) , 0, 0 },
{ 1, (0U) , 1, (0) },
{ (256) - 1, (0U) , (256) - 1, (0) },
{ (256) , (0U) , (256) , (0) },
{ (256) + 1, (0U) , (256) , (0) }
}

◆ timeout_elements

const struct pipe_sequence timeout_elements[]
static
Initial value:
= {
{ 0, (sizeof(tx_buffer)) , 0, 0 },
{ 1, (sizeof(tx_buffer)) , 0, -EAGAIN },
{ (256) - 1, (sizeof(tx_buffer)) , 0, -EAGAIN },
{ (256) , (sizeof(tx_buffer)) , 0, -EAGAIN },
{ (256) + 1, (sizeof(tx_buffer)) , 0, -EAGAIN },
{ 1, (1U) , 0, -EAGAIN },
{ (256) - 1, (1U) , 0, -EAGAIN },
{ (256) , (1U) , 0, -EAGAIN },
{ (256) + 1, (1U) , 0, -EAGAIN }
}
#define EAGAIN
No more contexts.
Definition errno.h:49

◆ tx_buffer

ZTEST_BMEM uint8_t tx_buffer[(256)+1]

◆ valid_fault

ZTEST_BMEM bool valid_fault

◆ wait_elements

const struct pipe_sequence wait_elements[]
static
Initial value:
= {
{ 1, (sizeof(tx_buffer)) , 1, (0) },
{ (256) - 1, (sizeof(tx_buffer)) , (256) - 1, (0) },
{ (256) , (sizeof(tx_buffer)) , (256) , (0) },
{ (256) + 1, (sizeof(tx_buffer)) , (256) + 1, (0) },
{ (256) - 1, (1U) , (256) - 1, (0) },
}