Skip to content

Commit

Permalink
Partial #1052, Queue test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
jphickey committed Jun 3, 2021
1 parent 041724f commit 205cdc3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/os/shared/src/osapi-queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ int32 OS_QueueGet(osal_id_t queue_id, void *data, size_t size, size_t *size_copi
/* Check Parameters */
OS_CHECK_POINTER(data);
OS_CHECK_POINTER(size_copied);
OS_CHECK_SIZE(size);

return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, queue_id, &token);
if (return_code == OS_SUCCESS)
Expand Down Expand Up @@ -205,6 +206,7 @@ int32 OS_QueuePut(osal_id_t queue_id, const void *data, size_t size, uint32 flag

/* Check Parameters */
OS_CHECK_POINTER(data);
OS_CHECK_SIZE(size);

return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, queue_id, &token);
if (return_code == OS_SUCCESS)
Expand Down
4 changes: 4 additions & 0 deletions src/unit-test-coverage/shared/src/coveragetest-queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ void Test_OS_QueueGet(void)
expected = OS_QUEUE_INVALID_SIZE;
actual = OS_QueueGet(UT_OBJID_1, Buf, sizeof(Buf), &actual_size, 0);
UtAssert_True(actual == expected, "OS_QueueGet() (%ld) == OS_QUEUE_INVALID_SIZE", (long)actual);

OSAPI_TEST_FUNCTION_RC(OS_QueueGet(UT_OBJID_1, Buf, 0, &actual_size, 0), OS_ERR_INVALID_SIZE);
}

void Test_OS_QueuePut(void)
Expand All @@ -144,6 +146,8 @@ void Test_OS_QueuePut(void)
expected = OS_QUEUE_INVALID_SIZE;
actual = OS_QueuePut(UT_OBJID_1, Data, 1 + sizeof(Data), 0);
UtAssert_True(actual == expected, "OS_QueuePut() (%ld) == OS_QUEUE_INVALID_SIZE", (long)actual);

OSAPI_TEST_FUNCTION_RC(OS_QueuePut(UT_OBJID_1, Data, 0, 0), OS_ERR_INVALID_SIZE);
}

void Test_OS_QueueGetIdByName(void)
Expand Down
8 changes: 8 additions & 0 deletions src/unit-tests/oscore-test/ut_oscore_queue_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ void UT_os_queue_delete_test()
/* #1 Invalid-ID-arg */

UT_RETVAL(OS_QueueDelete(UT_OBJID_INCORRECT), OS_ERR_INVALID_ID);
UT_RETVAL(OS_QueueDelete(OS_OBJECT_ID_UNDEFINED), OS_ERR_INVALID_ID);

/*-----------------------------------------------------*/
/* #3 Nominal */
Expand Down Expand Up @@ -195,6 +196,8 @@ void UT_os_queue_get_test()

UT_RETVAL(OS_QueueGet(UT_OBJID_INCORRECT, (void *)&queue_data_in, sizeof(uint32), &size_copied, OS_CHECK),
OS_ERR_INVALID_ID);
UT_RETVAL(OS_QueueGet(OS_OBJECT_ID_UNDEFINED, (void *)&queue_data_in, sizeof(uint32), &size_copied, OS_CHECK),
OS_ERR_INVALID_ID);

/*-----------------------------------------------------*/
/* #2 Invalid-pointer-arg-1 */
Expand All @@ -205,6 +208,7 @@ void UT_os_queue_get_test()
{
UT_RETVAL(OS_QueueGet(queue_id, NULL, sizeof(uint32), &size_copied, OS_CHECK), OS_INVALID_POINTER);
UT_RETVAL(OS_QueueGet(queue_id, &queue_data_in, sizeof(uint32), NULL, OS_CHECK), OS_INVALID_POINTER);
UT_RETVAL(OS_QueueGet(queue_id, &queue_data_in, 0, &size_copied, OS_CHECK), OS_ERR_INVALID_SIZE);

UT_TEARDOWN(OS_QueueDelete(queue_id));
}
Expand Down Expand Up @@ -304,6 +308,7 @@ void UT_os_queue_put_test()
/* #1 Invalid-ID-arg */

UT_RETVAL(OS_QueuePut(UT_OBJID_INCORRECT, (void *)&queue_data_out, sizeof(uint32), 0), OS_ERR_INVALID_ID);
UT_RETVAL(OS_QueuePut(OS_OBJECT_ID_UNDEFINED, (void *)&queue_data_out, sizeof(uint32), 0), OS_ERR_INVALID_ID);

/*-----------------------------------------------------*/
/* #2 Invalid-pointer-arg */
Expand All @@ -313,6 +318,8 @@ void UT_os_queue_put_test()
{
UT_RETVAL(OS_QueuePut(queue_id, NULL, sizeof(uint32), 0), OS_INVALID_POINTER);
UT_RETVAL(OS_QueuePut(queue_id, &queue_data_out, sizeof(uint32) + 1, 0), OS_QUEUE_INVALID_SIZE);
UT_RETVAL(OS_QueuePut(queue_id, &queue_data_out, 0, 0), OS_ERR_INVALID_SIZE);

UT_TEARDOWN(OS_QueueDelete(queue_id));
}

Expand Down Expand Up @@ -412,6 +419,7 @@ void UT_os_queue_get_info_test()
/* #1 Invalid-ID-arg */

UT_RETVAL(OS_QueueGetInfo(UT_OBJID_INCORRECT, &queue_prop), OS_ERR_INVALID_ID);
UT_RETVAL(OS_QueueGetInfo(OS_OBJECT_ID_UNDEFINED, &queue_prop), OS_ERR_INVALID_ID);

/*-----------------------------------------------------*/
/* #2 Invalid-pointer-arg */
Expand Down

0 comments on commit 205cdc3

Please sign in to comment.