tests: Update tests to use new k_pipe API
Update tests to use the reworked k_pipe API. Signed-off-by: Måns Ansgariusson <Mansgariusson@gmail.com>
This commit is contained in:
parent
c39291b7f0
commit
0572f1f098
14 changed files with 29 additions and 61 deletions
|
@ -16,9 +16,6 @@ CONFIG_CBPRINTF_FP_SUPPORT=y
|
|||
# Can only run under 1 CPU
|
||||
CONFIG_MP_MAX_NUM_CPUS=1
|
||||
|
||||
# Enable pipes
|
||||
CONFIG_PIPES=y
|
||||
|
||||
CONFIG_APPLICATION_DEFINED_SYSCALL=y
|
||||
CONFIG_TIMING_FUNCTIONS=y
|
||||
|
||||
|
|
|
@ -16,9 +16,6 @@ CONFIG_CBPRINTF_FP_SUPPORT=y
|
|||
# Can only run under 1 CPU
|
||||
CONFIG_MP_MAX_NUM_CPUS=1
|
||||
|
||||
# Enable pipes
|
||||
CONFIG_PIPES=y
|
||||
|
||||
CONFIG_APPLICATION_DEFINED_SYSCALL=y
|
||||
CONFIG_TIMING_FUNCTIONS=y
|
||||
CONFIG_USERSPACE=y
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
BENCH_BMEM char msg[MAX_MSG];
|
||||
BENCH_BMEM char data_bench[MESSAGE_SIZE];
|
||||
|
||||
BENCH_DMEM struct k_pipe *test_pipes[] = {&PIPE_NOBUFF, &PIPE_SMALLBUFF, &PIPE_BIGBUFF};
|
||||
BENCH_DMEM struct k_pipe *test_pipes[] = {&PIPE_SMALLBUFF, &PIPE_BIGBUFF};
|
||||
BENCH_BMEM char sline[SLINE_LEN + 1];
|
||||
|
||||
/*
|
||||
|
@ -70,7 +70,6 @@ K_MBOX_DEFINE(MAILB1);
|
|||
|
||||
K_MUTEX_DEFINE(DEMO_MUTEX);
|
||||
|
||||
K_PIPE_DEFINE(PIPE_NOBUFF, 0, 4);
|
||||
K_PIPE_DEFINE(PIPE_SMALLBUFF, 256, 4);
|
||||
K_PIPE_DEFINE(PIPE_BIGBUFF, 4096, 4);
|
||||
|
||||
|
@ -188,7 +187,7 @@ int main(void)
|
|||
k_thread_access_grant(&recv_thread, &DEMOQX1, &DEMOQX4, &DEMOQX192,
|
||||
&MB_COMM, &CH_COMM, &SEM0, &SEM1, &SEM2, &SEM3,
|
||||
&SEM4, &STARTRCV, &DEMO_MUTEX,
|
||||
&PIPE_NOBUFF, &PIPE_SMALLBUFF, &PIPE_BIGBUFF);
|
||||
&PIPE_SMALLBUFF, &PIPE_BIGBUFF);
|
||||
|
||||
k_thread_start(&recv_thread);
|
||||
k_thread_start(&test_thread);
|
||||
|
@ -212,7 +211,7 @@ int main(void)
|
|||
k_thread_access_grant(&test_thread, &DEMOQX1, &DEMOQX4, &DEMOQX192,
|
||||
&MB_COMM, &CH_COMM, &SEM0, &SEM1, &SEM2, &SEM3,
|
||||
&SEM4, &STARTRCV, &DEMO_MUTEX,
|
||||
&PIPE_NOBUFF, &PIPE_SMALLBUFF, &PIPE_BIGBUFF);
|
||||
&PIPE_SMALLBUFF, &PIPE_BIGBUFF);
|
||||
|
||||
k_thread_start(&recv_thread);
|
||||
k_thread_start(&test_thread);
|
||||
|
@ -236,11 +235,11 @@ int main(void)
|
|||
k_thread_access_grant(&test_thread, &DEMOQX1, &DEMOQX4, &DEMOQX192,
|
||||
&MB_COMM, &CH_COMM, &SEM0, &SEM1, &SEM2, &SEM3,
|
||||
&SEM4, &STARTRCV, &DEMO_MUTEX,
|
||||
&PIPE_NOBUFF, &PIPE_SMALLBUFF, &PIPE_BIGBUFF);
|
||||
&PIPE_SMALLBUFF, &PIPE_BIGBUFF);
|
||||
k_thread_access_grant(&recv_thread, &DEMOQX1, &DEMOQX4, &DEMOQX192,
|
||||
&MB_COMM, &CH_COMM, &SEM0, &SEM1, &SEM2, &SEM3,
|
||||
&SEM4, &STARTRCV, &DEMO_MUTEX,
|
||||
&PIPE_NOBUFF, &PIPE_SMALLBUFF, &PIPE_BIGBUFF);
|
||||
&PIPE_SMALLBUFF, &PIPE_BIGBUFF);
|
||||
|
||||
k_thread_start(&recv_thread);
|
||||
k_thread_start(&test_thread);
|
||||
|
|
|
@ -90,7 +90,7 @@ void pipe_test(void)
|
|||
PRINT_STRING(dashline);
|
||||
|
||||
for (putsize = 8U; putsize <= MESSAGE_SIZE_PIPE; putsize <<= 1) {
|
||||
for (pipe = 0; pipe < 3; pipe++) {
|
||||
for (pipe = 0; pipe < 2; pipe++) {
|
||||
putcount = NR_OF_PIPE_RUNS;
|
||||
pipeput(test_pipes[pipe], _ALL_N, putsize, putcount,
|
||||
&puttime[pipe]);
|
||||
|
@ -125,7 +125,7 @@ void pipe_test(void)
|
|||
|
||||
for (putsize = 8U; putsize <= (MESSAGE_SIZE_PIPE); putsize <<= 1) {
|
||||
putcount = MESSAGE_SIZE_PIPE / putsize;
|
||||
for (pipe = 0; pipe < 3; pipe++) {
|
||||
for (pipe = 0; pipe < 2; pipe++) {
|
||||
pipeput(test_pipes[pipe], _1_TO_N, putsize,
|
||||
putcount, &puttime[pipe]);
|
||||
/* size*count == MESSAGE_SIZE_PIPE */
|
||||
|
@ -171,16 +171,10 @@ int pipeput(struct k_pipe *pipe,
|
|||
for (i = 0; option == _1_TO_N || (i < count); i++) {
|
||||
size_t sizexferd = 0;
|
||||
size_t size2xfer = MIN(size, size2xfer_total - sizexferd_total);
|
||||
int ret;
|
||||
size_t mim_num_of_bytes = 0;
|
||||
|
||||
if (option == _ALL_N) {
|
||||
mim_num_of_bytes = size2xfer;
|
||||
}
|
||||
ret = k_pipe_put(pipe, data_bench, size2xfer,
|
||||
&sizexferd, mim_num_of_bytes, K_FOREVER);
|
||||
sizexferd = k_pipe_write(pipe, data_bench, size2xfer, K_FOREVER);
|
||||
|
||||
if (ret != 0) {
|
||||
if (sizexferd < 0) {
|
||||
return 1;
|
||||
}
|
||||
if (option == _ALL_N && sizexferd != size2xfer) {
|
||||
|
|
|
@ -36,7 +36,7 @@ void piperecvtask(void)
|
|||
/* matching (ALL_N) */
|
||||
|
||||
for (getsize = 8; getsize <= MESSAGE_SIZE_PIPE; getsize <<= 1) {
|
||||
for (pipe = 0; pipe < 3; pipe++) {
|
||||
for (pipe = 0; pipe < 2; pipe++) {
|
||||
getcount = NR_OF_PIPE_RUNS;
|
||||
pipeget(test_pipes[pipe], _ALL_N, getsize,
|
||||
getcount, &gettime);
|
||||
|
@ -52,7 +52,7 @@ void piperecvtask(void)
|
|||
/* non-matching (1_TO_N) */
|
||||
for (getsize = (MESSAGE_SIZE_PIPE); getsize >= 8; getsize >>= 1) {
|
||||
getcount = MESSAGE_SIZE_PIPE / getsize;
|
||||
for (pipe = 0; pipe < 3; pipe++) {
|
||||
for (pipe = 0; pipe < 2; pipe++) {
|
||||
/* size*count == MESSAGE_SIZE_PIPE */
|
||||
pipeget(test_pipes[pipe], _1_TO_N,
|
||||
getsize, getcount, &gettime);
|
||||
|
@ -95,12 +95,9 @@ int pipeget(struct k_pipe *pipe, enum pipe_options option, int size, int count,
|
|||
for (i = 0; option == _1_TO_N || (i < count); i++) {
|
||||
size_t sizexferd = 0;
|
||||
size_t size2xfer = MIN(size, size2xfer_total - sizexferd_total);
|
||||
int ret;
|
||||
|
||||
ret = k_pipe_get(pipe, data_recv, size2xfer,
|
||||
&sizexferd, option, K_FOREVER);
|
||||
|
||||
if (ret != 0) {
|
||||
sizexferd = k_pipe_read(pipe, data_recv, size2xfer, K_FOREVER);
|
||||
if (sizexferd < 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue