Skip to content

Commit 1530e86

Browse files
dcpleungkartben
authored andcommitted
tests: kernel/pipe_api: move local k_pipe var to global
When CONFIG_KERNEL_COHERENCE is enabled, pend_locked() asserts when wait_q is not in coherent memory. The k_pipes used in the pipe_api tests are declared locally within the test. They are located within the thread stacks and those wait_q inside k_pipe struct are thus not considered in coherent memory. To make them work, replace the local ones with a global k_pipe object. Since each test initializes the pipe object locally, the tests are not functionally changed. Fixes #84235 Signed-off-by: Daniel Leung <daniel.leung@intel.com>
1 parent 289f80f commit 1530e86

File tree

3 files changed

+5
-17
lines changed

3 files changed

+5
-17
lines changed

tests/kernel/pipe/pipe_api/src/basic.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ static void mkrandom(uint8_t *buffer, size_t size)
1717

1818
K_PIPE_DEFINE(test_define, 256, 4);
1919

20+
static struct k_pipe pipe;
21+
2022
ZTEST(k_pipe_basic, test_init)
2123
{
22-
struct k_pipe pipe;
2324
uint8_t buffer[10];
2425

2526
k_pipe_init(&pipe, buffer, sizeof(buffer));
@@ -28,7 +29,6 @@ ZTEST(k_pipe_basic, test_init)
2829

2930
ZTEST(k_pipe_basic, test_write_read_one)
3031
{
31-
struct k_pipe pipe;
3232
uint8_t buffer[10];
3333
uint8_t data = 0x55;
3434
uint8_t read_data;
@@ -43,7 +43,6 @@ ZTEST(k_pipe_basic, test_write_read_one)
4343

4444
ZTEST(k_pipe_basic, test_write_read_multiple)
4545
{
46-
struct k_pipe pipe;
4746
uint8_t buffer[10];
4847
uint8_t data = 0x55;
4948
uint8_t read_data;
@@ -59,7 +58,6 @@ ZTEST(k_pipe_basic, test_write_read_multiple)
5958

6059
ZTEST(k_pipe_basic, test_write_full)
6160
{
62-
struct k_pipe pipe;
6361
uint8_t buffer[10];
6462
uint8_t data[10];
6563

@@ -72,7 +70,6 @@ ZTEST(k_pipe_basic, test_write_full)
7270

7371
ZTEST(k_pipe_basic, test_read_empty)
7472
{
75-
struct k_pipe pipe;
7673
uint8_t buffer[10];
7774
uint8_t read_data;
7875

@@ -83,7 +80,6 @@ ZTEST(k_pipe_basic, test_read_empty)
8380

8481
ZTEST(k_pipe_basic, test_read_write_full)
8582
{
86-
struct k_pipe pipe;
8783
uint8_t buffer[10];
8884
uint8_t input[10];
8985
uint8_t res[10];
@@ -100,7 +96,6 @@ ZTEST(k_pipe_basic, test_read_write_full)
10096

10197
ZTEST(k_pipe_basic, test_read_write_wrapp_around)
10298
{
103-
struct k_pipe pipe;
10499
uint8_t buffer[12];
105100
uint8_t input[8];
106101
uint8_t res[16];
@@ -126,7 +121,6 @@ ZTEST(k_pipe_basic, test_read_write_wrapp_around)
126121

127122
ZTEST(k_pipe_basic, test_reset)
128123
{
129-
struct k_pipe pipe;
130124
uint8_t buffer[10];
131125
uint8_t data = 0x55;
132126
uint8_t read_data;
@@ -144,7 +138,6 @@ ZTEST(k_pipe_basic, test_reset)
144138

145139
ZTEST(k_pipe_basic, test_close)
146140
{
147-
struct k_pipe pipe;
148141
uint8_t buffer[12];
149142
uint8_t input[8];
150143
uint8_t res[16];

tests/kernel/pipe/pipe_api/src/concurrency.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ static const int partial_wait_time = 2000;
1616
#define DUMMY_DATA_SIZE 16
1717
static struct k_thread thread;
1818
static K_THREAD_STACK_DEFINE(stack, 1024);
19+
static struct k_pipe pipe;
1920

2021
static void thread_close(void *arg1, void *arg2, void *arg3)
2122
{
@@ -46,7 +47,6 @@ static void thread_read(void *arg1, void *arg2, void *arg3)
4647
ZTEST(k_pipe_concurrency, test_close_on_read)
4748
{
4849
k_tid_t tid;
49-
struct k_pipe pipe;
5050
uint8_t buffer[DUMMY_DATA_SIZE];
5151
uint8_t res;
5252

@@ -64,7 +64,6 @@ ZTEST(k_pipe_concurrency, test_close_on_read)
6464
ZTEST(k_pipe_concurrency, test_close_on_write)
6565
{
6666
k_tid_t tid;
67-
struct k_pipe pipe;
6867
uint8_t buffer[DUMMY_DATA_SIZE];
6968
uint8_t garbage[DUMMY_DATA_SIZE];
7069

@@ -85,7 +84,6 @@ ZTEST(k_pipe_concurrency, test_close_on_write)
8584
ZTEST(k_pipe_concurrency, test_reset_on_read)
8685
{
8786
k_tid_t tid;
88-
struct k_pipe pipe;
8987
uint8_t buffer[DUMMY_DATA_SIZE];
9088
uint8_t res;
9189

@@ -106,7 +104,6 @@ ZTEST(k_pipe_concurrency, test_reset_on_read)
106104
ZTEST(k_pipe_concurrency, test_reset_on_write)
107105
{
108106
k_tid_t tid;
109-
struct k_pipe pipe;
110107
uint8_t buffer[DUMMY_DATA_SIZE];
111108
uint8_t garbage[DUMMY_DATA_SIZE];
112109

@@ -129,7 +126,6 @@ ZTEST(k_pipe_concurrency, test_reset_on_write)
129126
ZTEST(k_pipe_concurrency, test_partial_read)
130127
{
131128
k_tid_t tid;
132-
struct k_pipe pipe;
133129
uint8_t buffer[DUMMY_DATA_SIZE];
134130
uint8_t garbage[DUMMY_DATA_SIZE];
135131
size_t write_size = sizeof(garbage)/2;
@@ -149,7 +145,6 @@ ZTEST(k_pipe_concurrency, test_partial_read)
149145
ZTEST(k_pipe_concurrency, test_partial_write)
150146
{
151147
k_tid_t tid;
152-
struct k_pipe pipe;
153148
uint8_t buffer[DUMMY_DATA_SIZE];
154149
uint8_t garbage[DUMMY_DATA_SIZE];
155150
size_t read_size = sizeof(garbage)/2;

tests/kernel/pipe/pipe_api/src/stress.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ LOG_MODULE_REGISTER(k_k_pipe_stress, LOG_LEVEL_INF);
1818

1919
ZTEST_SUITE(k_pipe_stress, NULL, NULL, NULL, NULL, NULL);
2020

21+
static struct k_pipe pipe;
22+
2123
ZTEST(k_pipe_stress, test_write)
2224
{
2325
int rc;
24-
struct k_pipe pipe;
2526
const size_t len = WRITE_LEN;
2627
uint8_t buffer[WRITE_LEN];
2728
uint8_t buf[WRITE_LEN];
@@ -43,7 +44,6 @@ ZTEST(k_pipe_stress, test_write)
4344
ZTEST(k_pipe_stress, test_read)
4445
{
4546
int rc;
46-
struct k_pipe pipe;
4747
const size_t len = READ_LEN;
4848
uint8_t buffer[READ_LEN];
4949
uint8_t buf[READ_LEN];

0 commit comments

Comments
 (0)