From 0058ceb2188eb89443f9f7b587fb130ce74eb775 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 3 Jun 2021 17:56:07 -0400 Subject: [PATCH] Partial #1052, Queue test cases --- src/os/shared/src/osapi-queue.c | 2 ++ src/unit-test-coverage/shared/src/coveragetest-queue.c | 4 ++++ src/unit-tests/oscore-test/ut_oscore_queue_test.c | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/src/os/shared/src/osapi-queue.c b/src/os/shared/src/osapi-queue.c index f50278f8e..24a303577 100644 --- a/src/os/shared/src/osapi-queue.c +++ b/src/os/shared/src/osapi-queue.c @@ -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) @@ -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) diff --git a/src/unit-test-coverage/shared/src/coveragetest-queue.c b/src/unit-test-coverage/shared/src/coveragetest-queue.c index a9493e87f..e7bbabbe6 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-queue.c +++ b/src/unit-test-coverage/shared/src/coveragetest-queue.c @@ -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) @@ -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) diff --git a/src/unit-tests/oscore-test/ut_oscore_queue_test.c b/src/unit-tests/oscore-test/ut_oscore_queue_test.c index f69faa716..89bd258b5 100644 --- a/src/unit-tests/oscore-test/ut_oscore_queue_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_queue_test.c @@ -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 */ @@ -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 */ @@ -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)); } @@ -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 */ @@ -412,6 +417,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 */