Skip to content

Commit

Permalink
Fix #1432, Remove dependencies on SemGetInfo in functional tests
Browse files Browse the repository at this point in the history
OS_BinSemGetInfo and OS_CountSemGetInfo isn't fully implemented on RTEMS.
Removed functional test dependencies on returning OS_SUCCESS on these calls.
  • Loading branch information
skliper committed Jan 10, 2024
1 parent 46c65e6 commit 1ebcf42
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 155 deletions.
38 changes: 3 additions & 35 deletions src/tests/bin-sem-flush-test/bin-sem-flush-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
45 changes: 11 additions & 34 deletions src/tests/bin-sem-timeout-test/bin-sem-timeout-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 0 additions & 10 deletions src/tests/osal-core-test/osal-core-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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");

Expand All @@ -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");

Expand All @@ -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");
}
Expand Down
33 changes: 0 additions & 33 deletions src/unit-tests/oscore-test/ut_oscore_binsem_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
**================================================================================*/
41 changes: 0 additions & 41 deletions src/unit-tests/oscore-test/ut_oscore_countsem_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
**================================================================================*/
2 changes: 0 additions & 2 deletions src/unit-tests/oscore-test/ut_oscore_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,13 @@ 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");
UtTest_Add(UT_os_count_sem_give_test, NULL, NULL, "OS_CountSemGive");
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");
Expand Down

0 comments on commit 1ebcf42

Please sign in to comment.