Skip to content

Commit 0572f1f

Browse files
Mattemagikernkartben
authored andcommitted
tests: Update tests to use new k_pipe API
Update tests to use the reworked k_pipe API. Signed-off-by: Måns Ansgariusson <[email protected]>
1 parent c39291b commit 0572f1f

File tree

14 files changed

+29
-61
lines changed

14 files changed

+29
-61
lines changed

tests/benchmarks/app_kernel/prj.conf

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ CONFIG_CBPRINTF_FP_SUPPORT=y
1616
# Can only run under 1 CPU
1717
CONFIG_MP_MAX_NUM_CPUS=1
1818

19-
# Enable pipes
20-
CONFIG_PIPES=y
21-
2219
CONFIG_APPLICATION_DEFINED_SYSCALL=y
2320
CONFIG_TIMING_FUNCTIONS=y
2421

tests/benchmarks/app_kernel/prj_user.conf

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ CONFIG_CBPRINTF_FP_SUPPORT=y
1616
# Can only run under 1 CPU
1717
CONFIG_MP_MAX_NUM_CPUS=1
1818

19-
# Enable pipes
20-
CONFIG_PIPES=y
21-
2219
CONFIG_APPLICATION_DEFINED_SYSCALL=y
2320
CONFIG_TIMING_FUNCTIONS=y
2421
CONFIG_USERSPACE=y

tests/benchmarks/app_kernel/src/master.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
BENCH_BMEM char msg[MAX_MSG];
2424
BENCH_BMEM char data_bench[MESSAGE_SIZE];
2525

26-
BENCH_DMEM struct k_pipe *test_pipes[] = {&PIPE_NOBUFF, &PIPE_SMALLBUFF, &PIPE_BIGBUFF};
26+
BENCH_DMEM struct k_pipe *test_pipes[] = {&PIPE_SMALLBUFF, &PIPE_BIGBUFF};
2727
BENCH_BMEM char sline[SLINE_LEN + 1];
2828

2929
/*
@@ -70,7 +70,6 @@ K_MBOX_DEFINE(MAILB1);
7070

7171
K_MUTEX_DEFINE(DEMO_MUTEX);
7272

73-
K_PIPE_DEFINE(PIPE_NOBUFF, 0, 4);
7473
K_PIPE_DEFINE(PIPE_SMALLBUFF, 256, 4);
7574
K_PIPE_DEFINE(PIPE_BIGBUFF, 4096, 4);
7675

@@ -188,7 +187,7 @@ int main(void)
188187
k_thread_access_grant(&recv_thread, &DEMOQX1, &DEMOQX4, &DEMOQX192,
189188
&MB_COMM, &CH_COMM, &SEM0, &SEM1, &SEM2, &SEM3,
190189
&SEM4, &STARTRCV, &DEMO_MUTEX,
191-
&PIPE_NOBUFF, &PIPE_SMALLBUFF, &PIPE_BIGBUFF);
190+
&PIPE_SMALLBUFF, &PIPE_BIGBUFF);
192191

193192
k_thread_start(&recv_thread);
194193
k_thread_start(&test_thread);
@@ -212,7 +211,7 @@ int main(void)
212211
k_thread_access_grant(&test_thread, &DEMOQX1, &DEMOQX4, &DEMOQX192,
213212
&MB_COMM, &CH_COMM, &SEM0, &SEM1, &SEM2, &SEM3,
214213
&SEM4, &STARTRCV, &DEMO_MUTEX,
215-
&PIPE_NOBUFF, &PIPE_SMALLBUFF, &PIPE_BIGBUFF);
214+
&PIPE_SMALLBUFF, &PIPE_BIGBUFF);
216215

217216
k_thread_start(&recv_thread);
218217
k_thread_start(&test_thread);
@@ -236,11 +235,11 @@ int main(void)
236235
k_thread_access_grant(&test_thread, &DEMOQX1, &DEMOQX4, &DEMOQX192,
237236
&MB_COMM, &CH_COMM, &SEM0, &SEM1, &SEM2, &SEM3,
238237
&SEM4, &STARTRCV, &DEMO_MUTEX,
239-
&PIPE_NOBUFF, &PIPE_SMALLBUFF, &PIPE_BIGBUFF);
238+
&PIPE_SMALLBUFF, &PIPE_BIGBUFF);
240239
k_thread_access_grant(&recv_thread, &DEMOQX1, &DEMOQX4, &DEMOQX192,
241240
&MB_COMM, &CH_COMM, &SEM0, &SEM1, &SEM2, &SEM3,
242241
&SEM4, &STARTRCV, &DEMO_MUTEX,
243-
&PIPE_NOBUFF, &PIPE_SMALLBUFF, &PIPE_BIGBUFF);
242+
&PIPE_SMALLBUFF, &PIPE_BIGBUFF);
244243

245244
k_thread_start(&recv_thread);
246245
k_thread_start(&test_thread);

tests/benchmarks/app_kernel/src/pipe_b.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ void pipe_test(void)
9090
PRINT_STRING(dashline);
9191

9292
for (putsize = 8U; putsize <= MESSAGE_SIZE_PIPE; putsize <<= 1) {
93-
for (pipe = 0; pipe < 3; pipe++) {
93+
for (pipe = 0; pipe < 2; pipe++) {
9494
putcount = NR_OF_PIPE_RUNS;
9595
pipeput(test_pipes[pipe], _ALL_N, putsize, putcount,
9696
&puttime[pipe]);
@@ -125,7 +125,7 @@ void pipe_test(void)
125125

126126
for (putsize = 8U; putsize <= (MESSAGE_SIZE_PIPE); putsize <<= 1) {
127127
putcount = MESSAGE_SIZE_PIPE / putsize;
128-
for (pipe = 0; pipe < 3; pipe++) {
128+
for (pipe = 0; pipe < 2; pipe++) {
129129
pipeput(test_pipes[pipe], _1_TO_N, putsize,
130130
putcount, &puttime[pipe]);
131131
/* size*count == MESSAGE_SIZE_PIPE */
@@ -171,16 +171,10 @@ int pipeput(struct k_pipe *pipe,
171171
for (i = 0; option == _1_TO_N || (i < count); i++) {
172172
size_t sizexferd = 0;
173173
size_t size2xfer = MIN(size, size2xfer_total - sizexferd_total);
174-
int ret;
175-
size_t mim_num_of_bytes = 0;
176174

177-
if (option == _ALL_N) {
178-
mim_num_of_bytes = size2xfer;
179-
}
180-
ret = k_pipe_put(pipe, data_bench, size2xfer,
181-
&sizexferd, mim_num_of_bytes, K_FOREVER);
175+
sizexferd = k_pipe_write(pipe, data_bench, size2xfer, K_FOREVER);
182176

183-
if (ret != 0) {
177+
if (sizexferd < 0) {
184178
return 1;
185179
}
186180
if (option == _ALL_N && sizexferd != size2xfer) {

tests/benchmarks/app_kernel/src/pipe_r.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void piperecvtask(void)
3636
/* matching (ALL_N) */
3737

3838
for (getsize = 8; getsize <= MESSAGE_SIZE_PIPE; getsize <<= 1) {
39-
for (pipe = 0; pipe < 3; pipe++) {
39+
for (pipe = 0; pipe < 2; pipe++) {
4040
getcount = NR_OF_PIPE_RUNS;
4141
pipeget(test_pipes[pipe], _ALL_N, getsize,
4242
getcount, &gettime);
@@ -52,7 +52,7 @@ void piperecvtask(void)
5252
/* non-matching (1_TO_N) */
5353
for (getsize = (MESSAGE_SIZE_PIPE); getsize >= 8; getsize >>= 1) {
5454
getcount = MESSAGE_SIZE_PIPE / getsize;
55-
for (pipe = 0; pipe < 3; pipe++) {
55+
for (pipe = 0; pipe < 2; pipe++) {
5656
/* size*count == MESSAGE_SIZE_PIPE */
5757
pipeget(test_pipes[pipe], _1_TO_N,
5858
getsize, getcount, &gettime);
@@ -95,12 +95,9 @@ int pipeget(struct k_pipe *pipe, enum pipe_options option, int size, int count,
9595
for (i = 0; option == _1_TO_N || (i < count); i++) {
9696
size_t sizexferd = 0;
9797
size_t size2xfer = MIN(size, size2xfer_total - sizexferd_total);
98-
int ret;
9998

100-
ret = k_pipe_get(pipe, data_recv, size2xfer,
101-
&sizexferd, option, K_FOREVER);
102-
103-
if (ret != 0) {
99+
sizexferd = k_pipe_read(pipe, data_recv, size2xfer, K_FOREVER);
100+
if (sizexferd < 0) {
104101
return 1;
105102
}
106103

tests/kernel/mem_protect/mem_protect/prj.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ CONFIG_ZTEST_STACK_SIZE=2048
44
CONFIG_MAX_THREAD_BYTES=4
55
CONFIG_TEST_USERSPACE=y
66
CONFIG_APPLICATION_DEFINED_SYSCALL=y
7-
CONFIG_PIPES=y

tests/kernel/mem_protect/userspace/prj.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ CONFIG_ZTEST=y
33
CONFIG_INIT_STACKS=y
44
CONFIG_APPLICATION_DEFINED_SYSCALL=y
55
CONFIG_TEST_USERSPACE=y
6-
CONFIG_PIPES=y

tests/kernel/mem_protect/userspace/src/main.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,6 @@ ZTEST(userspace, test_user_mode_enter)
664664

665665
/* Define and initialize pipe. */
666666
K_PIPE_DEFINE(kpipe, PIPE_LEN, BYTES_TO_READ_WRITE);
667-
K_APP_BMEM(default_part) static size_t bytes_written_read;
668-
669667
/**
670668
* @brief Test to write to kobject using pipe
671669
*
@@ -679,8 +677,7 @@ ZTEST_USER(userspace, test_write_kobject_user_pipe)
679677
*/
680678
set_fault(K_ERR_KERNEL_OOPS);
681679

682-
k_pipe_get(&kpipe, &test_revoke_sem, BYTES_TO_READ_WRITE,
683-
&bytes_written_read, 1, K_NO_WAIT);
680+
k_pipe_read(&kpipe, (uint8_t *)&test_revoke_sem, BYTES_TO_READ_WRITE, K_NO_WAIT);
684681

685682
zassert_unreachable("System call memory write validation "
686683
"did not fault");
@@ -699,8 +696,7 @@ ZTEST_USER(userspace, test_read_kobject_user_pipe)
699696
*/
700697
set_fault(K_ERR_KERNEL_OOPS);
701698

702-
k_pipe_put(&kpipe, &test_revoke_sem, BYTES_TO_READ_WRITE,
703-
&bytes_written_read, 1, K_NO_WAIT);
699+
k_pipe_write(&kpipe, (uint8_t *)&test_revoke_sem, BYTES_TO_READ_WRITE, K_NO_WAIT);
704700

705701
zassert_unreachable("System call memory read validation "
706702
"did not fault");

tests/kernel/mutex/mutex_error_case/prj.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ CONFIG_IRQ_OFFLOAD=y
33
CONFIG_TEST_USERSPACE=y
44
CONFIG_MP_MAX_NUM_CPUS=1
55
CONFIG_ZTEST_FATAL_HOOK=y
6-
CONFIG_PIPES=y
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
CONFIG_ZTEST=y
22
CONFIG_OBJ_CORE=y
33
CONFIG_EVENTS=y
4-
CONFIG_PIPES=y
54
CONFIG_SYS_MEM_BLOCKS=y

0 commit comments

Comments
 (0)