pipes: Simplify task_pipe_get() API family
Changes the pipe API so that the timeout parameter must be specified when invoking task_pipe_get() thereby obsoleting the following APIs: task_pipe_get_wait() task_pipe_get_wait_timeout() _task_pipe_get() Change-Id: If249e57d086fef15fdc1616965f53b310ac9cf9d Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
This commit is contained in:
parent
f5d90e1584
commit
57c7977ecf
8 changed files with 136 additions and 168 deletions
|
@ -256,8 +256,8 @@ rather than reading them individually.
|
|||
|
||||
while (1) {
|
||||
/* read 20 complete data items at once */
|
||||
task_pipe_get_wait(DATA_PIPE, &data_items, sizeof(data_items),
|
||||
&amount_read, _ALL_N);
|
||||
task_pipe_get(DATA_PIPE, &data_items, sizeof(data_items),
|
||||
&amount_read, _ALL_N, TICKS_UNLIMITED);
|
||||
|
||||
/* process the data items one at a time */
|
||||
for (i = 0; i < 20; i++) {
|
||||
|
@ -286,7 +286,7 @@ unprocessed data bytes in the pipe.
|
|||
while (1) {
|
||||
/* consume any data bytes currently in the pipe */
|
||||
while (task_pipe_get(DATA_PIPE, &data_area, sizeof(data_area),
|
||||
&amount_read, _1_TO_N) == RC_OK) {
|
||||
&amount_read, _1_TO_N, TICKS_NONE) == RC_OK) {
|
||||
/* now have from 1 to 20 data bytes */
|
||||
for (i = 0; i < amount_read; i++) {
|
||||
... = data_area[i];
|
||||
|
@ -312,10 +312,3 @@ The following Pipe APIs are provided by :file:`microkernel.h`:
|
|||
|
||||
:c:func:`task_pipe_get()`
|
||||
Reads data from a pipe, or fails and continues if data isn't there.
|
||||
|
||||
:c:func:`task_pipe_get_wait()`
|
||||
Reads data from a pipe, or waits for data if data isn't there.
|
||||
|
||||
:c:func:`task_pipe_get_wait_timeout()`
|
||||
Reads data from a pipe, or waits for
|
||||
data for a specified time period if data isn't there.
|
||||
|
|
|
@ -81,63 +81,32 @@ extern "C" {
|
|||
extern int task_pipe_put(kpipe_t id, void *buffer, int bytes_to_write,
|
||||
int *bytes_written, K_PIPE_OPTION options, int32_t timeout);
|
||||
|
||||
extern int _task_pipe_get(kpipe_t id,
|
||||
void *pBuffer,
|
||||
int iNbrBytesToRead,
|
||||
int *piNbrBytesRead,
|
||||
K_PIPE_OPTION Option,
|
||||
int32_t TimeOut);
|
||||
|
||||
/**
|
||||
* @brief Pipe read request
|
||||
*
|
||||
* Attempt to read data into a memory buffer area from the
|
||||
* specified pipe and fail immediately if not possible.
|
||||
* specified pipe with a timeout option.
|
||||
*
|
||||
* @param id Pipe ID
|
||||
* @param b Buffer
|
||||
* @param n Number of bytes to read
|
||||
* @param pn Pointer to number of bytes read
|
||||
* @param o Pipe options
|
||||
* @param buffer Buffer
|
||||
* @param bytes_to_read Number of bytes to read
|
||||
* @param bytes_read Pointer to number of bytes read
|
||||
* @param options Pipe options
|
||||
* @param timeout Affects the action taken should the pipe be empty. If
|
||||
* TICKS_NONE, then return immediately. If TICKS_UNLIMITED, then wait as long
|
||||
* as necessary. Otherwise wait up to the specified number of ticks before
|
||||
* timing out.
|
||||
*
|
||||
* @return RC_OK, RC_INCOMPLETE, RC_FAIL, or RC_ALIGNMENT
|
||||
* @retval RC_OK Successfully read data from pipe
|
||||
* @retval RC_ALIGNMENT Data is improperly aligned
|
||||
* @retval RC_INCOMPLETE Only some of the data was read from the pipe when
|
||||
* @a options = _ALL_N
|
||||
* @retval RC_TIME Timed out waiting to read from pipe
|
||||
* @retval RC_FAIL Failed to immediately read from pipe when
|
||||
* @a timeout = TICKS_NONE
|
||||
*/
|
||||
#define task_pipe_get(id, b, n, pn, o) \
|
||||
_task_pipe_get(id, b, n, pn, o, TICKS_NONE)
|
||||
/**
|
||||
* @brief Pipe read request and wait
|
||||
*
|
||||
* Attempt to read data into a memory buffer area from the
|
||||
* specified pipe and wait forever until it succeeds.
|
||||
*
|
||||
* @param id Pipe ID
|
||||
* @param b Buffer
|
||||
* @param n Number of bytes to read
|
||||
* @param pn Pointer to number of bytes read
|
||||
* @param o Pipe options
|
||||
*
|
||||
* @return RC_OK, RC_INCOMPLETE, or RC_ALIGNMENT
|
||||
*/
|
||||
#define task_pipe_get_wait(id, b, n, pn, o) \
|
||||
_task_pipe_get(id, b, n, pn, o, TICKS_UNLIMITED)
|
||||
/**
|
||||
* @brief Pipe read request
|
||||
*
|
||||
* This routine attempts to read data into a memory buffer area from the
|
||||
* specified pipe, with a possible timeout option.
|
||||
*
|
||||
* @param id Pipe ID
|
||||
* @param b Buffer
|
||||
* @param n Number of bytes to read
|
||||
* @param pn Pointer to number of bytes read
|
||||
* @param o Pipe options
|
||||
* @param t Timeout
|
||||
*
|
||||
* @return RC_OK, RC_INCOMPLETE, RC_FAIL, RC_TIME, or RC_ALIGNMENT
|
||||
*/
|
||||
#define task_pipe_get_wait_timeout(id, b, n, pn, o, t) \
|
||||
_task_pipe_get(id, b, n, pn, o, t)
|
||||
|
||||
extern int task_pipe_get(kpipe_t id, void *buffer, int bytes_to_read,
|
||||
int *bytes_read, K_PIPE_OPTION options, int32_t timeout);
|
||||
|
||||
extern int _task_pipe_block_put(kpipe_t id,
|
||||
struct k_block block,
|
||||
|
|
|
@ -48,57 +48,49 @@ void _k_pipe_init(void)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Pipe read request
|
||||
*
|
||||
* This routine attempts to read data into a memory buffer area from the
|
||||
* specified pipe.
|
||||
*
|
||||
* @return RC_OK, RC_INCOMPLETE, RC_FAIL, RC_TIME, or RC_ALIGNMENT
|
||||
*/
|
||||
int _task_pipe_get(kpipe_t Id, void *pBuffer,
|
||||
int iNbrBytesToRead, int *piNbrBytesRead,
|
||||
K_PIPE_OPTION Option, int32_t TimeOut)
|
||||
int task_pipe_get(kpipe_t id, void *buffer,
|
||||
int bytes_to_read, int *bytes_read,
|
||||
K_PIPE_OPTION options, int32_t timeout)
|
||||
{
|
||||
struct k_args A;
|
||||
|
||||
/*
|
||||
* some users do not check the FUNCTION return value,
|
||||
* but immediately use iNbrBytesRead; make sure it always
|
||||
* but immediately use bytes_read; make sure it always
|
||||
* has a good value, even when we return failure immediately
|
||||
* (see below)
|
||||
*/
|
||||
|
||||
*piNbrBytesRead = 0;
|
||||
*bytes_read = 0;
|
||||
|
||||
if (unlikely(iNbrBytesToRead % SIZEOFUNIT_TO_OCTET(1))) {
|
||||
if (unlikely(bytes_to_read % SIZEOFUNIT_TO_OCTET(1))) {
|
||||
return RC_ALIGNMENT;
|
||||
}
|
||||
if (unlikely(iNbrBytesToRead == 0)) {
|
||||
if (unlikely(bytes_to_read == 0)) {
|
||||
/*
|
||||
* not allowed because enlisted requests with zero size
|
||||
* will hang in _k_pipe_process()
|
||||
*/
|
||||
return RC_FAIL;
|
||||
}
|
||||
if (unlikely(Option == _0_TO_N && TimeOut != TICKS_NONE)) {
|
||||
if (unlikely(options == _0_TO_N && timeout != TICKS_NONE)) {
|
||||
return RC_FAIL;
|
||||
}
|
||||
|
||||
A.priority = _k_current_task->priority;
|
||||
A.Comm = _K_SVC_PIPE_GET_REQUEST;
|
||||
A.Time.ticks = TimeOut;
|
||||
A.Time.ticks = timeout;
|
||||
|
||||
A.args.pipe_req.req_info.pipe.id = Id;
|
||||
A.args.pipe_req.req_type.sync.total_size = iNbrBytesToRead;
|
||||
A.args.pipe_req.req_type.sync.data_ptr = pBuffer;
|
||||
A.args.pipe_req.req_info.pipe.id = id;
|
||||
A.args.pipe_req.req_type.sync.total_size = bytes_to_read;
|
||||
A.args.pipe_req.req_type.sync.data_ptr = buffer;
|
||||
|
||||
_k_pipe_option_set(&A.args, Option);
|
||||
_k_pipe_option_set(&A.args, options);
|
||||
_k_pipe_request_type_set(&A.args, _SYNCREQ);
|
||||
|
||||
KERNEL_ENTRY(&A);
|
||||
|
||||
*piNbrBytesRead = A.args.pipe_ack.xferred_size;
|
||||
*bytes_read = A.args.pipe_ack.xferred_size;
|
||||
return A.Time.rcode;
|
||||
}
|
||||
|
||||
|
|
|
@ -109,8 +109,8 @@ int pipeget(kpipe_t pipe, K_PIPE_OPTION option, int size, int count,
|
|||
int size2xfer = min(size, size2xfer_total - sizexferd_total);
|
||||
int ret;
|
||||
|
||||
ret = task_pipe_get_wait(pipe, data_recv, size2xfer,
|
||||
&sizexferd, option);
|
||||
ret = task_pipe_get(pipe, data_recv, size2xfer,
|
||||
&sizexferd, option, TICKS_UNLIMITED);
|
||||
if (RC_OK != ret) {
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ static pfunc func_array[] = {
|
|||
(pfunc)_task_sem_group_take,
|
||||
/* pipe functions */
|
||||
(pfunc)task_pipe_put,
|
||||
(pfunc)_task_pipe_get,
|
||||
(pfunc)task_pipe_get,
|
||||
(pfunc)_task_pipe_block_put,
|
||||
/* mailbox functions */
|
||||
(pfunc)task_mbox_put,
|
||||
|
|
|
@ -35,8 +35,8 @@ Starting pipe tests
|
|||
Testing task_pipe_put(TICKS_NONE) ...
|
||||
Testing task_pipe_put(TICKS_UNLIMITED) ...
|
||||
Testing task_pipe_put(timeout) ...
|
||||
Testing task_pipe_get() ...
|
||||
Testing task_pipe_get_wait() ...
|
||||
Testing task_pipe_get_wait_timeout() ...
|
||||
Testing task_pipe_get(TICKS_NONE) ...
|
||||
Testing task_pipe_get(TICKS_UNLIMITED) ...
|
||||
Testing task_pipe_get(timeout) ...
|
||||
===================================================================
|
||||
PROJECT EXECUTION SUCCESSFUL
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
*
|
||||
* task_pipe_put()
|
||||
* task_pipe_get()
|
||||
* task_pipe_get_wait()
|
||||
* task_pipe_get_wait_timeout()
|
||||
*
|
||||
* The following target pipe routine does not yet have a test case:
|
||||
* task_pipe_block_put()
|
||||
|
@ -209,7 +207,8 @@ int pipePutHelperWork(SIZE_EXPECT *singleItems, int nSingles,
|
|||
}
|
||||
|
||||
rv = task_pipe_get(pipeId, rxBuffer, singleItems[i].size,
|
||||
&bytesReceived, singleItems[i].options);
|
||||
&bytesReceived, singleItems[i].options,
|
||||
TICKS_NONE);
|
||||
if (rv != singleItems[i].rcode) {
|
||||
TC_ERROR("task_pipe_get(%d bytes) : Expected %d not %d.\n"
|
||||
" bytesReceived = %d\n",
|
||||
|
@ -249,7 +248,8 @@ int pipePutHelperWork(SIZE_EXPECT *singleItems, int nSingles,
|
|||
}
|
||||
|
||||
rv = task_pipe_get(pipeId, rxBuffer, manyItems[i].size,
|
||||
&bytesReceived, manyItems[i].options);
|
||||
&bytesReceived, manyItems[i].options,
|
||||
TICKS_NONE);
|
||||
|
||||
if (rv != manyItems[i].rcode) {
|
||||
TC_ERROR("task_pipe_get(%d bytes) : Expected %d not %d.\n"
|
||||
|
@ -453,24 +453,17 @@ int pipePutTest(void)
|
|||
int pipePutWaitHelper(void)
|
||||
{
|
||||
int i; /* loop counter */
|
||||
int rv; /* return value from task_pipe_get_wait */
|
||||
int bytesRead; /* # of bytes read from task_pipe_get_wait() */
|
||||
int rv; /* return value from task_pipe_get*/
|
||||
int bytesRead; /* # of bytes read from task_pipe_get() */
|
||||
|
||||
(void)task_sem_take_wait(altSem); /* Wait until test is ready */
|
||||
|
||||
/* 1. task_pipe_get_wait() will force a context switch to RegressionTask() */
|
||||
rv = task_pipe_get_wait(pipeId, rxBuffer, PIPE_SIZE,
|
||||
&bytesRead, _ALL_N);
|
||||
if ((rv != RC_OK) || (bytesRead != PIPE_SIZE)) {
|
||||
TC_ERROR("Expected return code %d, not %d\n"
|
||||
"Expected %d bytes to be read, not %d\n",
|
||||
RC_OK, rv, PIPE_SIZE, bytesRead);
|
||||
return TC_FAIL;
|
||||
}
|
||||
|
||||
/* 2. task_pipe_get_wait() will force a context switch to RegressionTask(). */
|
||||
rv = task_pipe_get_wait(pipeId, rxBuffer, PIPE_SIZE,
|
||||
&bytesRead, _1_TO_N);
|
||||
/*
|
||||
* 1. task_pipe_get(TICKS_UNLIMITED) will force a context
|
||||
* switch to RegressionTask().
|
||||
*/
|
||||
rv = task_pipe_get(pipeId, rxBuffer, PIPE_SIZE,
|
||||
&bytesRead, _ALL_N, TICKS_UNLIMITED);
|
||||
if ((rv != RC_OK) || (bytesRead != PIPE_SIZE)) {
|
||||
TC_ERROR("Expected return code %d, not %d\n"
|
||||
"Expected %d bytes to be read, not %d\n",
|
||||
|
@ -479,12 +472,25 @@ int pipePutWaitHelper(void)
|
|||
}
|
||||
|
||||
/*
|
||||
* Before emptying the pipe, check that task_pipe_get_wait() fails when
|
||||
* using the _0_TO_N option.
|
||||
* 2. task_pipe_get(TICKS_UNLIMITED) will force a context
|
||||
* switch to RegressionTask().
|
||||
*/
|
||||
rv = task_pipe_get(pipeId, rxBuffer, PIPE_SIZE,
|
||||
&bytesRead, _1_TO_N, TICKS_UNLIMITED);
|
||||
if ((rv != RC_OK) || (bytesRead != PIPE_SIZE)) {
|
||||
TC_ERROR("Expected return code %d, not %d\n"
|
||||
"Expected %d bytes to be read, not %d\n",
|
||||
RC_OK, rv, PIPE_SIZE, bytesRead);
|
||||
return TC_FAIL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Before emptying the pipe, check that task_pipe_get(TICKS_UNLIMITED)
|
||||
* fails when using the _0_TO_N option.
|
||||
*/
|
||||
|
||||
rv = task_pipe_get_wait(pipeId, rxBuffer, PIPE_SIZE / 2,
|
||||
&bytesRead, _0_TO_N);
|
||||
rv = task_pipe_get(pipeId, rxBuffer, PIPE_SIZE / 2,
|
||||
&bytesRead, _0_TO_N, TICKS_UNLIMITED);
|
||||
if (rv != RC_FAIL) {
|
||||
TC_ERROR("Expected return code %d, not %d\n", RC_FAIL, rv);
|
||||
return TC_FAIL;
|
||||
|
@ -493,7 +499,7 @@ int pipePutWaitHelper(void)
|
|||
/* 3. Empty the pipe in two reads */
|
||||
for (i = 0; i < 2; i++) {
|
||||
rv = task_pipe_get(pipeId, rxBuffer, PIPE_SIZE / 2,
|
||||
&bytesRead, _0_TO_N);
|
||||
&bytesRead, _0_TO_N, TICKS_NONE);
|
||||
if ((rv != RC_OK) || (bytesRead != PIPE_SIZE / 2)) {
|
||||
TC_ERROR("Expected return code %d, not %d\n"
|
||||
"Expected %d bytes to be read, not %d\n",
|
||||
|
@ -569,7 +575,7 @@ int pipePutWaitTest(void)
|
|||
|
||||
/**
|
||||
*
|
||||
* @brief Test task_pipe_get_wait_timeout()
|
||||
* @brief Test task_pipe_get(timeout)
|
||||
*
|
||||
* @return TC_PASS on success, TC_FAIL on failure
|
||||
*/
|
||||
|
@ -577,24 +583,17 @@ int pipePutWaitTest(void)
|
|||
int pipePutTimeoutHelper(void)
|
||||
{
|
||||
int i; /* loop counter */
|
||||
int rv; /* return value from task_pipe_get_wait_timeout() */
|
||||
int bytesRead; /* # of bytes read from task_pipe_get_wait_timeout() */
|
||||
int rv; /* return value from task_pipe_get() */
|
||||
int bytesRead; /* # of bytes read from task_pipe_get() */
|
||||
|
||||
(void)task_sem_take_wait(altSem); /* Wait until test is ready */
|
||||
|
||||
/* 1. task_pipe_get_wait_timeout() will force a context switch to RegressionTask() */
|
||||
rv = task_pipe_get_wait_timeout(pipeId, rxBuffer, PIPE_SIZE,
|
||||
&bytesRead, _ALL_N, ONE_SECOND);
|
||||
if ((rv != RC_OK) || (bytesRead != PIPE_SIZE)) {
|
||||
TC_ERROR("Expected return code %d, not %d\n"
|
||||
"Expected %d bytes to be read, not %d\n",
|
||||
RC_OK, rv, PIPE_SIZE, bytesRead);
|
||||
return TC_FAIL;
|
||||
}
|
||||
|
||||
/* 2. task_pipe_get_wait_timeout() will force a context switch to RegressionTask(). */
|
||||
rv = task_pipe_get_wait_timeout(pipeId, rxBuffer, PIPE_SIZE,
|
||||
&bytesRead, _1_TO_N, ONE_SECOND);
|
||||
/*
|
||||
* 1. task_pipe_get(timeout) will force a context
|
||||
* switch to RegressionTask()
|
||||
*/
|
||||
rv = task_pipe_get(pipeId, rxBuffer, PIPE_SIZE,
|
||||
&bytesRead, _ALL_N, ONE_SECOND);
|
||||
if ((rv != RC_OK) || (bytesRead != PIPE_SIZE)) {
|
||||
TC_ERROR("Expected return code %d, not %d\n"
|
||||
"Expected %d bytes to be read, not %d\n",
|
||||
|
@ -603,12 +602,25 @@ int pipePutTimeoutHelper(void)
|
|||
}
|
||||
|
||||
/*
|
||||
* Before emptying the pipe, check that task_pipe_get_wait_timeout() fails when
|
||||
* 2. task_pipe_get(timeout) will force a context
|
||||
* switch to RegressionTask().
|
||||
*/
|
||||
rv = task_pipe_get(pipeId, rxBuffer, PIPE_SIZE,
|
||||
&bytesRead, _1_TO_N, ONE_SECOND);
|
||||
if ((rv != RC_OK) || (bytesRead != PIPE_SIZE)) {
|
||||
TC_ERROR("Expected return code %d, not %d\n"
|
||||
"Expected %d bytes to be read, not %d\n",
|
||||
RC_OK, rv, PIPE_SIZE, bytesRead);
|
||||
return TC_FAIL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Before emptying the pipe, check that task_pipe_get(timeout) fails when
|
||||
* using the _0_TO_N option.
|
||||
*/
|
||||
|
||||
rv = task_pipe_get_wait_timeout(pipeId, rxBuffer, PIPE_SIZE / 2,
|
||||
&bytesRead, _0_TO_N, ONE_SECOND);
|
||||
rv = task_pipe_get(pipeId, rxBuffer, PIPE_SIZE / 2,
|
||||
&bytesRead, _0_TO_N, ONE_SECOND);
|
||||
if (rv != RC_FAIL) {
|
||||
TC_ERROR("Expected return code %d, not %d\n", RC_FAIL, rv);
|
||||
return TC_FAIL;
|
||||
|
@ -617,7 +629,7 @@ int pipePutTimeoutHelper(void)
|
|||
/* 3. Empty the pipe in two reads */
|
||||
for (i = 0; i < 2; i++) {
|
||||
rv = task_pipe_get(pipeId, rxBuffer, PIPE_SIZE / 2,
|
||||
&bytesRead, _0_TO_N);
|
||||
&bytesRead, _0_TO_N, TICKS_NONE);
|
||||
if ((rv != RC_OK) || (bytesRead != PIPE_SIZE / 2)) {
|
||||
TC_ERROR("Expected return code %d, not %d\n"
|
||||
"Expected %d bytes to be read, not %d\n",
|
||||
|
@ -713,12 +725,12 @@ int pipePutTimeoutTest(void)
|
|||
|
||||
/**
|
||||
*
|
||||
* @brief Routine to test task_pipe_get()
|
||||
* @brief Routine to test task_pipe_get(TICKS_NONE)
|
||||
*
|
||||
* This routine tests the task_pipe_get() API. Some of this functionality
|
||||
* has already been tested while testing task_pipe_put(). As a result, the
|
||||
* only remaining functionality that needs to be checked are attempts to get
|
||||
* data from an empty pipe.
|
||||
* This routine tests the task_pipe_get(TICKS_NONE) API. Some of this
|
||||
* functionality has already been tested while testing task_pipe_put(). As
|
||||
* a result, the only remaining functionality that needs to be checked are
|
||||
* attempts to get data from an empty pipe.
|
||||
*
|
||||
* @return TC_PASS on success, TC_FAIL on failure
|
||||
*/
|
||||
|
@ -735,7 +747,7 @@ int pipeGetTest(void)
|
|||
for (j = 0; j < ARRAY_SIZE(options); j++) {
|
||||
for (i = 0; i < ARRAY_SIZE(size); i++) {
|
||||
rv = task_pipe_get(pipeId, rxBuffer, size[i],
|
||||
&bytesRead, options[j]);
|
||||
&bytesRead, options[j], TICKS_NONE);
|
||||
if (rv != RC_FAIL) {
|
||||
TC_ERROR("Expected return code %d, not %d\n", RC_FAIL, rv);
|
||||
return TC_FAIL;
|
||||
|
@ -745,7 +757,7 @@ int pipeGetTest(void)
|
|||
|
||||
for (i = 0; i < ARRAY_SIZE(size); i++) {
|
||||
rv = task_pipe_get(pipeId, rxBuffer, size[i],
|
||||
&bytesRead, _0_TO_N);
|
||||
&bytesRead, _0_TO_N, TICKS_NONE);
|
||||
if (rv != RC_OK) {
|
||||
TC_ERROR("Expected return code %d, not %d\n", RC_OK, rv);
|
||||
return TC_FAIL;
|
||||
|
@ -762,9 +774,9 @@ int pipeGetTest(void)
|
|||
|
||||
/**
|
||||
*
|
||||
* @brief Test task_pipe_get_wait()
|
||||
* @brief Test task_pipe_get(TICKS_UNLIMITED)
|
||||
*
|
||||
* @param items testcase list for task_pipe_get_wait()
|
||||
* @param items testcase list for task_pipe_get(TICKS_UNLIMITED)
|
||||
* @param nItems number of items in list
|
||||
*
|
||||
* @return TC_PASS on success, TC_FAIL on failure
|
||||
|
@ -778,9 +790,9 @@ int pipeGetWaitHelperWork(SIZE_EXPECT *items, int nItems)
|
|||
|
||||
for (i = 0; i < nItems; i++) {
|
||||
/*
|
||||
* Pipe should be empty. Most calls to task_pipe_get_wait() should
|
||||
* block until the call to task_pipe_put() is performed in the routine
|
||||
* pipeGetWaitHelperWork().
|
||||
* Pipe should be empty. Most calls to task_pipe_get(TICKS_UNLIMITED)
|
||||
* should block until the call to task_pipe_put() is performed in the
|
||||
* routine pipeGetWaitHelperWork().
|
||||
*/
|
||||
|
||||
bytesSent = 0;
|
||||
|
@ -800,7 +812,7 @@ int pipeGetWaitHelperWork(SIZE_EXPECT *items, int nItems)
|
|||
|
||||
/**
|
||||
*
|
||||
* @brief Test task_pipe_get_wait()
|
||||
* @brief Test task_pipe_get(TICKS_UNLIMITED)
|
||||
*
|
||||
* @return TC_PASS on success, TC_FAIL on failure
|
||||
*/
|
||||
|
@ -828,9 +840,9 @@ int pipeGetWaitHelper(void)
|
|||
|
||||
/**
|
||||
*
|
||||
* @brief Test task_pipe_get_wait()
|
||||
* @brief Test task_pipe_get(TICKS_UNLIMITED)
|
||||
*
|
||||
* @param items testcase list for task_pipe_get_wait()
|
||||
* @param items testcase list for task_pipe_get(TICKS_UNLIMITED)
|
||||
* @param nItems number of items in list
|
||||
*
|
||||
* @return TC_PASS on success, TC_FAIL on failure
|
||||
|
@ -839,18 +851,19 @@ int pipeGetWaitHelper(void)
|
|||
int pipeGetWaitTestWork(SIZE_EXPECT *items, int nItems)
|
||||
{
|
||||
int i; /* loop counter */
|
||||
int rv; /* return code from task_pipe_get_wait() */
|
||||
int bytesRead; /* # of bytes read from task_pipe_get_wait() */
|
||||
int rv; /* return code from task_pipe_get() */
|
||||
int bytesRead; /* # of bytes read from task_pipe_get() */
|
||||
|
||||
for (i = 0; i < nItems; i++) {
|
||||
/*
|
||||
* Pipe should be empty. Most calls to task_pipe_get_wait() should
|
||||
* block until the call to task_pipe_put() is performed in the routine
|
||||
* pipeGetWaitHelperWork().
|
||||
* Pipe should be empty. Most calls to task_pipe_get(TICKS_UNLIMITED)
|
||||
* should block until the call to task_pipe_put() is performed in the
|
||||
* routine pipeGetWaitHelperWork().
|
||||
*/
|
||||
|
||||
rv = task_pipe_get_wait(pipeId, rxBuffer, items[i].size,
|
||||
&bytesRead, items[i].options);
|
||||
rv = task_pipe_get(pipeId, rxBuffer, items[i].size,
|
||||
&bytesRead, items[i].options,
|
||||
TICKS_UNLIMITED);
|
||||
if ((rv != items[i].rcode) || (bytesRead != items[i].sent)) {
|
||||
TC_ERROR("Expected return value %d, got %d\n"
|
||||
"Expected bytesRead = %d, got %d\n",
|
||||
|
@ -864,7 +877,7 @@ int pipeGetWaitTestWork(SIZE_EXPECT *items, int nItems)
|
|||
|
||||
/**
|
||||
*
|
||||
* @brief Test task_pipe_get_wait()
|
||||
* @brief Test task_pipe_get(TICKS_UNLIMITED)
|
||||
*
|
||||
* @return TC_PASS on success, TC_FAIL on failure
|
||||
*/
|
||||
|
@ -888,8 +901,8 @@ int pipeGetWaitTest(void)
|
|||
return TC_FAIL;
|
||||
}
|
||||
|
||||
rv = task_pipe_get_wait(pipeId, rxBuffer, PIPE_SIZE,
|
||||
&bytesRead, _0_TO_N);
|
||||
rv = task_pipe_get(pipeId, rxBuffer, PIPE_SIZE,
|
||||
&bytesRead, _0_TO_N, TICKS_UNLIMITED);
|
||||
if (rv != RC_FAIL) {
|
||||
TC_ERROR("Expected return code of %d, not %d\n", RC_FAIL, rv);
|
||||
return TC_FAIL;
|
||||
|
@ -900,7 +913,7 @@ int pipeGetWaitTest(void)
|
|||
|
||||
/**
|
||||
*
|
||||
* @brief Test remaining task_pipe_get_wait_timeout() functionality
|
||||
* @brief Test remaining task_pipe_get(timeout) functionality
|
||||
*
|
||||
* @return TC_PASS on success, TC_FAIL on failure
|
||||
*/
|
||||
|
@ -908,12 +921,13 @@ int pipeGetWaitTest(void)
|
|||
int pipeGetTimeoutTest(void)
|
||||
{
|
||||
int i; /* loop counter */
|
||||
int rv; /* return value from task_pipe_get_wait_timeout() */
|
||||
int bytesRead; /* # of bytes read from task_pipe_get_wait_timeout() */
|
||||
int rv; /* return value from task_pipe_get() */
|
||||
int bytesRead; /* # of bytes read from task_pipe_get() */
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(timeout_cases); i++) {
|
||||
rv = task_pipe_get_wait_timeout(pipeId, rxBuffer, timeout_cases[i].size,
|
||||
&bytesRead, timeout_cases[i].options, ONE_SECOND);
|
||||
rv = task_pipe_get(pipeId, rxBuffer, timeout_cases[i].size,
|
||||
&bytesRead, timeout_cases[i].options,
|
||||
ONE_SECOND);
|
||||
if ((rv != timeout_cases[i].rcode) ||
|
||||
(bytesRead != timeout_cases[i].sent)) {
|
||||
TC_ERROR("Expected return code %d, got %d\n"
|
||||
|
@ -967,7 +981,7 @@ int AlternateTask(void)
|
|||
}
|
||||
|
||||
/*
|
||||
* There is no pipeGetTimeoutHelper() as the task_pipe_get_wait_timeout() checks
|
||||
* There is no pipeGetTimeoutHelper() as the task_pipe_get(timeout) checks
|
||||
* have either been done in pipePutTimeoutHelper() or
|
||||
* pipeGetTimeoutTest().
|
||||
*/
|
||||
|
@ -1008,19 +1022,19 @@ int RegressionTask(void)
|
|||
return TC_FAIL;
|
||||
}
|
||||
|
||||
TC_PRINT("Testing task_pipe_get() ...\n");
|
||||
TC_PRINT("Testing task_pipe_get(TICKS_NONE) ...\n");
|
||||
tcRC = pipeGetTest();
|
||||
if (tcRC != TC_PASS) {
|
||||
return TC_FAIL;
|
||||
}
|
||||
|
||||
TC_PRINT("Testing task_pipe_get_wait() ...\n");
|
||||
TC_PRINT("Testing task_pipe_get(TICKS_UNLIMITED) ...\n");
|
||||
tcRC = pipeGetWaitTest();
|
||||
if (tcRC != TC_PASS) {
|
||||
return TC_FAIL;
|
||||
}
|
||||
|
||||
TC_PRINT("Testing task_pipe_get_wait_timeout() ...\n");
|
||||
TC_PRINT("Testing task_pipe_get(timeout) ...\n");
|
||||
tcRC = pipeGetTimeoutTest();
|
||||
if (tcRC != TC_PASS) {
|
||||
return TC_FAIL;
|
||||
|
|
|
@ -36,8 +36,8 @@ Starting pipe tests
|
|||
Testing task_pipe_put(TICKS_NONE) ...
|
||||
Testing task_pipe_put(TICKS_UNLIMITED) ...
|
||||
Testing task_pipe_put(timeout) ...
|
||||
Testing task_pipe_get() ...
|
||||
Testing task_pipe_get_wait() ...
|
||||
Testing task_pipe_get_wait_timeout() ...
|
||||
Testing task_pipe_get(TICKS_NONE) ...
|
||||
Testing task_pipe_get(TICKS_UNLIMITED) ...
|
||||
Testing task_pipe_get(timeout) ...
|
||||
===================================================================
|
||||
PROJECT EXECUTION SUCCESSFUL
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue