Zephyr Project API 3.7.0-rc1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
PIPEs

Functions

 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.
 
 ZTEST (pipe, test_pipe_flush)
 Test flushing a pipe.
 
 ZTEST (pipe_api_1cpu, test_pipe_thread2thread)
 Test pipe data passing between threads.
 
 ZTEST_USER (pipe_api_1cpu, test_pipe_user_thread2thread)
 Test data passing using pipes between user threads.
 
 ZTEST (pipe_api, test_resource_pool_auto_free)
 Test resource pool free.
 
static void tThread_half_pipe_put (void *p1, void *p2, void *p3)
 
static void tThread_half_pipe_get (void *p1, void *p2, void *p3)
 
 ZTEST (pipe_api, test_half_pipe_put_get)
 Test put/get with smaller pipe buffer.
 
 ZTEST (pipe_api, test_pipe_get_put)
 
 ZTEST (pipe_api, test_pipe_get_large)
 
 ZTEST (pipe_api, test_pipe_reader_wait)
 Test pending reader in pipe.
 
 ZTEST (pipe_api_1cpu, test_pipe_put_fail)
 Test pipe put failure scenario.
 
 ZTEST_USER (pipe_api_1cpu, test_pipe_user_put_fail)
 Test pipe put by a user thread.
 
 ZTEST (pipe_api, test_pipe_get_fail)
 Test pipe get failure scenario.
 
 ZTEST_USER (pipe_api, test_pipe_user_get_fail)
 Test pipe get by a user thread.
 
 ZTEST_USER (pipe_api, test_pipe_alloc_not_init)
 Test k_pipe_alloc_init() failure scenario.
 
 ZTEST_USER (pipe_api, test_pipe_get_null)
 Test k_pipe_get() failure scenario.
 
 ZTEST_USER (pipe_api, test_pipe_get_unreach_data)
 Test k_pipe_get() failure scenario.
 
 ZTEST_USER (pipe_api, test_pipe_get_unreach_size)
 Test k_pipe_get() failure scenario.
 
 ZTEST_USER (pipe_api, test_pipe_put_null)
 Test k_pipe_put() failure scenario.
 
 ZTEST_USER (pipe_api, test_pipe_put_unreach_data)
 Test k_pipe_put() failure scenario.
 
 ZTEST_USER (pipe_api, test_pipe_put_unreach_size)
 Test k_pipe_put() failure scenario.
 
 ZTEST_USER (pipe_api, test_pipe_read_avail_null)
 Test k_pipe_read_avail() failure scenario.
 
 ZTEST_USER (pipe_api, test_pipe_write_avail_null)
 Test k_pipe_write_avail() failure scenario.
 
static ZTEST_DMEM unsigned char data [] = "abcdefgh"
 Tests for the Pipe read / write availability.
 
static struct k_pipe pipe
 
static struct k_pipe bufferless
 
static struct k_pipe bufferless1
 
 ZTEST (pipe_api, test_pipe_avail_no_buffer)
 Pipes with no buffer or size 0 should return 0 bytes available.
 
 ZTEST (pipe_api, test_pipe_avail_r_lt_w)
 Test available read / write space for r < w.
 
 ZTEST (pipe_api, test_pipe_avail_w_lt_r)
 Test available read / write space for w < r.
 
 ZTEST (pipe_api, test_pipe_avail_r_eq_w_empty)
 Test available read / write space for r == w and an empty buffer.
 
 ZTEST (pipe_api, test_pipe_avail_r_eq_w_full)
 Test available read / write space for r == w and a full buffer.
 

Detailed Description

Function Documentation

◆ 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

◆ ZTEST() [1/15]

ZTEST ( pipe  ,
test_pipe_define_at_runtime   
)

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

◆ ZTEST() [2/15]

ZTEST ( pipe  ,
test_pipe_flush   
)

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

Test flushing a pipe.

Test Objective:

  • Check if the kernel flushes a pipe properly at runtime.

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. Use this pipe to transfer data.
  3. Have a thread fill and block on writing to the pipe
  4. Flush the pipe and check that the pipe is completely empty
  5. Have a thread fill and block on writing to the pipe
  6. Flush only the pipe's buffer and check the results

Expected Test Result:

  • Reading from the pipe after k_pipe_flush() results in no data to read.
  • Reading from the pipe after k_pipe_buffer_flush() results in read data, but missing the original data that was in the buffer prior to the flush.

Pass/Fail Criteria:

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

Assumptions and Constraints:

  • N/A

◆ ZTEST() [3/15]

ZTEST ( pipe_api  ,
test_half_pipe_put_get   
)

#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

◆ ZTEST() [4/15]

ZTEST ( pipe_api  ,
test_pipe_avail_no_buffer   
)

#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.

◆ ZTEST() [5/15]

ZTEST ( pipe_api  ,
test_pipe_avail_r_eq_w_empty   
)

#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 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

◆ ZTEST() [6/15]

ZTEST ( pipe_api  ,
test_pipe_avail_r_eq_w_full   
)

#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 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:

◆ ZTEST() [7/15]

ZTEST ( pipe_api  ,
test_pipe_avail_r_lt_w   
)

#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

◆ ZTEST() [8/15]

ZTEST ( pipe_api  ,
test_pipe_avail_w_lt_r   
)

#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

◆ ZTEST() [9/15]

ZTEST ( pipe_api  ,
test_pipe_get_fail   
)

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

Test pipe get failure scenario.

See also
k_pipe_init(), k_pipe_get()

◆ ZTEST() [10/15]

ZTEST ( pipe_api  ,
test_pipe_get_large   
)

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

TESTPOINT: thread-thread data passing via pipe

◆ ZTEST() [11/15]

ZTEST ( pipe_api  ,
test_pipe_get_put   
)

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

TESTPOINT: thread-thread data passing via pipe

◆ ZTEST() [12/15]

ZTEST ( pipe_api  ,
test_pipe_reader_wait   
)

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

Test pending reader in pipe.

See also
k_pipe_put(), k_pipe_get()

◆ ZTEST() [13/15]

ZTEST ( pipe_api  ,
test_resource_pool_auto_free   
)

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

Test resource pool free.

See also
k_heap_alloc()

◆ ZTEST() [14/15]

ZTEST ( pipe_api_1cpu  ,
test_pipe_put_fail   
)

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

Test pipe put failure scenario.

See also
k_pipe_init(), k_pipe_put()

◆ ZTEST() [15/15]

ZTEST ( pipe_api_1cpu  ,
test_pipe_thread2thread   
)

#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

◆ ZTEST_USER() [1/22]

ZTEST_USER ( pipe  ,
test_pipe_forever_timeout   
)

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

◆ ZTEST_USER() [2/22]

ZTEST_USER ( pipe  ,
test_pipe_forever_wait   
)

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

Test when multiple items are present with wait.

See also
k_pipe_put()

◆ ZTEST_USER() [3/22]

ZTEST_USER ( pipe  ,
test_pipe_get_invalid_size   
)

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

Test pipe get of invalid size.

See also
k_pipe_get()

◆ ZTEST_USER() [4/22]

ZTEST_USER ( pipe  ,
test_pipe_get_min_xfer   
)

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

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

See also
k_pipe_get()

◆ ZTEST_USER() [5/22]

ZTEST_USER ( pipe  ,
test_pipe_get_on_empty_pipe   
)

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

Test pipe get from a empty pipe.

See also
k_pipe_get()

◆ ZTEST_USER() [6/22]

ZTEST_USER ( pipe  ,
test_pipe_get_timeout   
)

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

k_pipe_get timeout test

See also
k_pipe_get()

◆ ZTEST_USER() [7/22]

ZTEST_USER ( pipe  ,
test_pipe_on_multiple_elements   
)

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

◆ ZTEST_USER() [8/22]

ZTEST_USER ( pipe  ,
test_pipe_on_single_elements   
)

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

◆ ZTEST_USER() [9/22]

ZTEST_USER ( pipe  ,
test_pipe_put_min_xfer   
)

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

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

See also
k_pipe_put()

◆ ZTEST_USER() [10/22]

ZTEST_USER ( pipe  ,
test_pipe_timeout   
)

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

◆ ZTEST_USER() [11/22]

ZTEST_USER ( pipe_api  ,
test_pipe_alloc_not_init   
)

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

◆ ZTEST_USER() [12/22]

ZTEST_USER ( pipe_api  ,
test_pipe_get_null   
)

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

◆ ZTEST_USER() [13/22]

ZTEST_USER ( pipe_api  ,
test_pipe_get_unreach_data   
)

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

◆ ZTEST_USER() [14/22]

ZTEST_USER ( pipe_api  ,
test_pipe_get_unreach_size   
)

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

◆ ZTEST_USER() [15/22]

ZTEST_USER ( pipe_api  ,
test_pipe_put_null   
)

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

◆ ZTEST_USER() [16/22]

ZTEST_USER ( pipe_api  ,
test_pipe_put_unreach_data   
)

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

◆ ZTEST_USER() [17/22]

ZTEST_USER ( pipe_api  ,
test_pipe_put_unreach_size   
)

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

◆ ZTEST_USER() [18/22]

ZTEST_USER ( pipe_api  ,
test_pipe_read_avail_null   
)

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

◆ ZTEST_USER() [19/22]

ZTEST_USER ( pipe_api  ,
test_pipe_user_get_fail   
)

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

Test pipe get by a user thread.

See also
k_pipe_alloc_init()

◆ ZTEST_USER() [20/22]

ZTEST_USER ( pipe_api  ,
test_pipe_write_avail_null   
)

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

◆ ZTEST_USER() [21/22]

ZTEST_USER ( pipe_api_1cpu  ,
test_pipe_user_put_fail   
)

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

Test pipe put by a user thread.

See also
k_pipe_put()

◆ ZTEST_USER() [22/22]

ZTEST_USER ( pipe_api_1cpu  ,
test_pipe_user_thread2thread   
)

#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

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 ,
}