From 1ebcf42e0130097c5b02e69e26becb1ed6dfc5aa Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Wed, 10 Jan 2024 15:08:45 +0000 Subject: [PATCH] Fix #1432, Remove dependencies on SemGetInfo in functional tests OS_BinSemGetInfo and OS_CountSemGetInfo isn't fully implemented on RTEMS. Removed functional test dependencies on returning OS_SUCCESS on these calls. --- .../bin-sem-flush-test/bin-sem-flush-test.c | 38 ++-------------- .../bin-sem-timeout-test.c | 45 +++++-------------- src/tests/osal-core-test/osal-core-test.c | 10 ----- .../oscore-test/ut_oscore_binsem_test.c | 33 -------------- .../oscore-test/ut_oscore_countsem_test.c | 41 ----------------- src/unit-tests/oscore-test/ut_oscore_test.c | 2 - 6 files changed, 14 insertions(+), 155 deletions(-) diff --git a/src/tests/bin-sem-flush-test/bin-sem-flush-test.c b/src/tests/bin-sem-flush-test/bin-sem-flush-test.c index 1975732c9..506e4dd7c 100644 --- a/src/tests/bin-sem-flush-test/bin-sem-flush-test.c +++ b/src/tests/bin-sem-flush-test/bin-sem-flush-test.c @@ -72,16 +72,7 @@ void task_1(void) } else { - status = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); - if (status != OS_SUCCESS) - { - ++task_1_failures; - OS_printf("TASK 1: Error calling OS_BinSemGetInfo\n"); - } - else - { - OS_printf("TASK 1: out of BinSemTake: %d\n", (int)bin_sem_prop.value); - } + OS_printf("TASK 1: out of BinSemTake: %d\n", (int)bin_sem_prop.value); } while (1) @@ -112,16 +103,7 @@ void task_2(void) } else { - status = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); - if (status != OS_SUCCESS) - { - ++task_2_failures; - OS_printf("TASK 2: Error calling OS_BinSemGetInfo\n"); - } - else - { - OS_printf("TASK 2: out of BinSemTake: %d\n", (int)bin_sem_prop.value); - } + OS_printf("TASK 2: out of BinSemTake: %d\n", (int)bin_sem_prop.value); } while (1) @@ -151,16 +133,7 @@ void task_3(void) } else { - status = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); - if (status != OS_SUCCESS) - { - ++task_3_failures; - OS_printf("TASK 3: Error calling OS_BinSemGetInfo\n"); - } - else - { - OS_printf("TASK 3: out of BinSemTake: %d\n", (int)bin_sem_prop.value); - } + OS_printf("TASK 3: out of BinSemTake: %d\n", (int)bin_sem_prop.value); } while (1) @@ -214,16 +187,11 @@ void BinSemFlushSetup(void) status = OS_BinSemCreate(&bin_sem_id, "BinSem1", 1, 0); UtAssert_True(status == OS_SUCCESS, "BinSem1 create Id=%lx Rc=%d", OS_ObjectIdToInteger(bin_sem_id), (int)status); - status = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); - UtAssert_True(status == OS_SUCCESS, "BinSem1 value=%d Rc=%d", (int)bin_sem_prop.value, (int)status); - /* ** Take the semaphore so the value is 0 and the next SemTake call should block */ status = OS_BinSemTake(bin_sem_id); UtAssert_True(status == OS_SUCCESS, "BinSem1 take Rc=%d", (int)status); - status = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); - UtAssert_True(status == OS_SUCCESS, "BinSem1 value=%d Rc=%d", (int)bin_sem_prop.value, (int)status); /* ** Create the tasks diff --git a/src/tests/bin-sem-timeout-test/bin-sem-timeout-test.c b/src/tests/bin-sem-timeout-test/bin-sem-timeout-test.c index 4a3dc4ba2..00ad53dc7 100644 --- a/src/tests/bin-sem-timeout-test/bin-sem-timeout-test.c +++ b/src/tests/bin-sem-timeout-test/bin-sem-timeout-test.c @@ -76,22 +76,6 @@ void TimerFunction(osal_id_t local_timer_id) { ++timer_function_failures; } - - { - status = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); - if (status != OS_SUCCESS) - { - ++timer_function_failures; - } - else if (bin_sem_prop.value > 1) - { - ++timer_function_failures; - } - else if (bin_sem_prop.value < -1) - { - ++timer_function_failures; - } - } } void task_1(void) @@ -115,20 +99,18 @@ void task_1(void) { OS_printf("TASK 1: Doing some work: %d\n", (int)counter++); status = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); - if (status != OS_SUCCESS) - { - OS_printf("Error: OS_BinSemGetInfo\n"); - ++task_1_failures; - } - else if (bin_sem_prop.value > 1) + if (status == OS_SUCCESS) { - OS_printf("Error: Binary sem value > 1 ( in task):%d !\n", (int)bin_sem_prop.value); - ++task_1_failures; - } - else if (bin_sem_prop.value < -1) - { - OS_printf("Error: Binary sem value < -1 ( in task):%d !\n", (int)bin_sem_prop.value); - ++task_1_failures; + if (bin_sem_prop.value > 1) + { + OS_printf("Error: Binary sem value > 1 ( in task):%d !\n", (int)bin_sem_prop.value); + ++task_1_failures; + } + else if (bin_sem_prop.value < -1) + { + OS_printf("Error: Binary sem value < -1 ( in task):%d !\n", (int)bin_sem_prop.value); + ++task_1_failures; + } } } else if (status == OS_SEM_TIMEOUT) @@ -211,16 +193,11 @@ void BinSemTimeoutSetup(void) status = OS_BinSemCreate(&bin_sem_id, "BinSem1", 1, 0); UtAssert_True(status == OS_SUCCESS, "BinSem1 create Id=%lx Rc=%d", OS_ObjectIdToInteger(bin_sem_id), (int)status); - status = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); - UtAssert_True(status == OS_SUCCESS, "BinSem1 value=%d Rc=%d", (int)bin_sem_prop.value, (int)status); - /* ** Take the semaphore so the value is 0 and the next SemTake call should block */ status = OS_BinSemTake(bin_sem_id); UtAssert_True(status == OS_SUCCESS, "BinSem1 take Rc=%d", (int)status); - status = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); - UtAssert_True(status == OS_SUCCESS, "BinSem1 value=%d Rc=%d", (int)bin_sem_prop.value, (int)status); /* ** Create the "consumer" task. diff --git a/src/tests/osal-core-test/osal-core-test.c b/src/tests/osal-core-test/osal-core-test.c index 2f07df408..bd2e37c59 100644 --- a/src/tests/osal-core-test/osal-core-test.c +++ b/src/tests/osal-core-test/osal-core-test.c @@ -549,7 +549,6 @@ void TestGetInfos(void) int status; OS_task_prop_t task_prop; OS_queue_prop_t queue_prop; - OS_bin_sem_prop_t bin_prop; OS_mut_sem_prop_t mut_prop; /* first step is to create an object to to get the properties of */ @@ -561,9 +560,6 @@ void TestGetInfos(void) status = OS_QueueCreate(&msgq_0, "q 0", OSAL_BLOCKCOUNT_C(MSGQ_DEPTH), OSAL_SIZE_C(MSGQ_SIZE), 0); UtAssert_True(status == OS_SUCCESS, "OS_QueueCreate"); - status = OS_BinSemCreate(&bin_0, "Bin 0", 1, 0); - UtAssert_True(status == OS_SUCCESS, "OS_BinSemCreate"); - status = OS_MutSemCreate(&mut_0, "Mut 0", 0); UtAssert_True(status == OS_SUCCESS, "OS_MutSemCreate"); @@ -575,9 +571,6 @@ void TestGetInfos(void) status = OS_QueueGetInfo(msgq_0, &queue_prop); UtAssert_True(status == OS_SUCCESS, "OS_QueueGetInfo"); - status = OS_BinSemGetInfo(bin_0, &bin_prop); - UtAssert_True(status == OS_SUCCESS, "OS_BinSemGetInfo"); - status = OS_MutSemGetInfo(mut_0, &mut_prop); UtAssert_True(status == OS_SUCCESS, "OS_MutSemGetInfo"); @@ -587,9 +580,6 @@ void TestGetInfos(void) status = OS_QueueDelete(msgq_0); UtAssert_True(status == OS_SUCCESS, "OS_QueueDelete"); - status = OS_BinSemDelete(bin_0); - UtAssert_True(status == OS_SUCCESS, "OS_BinSemDelete"); - status = OS_MutSemDelete(mut_0); UtAssert_True(status == OS_SUCCESS, "OS_MutSemDelete"); } diff --git a/src/unit-tests/oscore-test/ut_oscore_binsem_test.c b/src/unit-tests/oscore-test/ut_oscore_binsem_test.c index 83f5f49d7..e40f41dcb 100644 --- a/src/unit-tests/oscore-test/ut_oscore_binsem_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_binsem_test.c @@ -288,39 +288,6 @@ void UT_os_bin_sem_get_id_by_name_test() } } -/*--------------------------------------------------------------------------------* -** Syntax: OS_BinSemGetInfo -** Purpose: Returns semaphore information about the given binary semaphore id -** Parameters: To-be-filled-in -** Returns: OS_INVALID_POINTER if the pointer passed in is null -** OS_ERR_INVALID_ID if the id passed in is not a valid binary semaphore id -** OS_SUCCESS if succeeded -** Test #1: TBD -**--------------------------------------------------------------------------------*/ -void UT_os_bin_sem_get_info_test() -{ - osal_id_t bin_sem_id = OS_OBJECT_ID_UNDEFINED; - OS_bin_sem_prop_t bin_sem_prop; - - /*-----------------------------------------------------*/ - UT_RETVAL(OS_BinSemGetInfo(UT_OBJID_INCORRECT, &bin_sem_prop), OS_ERR_INVALID_ID); - UT_RETVAL(OS_BinSemGetInfo(OS_OBJECT_ID_UNDEFINED, &bin_sem_prop), OS_ERR_INVALID_ID); - - /*-----------------------------------------------------*/ - if (UT_SETUP(OS_BinSemCreate(&bin_sem_id, "GetInfo", 1, 0))) - { - UT_RETVAL(OS_BinSemGetInfo(bin_sem_id, NULL), OS_INVALID_POINTER); - UT_TEARDOWN(OS_BinSemDelete(bin_sem_id)); - } - - /*-----------------------------------------------------*/ - if (UT_SETUP(OS_BinSemCreate(&bin_sem_id, "GetInfo", 1, 0))) - { - UT_NOMINAL(OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop)); - UT_TEARDOWN(OS_BinSemDelete(bin_sem_id)); - } -} - /*================================================================================* ** End of File: ut_oscore_binsem_test.c **================================================================================*/ diff --git a/src/unit-tests/oscore-test/ut_oscore_countsem_test.c b/src/unit-tests/oscore-test/ut_oscore_countsem_test.c index 786c13aff..8d9f8df4f 100644 --- a/src/unit-tests/oscore-test/ut_oscore_countsem_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_countsem_test.c @@ -330,47 +330,6 @@ void UT_os_count_sem_get_id_by_name_test() } } -/*--------------------------------------------------------------------------------* -** Syntax: OS_CountSemGetInfo -** Purpose: Returns semaphore information about the given binary semaphore id -** Parameters: To-be-filled-in -** Returns: OS_INVALID_POINTER if the pointer passed in is null -** OS_ERR_INVALID_ID if the id passed in is not a valid binary semaphore id -** OS_SUCCESS if succeeded -**--------------------------------------------------------------------------------*/ -void UT_os_count_sem_get_info_test() -{ - osal_id_t count_sem_id = OS_OBJECT_ID_UNDEFINED; - OS_count_sem_prop_t count_sem_prop; - - /*-----------------------------------------------------*/ - /* #1 Invalid-ID-arg */ - - UT_RETVAL(OS_CountSemGetInfo(UT_OBJID_INCORRECT, &count_sem_prop), OS_ERR_INVALID_ID); - UT_RETVAL(OS_CountSemGetInfo(OS_OBJECT_ID_UNDEFINED, &count_sem_prop), OS_ERR_INVALID_ID); - - /*-----------------------------------------------------*/ - /* #2 Invalid-pointer-arg */ - - if (UT_SETUP(OS_CountSemCreate(&count_sem_id, "GetInfo", 1, 0))) - { - UT_RETVAL(OS_CountSemGetInfo(count_sem_id, NULL), OS_INVALID_POINTER); - - UT_TEARDOWN(OS_CountSemDelete(count_sem_id)); - } - - /*-----------------------------------------------------*/ - /* #3 Nominal */ - - /* Setup */ - if (UT_SETUP(OS_CountSemCreate(&count_sem_id, "GetInfo", 1, 0))) - { - UT_NOMINAL(OS_CountSemGetInfo(count_sem_id, &count_sem_prop)); - - UT_TEARDOWN(OS_CountSemDelete(count_sem_id)); - } -} - /*================================================================================* ** End of File: ut_oscore_countsem_test.c **================================================================================*/ diff --git a/src/unit-tests/oscore-test/ut_oscore_test.c b/src/unit-tests/oscore-test/ut_oscore_test.c index f0495fdb3..5cf5afc0f 100644 --- a/src/unit-tests/oscore-test/ut_oscore_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_test.c @@ -203,7 +203,6 @@ void UtTest_Setup(void) UtTest_Add(UT_os_bin_sem_take_test, NULL, NULL, "OS_BinSemTake"); UtTest_Add(UT_os_bin_sem_timed_wait_test, NULL, NULL, "OS_BinSemTimedWait"); UtTest_Add(UT_os_bin_sem_get_id_by_name_test, NULL, NULL, "OS_BinSemGetIdByName"); - UtTest_Add(UT_os_bin_sem_get_info_test, NULL, NULL, "OS_BinSemGetInfo"); UtTest_Add(UT_os_count_sem_create_test, NULL, NULL, "OS_CountSemCreate"); UtTest_Add(UT_os_count_sem_delete_test, NULL, NULL, "OS_CountSemDelete"); @@ -211,7 +210,6 @@ void UtTest_Setup(void) UtTest_Add(UT_os_count_sem_take_test, NULL, NULL, "OS_CountSemTake"); UtTest_Add(UT_os_count_sem_timed_wait_test, NULL, NULL, "OS_CountSemTimedWait"); UtTest_Add(UT_os_count_sem_get_id_by_name_test, NULL, NULL, "OS_CountSemGetIdByName"); - UtTest_Add(UT_os_count_sem_get_info_test, NULL, NULL, "OS_CountSemGetInfo"); UtTest_Add(UT_os_mut_sem_create_test, NULL, NULL, "OS_MutSemCreate"); UtTest_Add(UT_os_mut_sem_delete_test, NULL, NULL, "OS_MutSemDelete");