Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS

Functions

void test_pipe_on_single_elements (void)
 Verify pipe with 1 element insert. More...
 
void test_pipe_on_multiple_elements (void)
 Test when multiple items are present in the pipe. More...
 
void test_pipe_forever_wait (void)
 Test when multiple items are present with wait. More...
 
void test_pipe_timeout (void)
 Test pipes with timeout. More...
 
void test_pipe_get_on_empty_pipe (void)
 Test pipe get from a empty pipe. More...
 
void test_pipe_forever_timeout (void)
 Test the pipe_get with K_FOREVER as timeout. More...
 
void test_pipe_get_timeout (void)
 k_pipe_get timeout test More...
 
void test_pipe_get_invalid_size (void)
 Test pipe get of invalid size. More...
 
void test_pipe_get_min_xfer (void)
 Test pipe get returns immediately if >= min_xfer is available. More...
 
void test_pipe_put_min_xfer (void)
 Test pipe put returns immediately if >= min_xfer is available. More...
 
void test_pipe_define_at_runtime (void)
 Test defining and initializing pipes at run time. More...
 
void test_pipe_thread2thread (void)
 Test pipe data passing between threads. More...
 
void test_pipe_user_thread2thread (void)
 Test data passing using pipes between user threads. More...
 
void test_resource_pool_auto_free (void)
 Test resource pool free. More...
 
static void tThread_half_pipe_put (void *p1, void *p2, void *p3)
 
static void tThread_half_pipe_get (void *p1, void *p2, void *p3)
 
void test_half_pipe_put_get (void)
 Test put/get with smaller pipe buffer. More...
 
void test_pipe_get_put (void)
 
void test_pipe_get_large (void)
 
void test_pipe_reader_wait (void)
 Test pending reader in pipe. More...
 
void test_pipe_put_fail (void)
 Test pipe put failure scenario. More...
 
void test_pipe_user_put_fail (void)
 Test pipe put by a user thread. More...
 
void test_pipe_get_fail (void)
 Test pipe get failure scenario. More...
 
void test_pipe_user_get_fail (void)
 Test pipe get by a user thread. 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...
 
static ZTEST_DMEM unsigned char data [] = "abcdefgh"
 Tests for the Pipe read / write availability. More...
 
static struct k_pipe pipe
 
static struct k_pipe bufferless
 
static struct k_pipe bufferless1
 
void test_pipe_avail_no_buffer (void)
 Pipes with no buffer or size 0 should return 0 bytes available. 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_empty (void)
 Test available read / write space for r == w and an empty buffer. More...
 
void test_pipe_avail_r_eq_w_full (void)
 Test available read / write space for r == w and a full buffer. More...
 

Detailed Description

Function Documentation

◆ test_half_pipe_put_get()

void test_half_pipe_put_get ( void  )

#include <tests/kernel/pipe/pipe_api/src/test_pipe_contexts.c>

Test put/get with smaller pipe buffer.

See also
k_pipe_put(), k_pipe_get()

TESTPOINT: thread-thread data passing via pipe

◆ test_pipe_alloc_not_init()

void test_pipe_alloc_not_init ( void  )

#include <tests/kernel/pipe/pipe_api/src/test_pipe_fail.c>

Test k_pipe_alloc_init() failure scenario.

See what will happen if an uninitialized k_pipe is passed to k_pipe_alloc_init().

See also
k_pipe_alloc_init()

◆ test_pipe_avail_no_buffer()

void test_pipe_avail_no_buffer ( void  )

#include <tests/kernel/pipe/pipe_api/src/test_pipe_avail.c>

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.

Note
A distinction can be made between buffered and bufferless pipes in that k_pipe_read_avail and k_pipe_write_avail will never simultaneously return 0 for a buffered pipe, but they will both return 0 for an unbuffered pipe.

◆ test_pipe_avail_r_eq_w_empty()

void test_pipe_avail_r_eq_w_empty ( void  )

#include <tests/kernel/pipe/pipe_api/src/test_pipe_avail.c>

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_pipe_avail_r_eq_w_full()

void test_pipe_avail_r_eq_w_full ( void  )

#include <tests/kernel/pipe/pipe_api/src/test_pipe_avail.c>

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_pipe_avail_r_lt_w()

void test_pipe_avail_r_lt_w ( void  )

#include <tests/kernel/pipe/pipe_api/src/test_pipe_avail.c>

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_pipe_avail_w_lt_r()

void test_pipe_avail_w_lt_r ( void  )

#include <tests/kernel/pipe/pipe_api/src/test_pipe_avail.c>

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

◆ test_pipe_define_at_runtime()

void test_pipe_define_at_runtime ( void  )

#include <tests/kernel/pipe/pipe/src/test_pipe.c>

Test defining and initializing pipes at run time.

Test Objective:

  • Check if the kernel provided a mechanism for defining and initializing pipes at run time.

Testing techniques:

  • function and block box testing,Interface testing, Dynamic analysis and testing.

Prerequisite Conditions:

  • CONFIG_TEST_USERSPACE.

Input Specifications:

  • N/A

Test Procedure:

  1. Define and initialize a pipe at run time
  2. Using this pipe to transfer data.
  3. Check the pipe get/put operation.

Expected Test Result:

  • Pipe can be defined and initialized at run time.

Pass/Fail Criteria:

  • Successful if check points in test procedure are all passed, otherwise failure.

Assumptions and Constraints:

  • N/A
See also
k_pipe_init()

◆ test_pipe_forever_timeout()

void test_pipe_forever_timeout ( void  )

#include <tests/kernel/pipe/pipe/src/test_pipe.c>

Test the pipe_get with K_FOREVER as timeout.

Testcase is similar to test_pipe_on_single_elements() but with K_FOREVER as timeout.

See also
k_pipe_put()

◆ test_pipe_forever_wait()

void test_pipe_forever_wait ( void  )

#include <tests/kernel/pipe/pipe/src/test_pipe.c>

Test when multiple items are present with wait.

See also
k_pipe_put()

◆ test_pipe_get_fail()

void test_pipe_get_fail ( void  )

#include <tests/kernel/pipe/pipe_api/src/test_pipe_fail.c>

Test pipe get failure scenario.

See also
k_pipe_init(), k_pipe_get()

◆ test_pipe_get_invalid_size()

void test_pipe_get_invalid_size ( void  )

#include <tests/kernel/pipe/pipe/src/test_pipe.c>

Test pipe get of invalid size.

See also
k_pipe_get()

◆ test_pipe_get_large()

void test_pipe_get_large ( void  )

#include <tests/kernel/pipe/pipe_api/src/test_pipe_contexts.c>

TESTPOINT: thread-thread data passing via pipe

◆ test_pipe_get_min_xfer()

void test_pipe_get_min_xfer ( void  )

#include <tests/kernel/pipe/pipe/src/test_pipe.c>

Test pipe get returns immediately if >= min_xfer is available.

See also
k_pipe_get()

◆ test_pipe_get_null()

void test_pipe_get_null ( void  )

#include <tests/kernel/pipe/pipe_api/src/test_pipe_fail.c>

Test k_pipe_get() failure scenario.

See what will happen if an uninitialized k_pipe is passed to k_pipe_get().

See also
k_pipe_get()

◆ test_pipe_get_on_empty_pipe()

void test_pipe_get_on_empty_pipe ( void  )

#include <tests/kernel/pipe/pipe/src/test_pipe.c>

Test pipe get from a empty pipe.

See also
k_pipe_get()

◆ test_pipe_get_put()

void test_pipe_get_put ( void  )

#include <tests/kernel/pipe/pipe_api/src/test_pipe_contexts.c>

TESTPOINT: thread-thread data passing via pipe

◆ test_pipe_get_timeout()

void test_pipe_get_timeout ( void  )

#include <tests/kernel/pipe/pipe/src/test_pipe.c>

k_pipe_get timeout test

See also
k_pipe_get()

◆ test_pipe_get_unreach_data()

void test_pipe_get_unreach_data ( void  )

#include <tests/kernel/pipe/pipe_api/src/test_pipe_fail.c>

Test k_pipe_get() failure scenario.

See what will happen if the parameter address is accessed deny to test k_pipe_get

See also
k_pipe_get()

◆ test_pipe_get_unreach_size()

void test_pipe_get_unreach_size ( void  )

#include <tests/kernel/pipe/pipe_api/src/test_pipe_fail.c>

Test k_pipe_get() failure scenario.

See what will happen if the parameter address is accessed deny to test k_pipe_get

See also
k_pipe_get()

◆ test_pipe_on_multiple_elements()

void test_pipe_on_multiple_elements ( void  )

#include <tests/kernel/pipe/pipe/src/test_pipe.c>

Test when multiple items are present in the pipe.

transfer sequences of bytes of data in part.

  • Using a sub thread to get data part.
  • Using main thread to put data part by part
See also
k_pipe_put()

◆ test_pipe_on_single_elements()

void test_pipe_on_single_elements ( void  )

#include <tests/kernel/pipe/pipe/src/test_pipe.c>

Verify pipe with 1 element insert.

Test Objective:

  • transfer sequences of bytes of data in whole.

Testing techniques:

  • function and block box testing,Interface testing, Dynamic analysis and testing.

Prerequisite Conditions:

  • CONFIG_TEST_USERSPACE.

Input Specifications:

  • N/A

Test Procedure:

  1. Define and initialize a pipe at compile time.
  2. Using a sub thread to get pipe data in whole, and check if the data is correct with expected.
  3. Using main thread to put data in whole, check if the return is correct with expected.

Expected Test Result:

  • The pipe put/get whole data is correct.

Pass/Fail Criteria:

  • Successful if check points in test procedure are all passed, otherwise failure.

Assumptions and Constraints:

  • N/A
See also
k_pipe_put(), k_pipe_get()

◆ test_pipe_put_fail()

void test_pipe_put_fail ( void  )

#include <tests/kernel/pipe/pipe_api/src/test_pipe_fail.c>

Test pipe put failure scenario.

See also
k_pipe_init(), k_pipe_put()

◆ test_pipe_put_min_xfer()

void test_pipe_put_min_xfer ( void  )

#include <tests/kernel/pipe/pipe/src/test_pipe.c>

Test pipe put returns immediately if >= min_xfer is available.

See also
k_pipe_put()

◆ test_pipe_put_null()

void test_pipe_put_null ( void  )

#include <tests/kernel/pipe/pipe_api/src/test_pipe_fail.c>

Test k_pipe_put() failure scenario.

See what will happen if a null pointer is passed into the k_pipe_put as a parameter

See also
k_pipe_put()

◆ test_pipe_put_unreach_data()

void test_pipe_put_unreach_data ( void  )

#include <tests/kernel/pipe/pipe_api/src/test_pipe_fail.c>

Test k_pipe_put() failure scenario.

See what will happen if the parameter address is accessed deny to test k_pipe_put

See also
k_pipe_put()

◆ test_pipe_put_unreach_size()

void test_pipe_put_unreach_size ( void  )

#include <tests/kernel/pipe/pipe_api/src/test_pipe_fail.c>

Test k_pipe_put() failure scenario.

See what will happen if the parameter address is accessed deny to test k_pipe_put

See also
k_pipe_put()

◆ test_pipe_read_avail_null()

void test_pipe_read_avail_null ( void  )

#include <tests/kernel/pipe/pipe_api/src/test_pipe_fail.c>

Test k_pipe_read_avail() failure scenario.

See what will happen if a null pointer is passed into the k_pipe_read_avail as a parameter

See also
k_pipe_read_avail()

◆ test_pipe_reader_wait()

void test_pipe_reader_wait ( void  )

#include <tests/kernel/pipe/pipe_api/src/test_pipe_contexts.c>

Test pending reader in pipe.

See also
k_pipe_put(), k_pipe_get()

TESTPOINT: test k_pipe_block_put with semaphore

◆ test_pipe_thread2thread()

void test_pipe_thread2thread ( void  )

#include <tests/kernel/pipe/pipe_api/src/test_pipe_contexts.c>

Test pipe data passing between threads.

Test Objective:

  • Verify data passing with "pipe put/get" APIs between threads

Testing techniques:

  • function and block box testing,Interface testing, Dynamic analysis and testing.

Prerequisite Conditions:

  • CONFIG_TEST_USERSPACE.

Input Specifications:

  • N/A

Test Procedure:

  1. Initialize a pipe, which is defined at run time.
  2. Create a thread (A).
  3. In A thread, check if it can get data, which is sent by main thread via the pipe.
  4. In A thread, send data to main thread via the pipe.
  5. In main thread, send data to A thread via the pipe.
  6. In main thread, check if it can get data, which is sent by A thread.
  7. Do the same testing with a pipe, which is defined at compile time

Expected Test Result:

  • Data can be sent/received between threads.

Pass/Fail Criteria:

  • Successful if check points in test procedure are all passed, otherwise failure.

Assumptions and Constraints:

  • N/A
See also
k_pipe_init(), k_pipe_put(), K_PIPE_DEFINE(x)

TESTPOINT: test k_pipe_init pipe

TESTPOINT: test K_PIPE_DEFINE pipe

◆ test_pipe_timeout()

void test_pipe_timeout ( void  )

#include <tests/kernel/pipe/pipe/src/test_pipe.c>

Test pipes with timeout.

Test Objective:

  • Check if the kernel support supplying a timeout parameter indicating the maximum amount of time a process will wait.

Testing techniques:

  • function and block box testing,Interface testing, Dynamic analysis and testing.

Prerequisite Conditions:

  • CONFIG_TEST_USERSPACE.

Input Specifications:

  • N/A

Test Procedure:

  1. Create a sub thread to get data from a pipe.
  2. In the sub thread, Set K_MSEC(10) as timeout for k_pipe_get(). and check the data which get from pipe if correct.
  3. In main thread, use k_pipe_put to put data. and check the return of k_pipe_put.

Expected Test Result:

  • The pipe can set timeout and works well.

Pass/Fail Criteria:

  • Successful if check points in test procedure are all passed, otherwise failure.

Assumptions and Constraints:

  • N/A
See also
k_pipe_put()

◆ test_pipe_user_get_fail()

void test_pipe_user_get_fail ( void  )

#include <tests/kernel/pipe/pipe_api/src/test_pipe_fail.c>

Test pipe get by a user thread.

See also
k_pipe_alloc_init()

◆ test_pipe_user_put_fail()

void test_pipe_user_put_fail ( void  )

#include <tests/kernel/pipe/pipe_api/src/test_pipe_fail.c>

Test pipe put by a user thread.

See also
k_pipe_put()

◆ test_pipe_user_thread2thread()

void test_pipe_user_thread2thread ( void  )

#include <tests/kernel/pipe/pipe_api/src/test_pipe_contexts.c>

Test data passing using pipes between user threads.

See also
k_pipe_init(), k_pipe_put(), K_PIPE_DEFINE(x)

TESTPOINT: test k_object_alloc pipe

TESTPOINT: test k_pipe_alloc_init

◆ test_pipe_write_avail_null()

void test_pipe_write_avail_null ( void  )

#include <tests/kernel/pipe/pipe_api/src/test_pipe_fail.c>

Test k_pipe_write_avail() failure scenario.

See what will happen if a null pointer is passed into the k_pipe_write_avail as a parameter

See also
k_pipe_write_avail()

◆ test_resource_pool_auto_free()

void test_resource_pool_auto_free ( void  )

#include <tests/kernel/pipe/pipe_api/src/test_pipe_contexts.c>

Test resource pool free.

See also
k_heap_alloc()

◆ tThread_half_pipe_get()

static void tThread_half_pipe_get ( void p1,
void p2,
void p3 
)
static

◆ tThread_half_pipe_put()

static void tThread_half_pipe_put ( void p1,
void p2,
void p3 
)
static

Variable Documentation

◆ bufferless

struct k_pipe bufferless
static

◆ bufferless1

struct k_pipe bufferless1
static

#include <tests/kernel/pipe/pipe_api/src/test_pipe_avail.c>

Initial value:
= {
.buffer = data,
.size = 0,
}
static ZTEST_DMEM unsigned char data[]
Tests for the Pipe read / write availability.
Definition: test_pipe_avail.c:15

◆ data

ZTEST_DMEM unsigned char data[] = "abcdefgh"
static

#include <tests/kernel/pipe/pipe_api/src/test_pipe_avail.c>

Tests for the Pipe read / write availability.

◆ pipe

struct k_pipe pipe
static

#include <tests/kernel/pipe/pipe_api/src/test_pipe_avail.c>

Initial value:
= {
.buffer = data,
.size = sizeof(data) - 1 ,
}