Skip to content

Commit 3bcb137

Browse files
authored
Merge pull request nasa#1512 from nasa/integration-candidate
osal Integration candidate: Equuleus-rc1+dev31
2 parents a77b5bd + ded2540 commit 3bcb137

File tree

6 files changed

+69
-22
lines changed

6 files changed

+69
-22
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## Development Build: equuleus-rc1+dev123
4+
- 'Fix #1445, add conditional around priority sem test'
5+
- See: <https://github.com/nasa/osal/pull/1509>
6+
7+
38
## Development Build: equuleus-rc1+dev117
49
- 'Fix nasa/cFS#839, Update Workflows to Ubuntu 22.04'
510
- See: <https://github.com/nasa/osal/pull/1506>

src/os/inc/osapi-version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
/*
3535
* Development Build Macro Definitions
3636
*/
37-
#define OS_BUILD_NUMBER 117
37+
#define OS_BUILD_NUMBER 123
3838
#define OS_BUILD_BASELINE "equuleus-rc1"
3939
#define OS_BUILD_DEV_CYCLE "equuleus-rc2" /**< @brief Development: Release name for current development cycle */
4040
#define OS_BUILD_CODENAME "Equuleus" /**< @brief: Development: Code name for the current build */

src/os/posix/src/os-impl-tasks.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,8 @@ int32 OS_Posix_TaskAPI_Impl_Init(void)
412412
*/
413413
POSIX_GlobalVars.SelectedRtScheduler = sched_policy;
414414
POSIX_GlobalVars.EnableTaskPriorities = true;
415-
} while (0);
415+
}
416+
while (0);
416417
}
417418
else
418419
{
@@ -549,7 +550,6 @@ int32 OS_Posix_InternalTaskCreate_Impl(pthread_t *pthr, osal_priority_t priority
549550
OS_DEBUG("pthread_attr_setschedparam error in OS_TaskCreate: %s\n", strerror(return_code));
550551
return OS_ERROR;
551552
}
552-
553553
} /* End if user is root */
554554

555555
/*
@@ -598,6 +598,12 @@ int32 OS_TaskCreate_Impl(const OS_object_token_t *token, uint32 flags)
598598
task = OS_OBJECT_TABLE_GET(OS_task_table, *token);
599599
impl = OS_OBJECT_TABLE_GET(OS_impl_task_table, *token);
600600

601+
/* If task priorities are not enabled then override the user-supplied priority value */
602+
if (!POSIX_GlobalVars.EnableTaskPriorities)
603+
{
604+
task->priority = OS_MAX_TASK_PRIORITY;
605+
}
606+
601607
return_code = OS_Posix_InternalTaskCreate_Impl(&impl->id, task->priority, task->stack_pointer, task->stack_size,
602608
OS_PthreadTaskEntry, arg.opaque_arg);
603609

@@ -736,7 +742,8 @@ int32 OS_TaskDelay_Impl(uint32 millisecond)
736742
do
737743
{
738744
status = clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &sleep_end, NULL);
739-
} while (status == EINTR);
745+
}
746+
while (status == EINTR);
740747

741748
if (status != 0)
742749
{

src/tests/bin-sem-test/bin-sem-test.c

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ void Test_BinSem(void)
7676
osal_id_t task_id[3];
7777
char long_name[OS_MAX_API_NAME + 1];
7878
OS_bin_sem_prop_t sem_prop;
79+
OS_task_prop_t task_prop;
7980
uint32 test_val;
8081
bool get_info_implemented;
8182

@@ -174,28 +175,44 @@ void Test_BinSem(void)
174175

175176
/* Start 3 child tasks, give and confirm highest priority task increments, flush and confirm all three */
176177
UtAssert_INT32_EQ(
177-
OS_TaskCreate(&task_id[0], "Task_0", Test_BinSem_Task0, NULL, TASK_STACK_SIZE, OSAL_PRIORITY_C(100), 0),
178+
OS_TaskCreate(&task_id[0], "Task_0", Test_BinSem_Task0, NULL, TASK_STACK_SIZE, OSAL_PRIORITY_C(200), 0),
178179
OS_SUCCESS);
180+
OS_TaskDelay(50);
179181
UtAssert_INT32_EQ(
180-
OS_TaskCreate(&task_id[1], "Task_1", Test_BinSem_Task1, NULL, TASK_STACK_SIZE, OSAL_PRIORITY_C(200), 0),
182+
OS_TaskCreate(&task_id[1], "Task_1", Test_BinSem_Task1, NULL, TASK_STACK_SIZE, OSAL_PRIORITY_C(100), 0),
181183
OS_SUCCESS);
182184
UtAssert_INT32_EQ(
183185
OS_TaskCreate(&task_id[2], "Task_2", Test_BinSem_Task2, NULL, TASK_STACK_SIZE, OSAL_PRIORITY_C(250), 0),
184186
OS_SUCCESS);
185-
OS_TaskDelay(100);
187+
OS_TaskDelay(50);
186188
UtAssert_UINT32_EQ(task_counter[0] + task_counter[1] + task_counter[2], 0);
187-
UtAssert_INT32_EQ(OS_BinSemGive(sem_id[0]), OS_SUCCESS);
188-
OS_TaskDelay(100);
189-
UtAssert_UINT32_EQ(task_counter[0], 1);
190-
UtAssert_UINT32_EQ(task_counter[1] + task_counter[2], 0);
191189
UtAssert_INT32_EQ(OS_BinSemFlush(sem_id[0]), OS_SUCCESS);
192190
OS_TaskDelay(100);
193-
UtAssert_UINT32_EQ(task_counter[0], 2);
191+
UtAssert_UINT32_EQ(task_counter[0], 1);
194192
UtAssert_UINT32_EQ(task_counter[1], 1);
195193
UtAssert_UINT32_EQ(task_counter[2], 1);
196194

195+
test_val = 3;
196+
197+
/* In permissive mode, priorities are not enforced, and thus there is no
198+
* guarantee of which task will run first. If priorities are enabled then
199+
* it should be guaranteed that Task_1 will get the sem first. By getting the
200+
* task properties we can check if the priority is in effect */
201+
UtAssert_INT32_EQ(OS_TaskGetInfo(task_id[1], &task_prop), OS_SUCCESS);
202+
if (task_prop.priority == OSAL_PRIORITY_C(100))
203+
{
204+
UtAssert_INT32_EQ(OS_BinSemGive(sem_id[0]), OS_SUCCESS);
205+
OS_TaskDelay(100);
206+
UtAssert_UINT32_EQ(task_counter[1], 2);
207+
UtAssert_UINT32_EQ(task_counter[2] + task_counter[2], 2);
208+
++test_val;
209+
}
210+
else
211+
{
212+
UtPrintf("Task Priorities not in effect, skipping sem priority test");
213+
}
214+
197215
/* Give loop for tasks to complete */
198-
test_val = 4;
199216
while (test_val < 9)
200217
{
201218
test_val++;

src/tests/count-sem-test/count-sem-test.c

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ void Test_CountSem(void)
7676
osal_id_t task_id[3];
7777
char long_name[OS_MAX_API_NAME + 1];
7878
OS_count_sem_prop_t sem_prop;
79+
OS_task_prop_t task_prop;
7980
uint32 test_val;
8081
bool get_info_implemented;
8182

@@ -176,23 +177,38 @@ void Test_CountSem(void)
176177

177178
/* Start 3 child tasks, give and confirm highest priority task increments, flush and confirm all three */
178179
UtAssert_INT32_EQ(
179-
OS_TaskCreate(&task_id[0], "Task_0", Test_CountSem_Task0, NULL, TASK_STACK_SIZE, OSAL_PRIORITY_C(100), 0),
180+
OS_TaskCreate(&task_id[0], "Task_0", Test_CountSem_Task0, NULL, TASK_STACK_SIZE, OSAL_PRIORITY_C(200), 0),
180181
OS_SUCCESS);
182+
OS_TaskDelay(50);
181183
UtAssert_INT32_EQ(
182-
OS_TaskCreate(&task_id[1], "Task_1", Test_CountSem_Task1, NULL, TASK_STACK_SIZE, OSAL_PRIORITY_C(200), 0),
184+
OS_TaskCreate(&task_id[1], "Task_1", Test_CountSem_Task1, NULL, TASK_STACK_SIZE, OSAL_PRIORITY_C(100), 0),
183185
OS_SUCCESS);
184186
UtAssert_INT32_EQ(
185187
OS_TaskCreate(&task_id[2], "Task_2", Test_CountSem_Task2, NULL, TASK_STACK_SIZE, OSAL_PRIORITY_C(250), 0),
186188
OS_SUCCESS);
187-
OS_TaskDelay(100);
189+
OS_TaskDelay(50);
188190
UtAssert_UINT32_EQ(task_counter[0] + task_counter[1] + task_counter[2], 0);
189-
UtAssert_INT32_EQ(OS_CountSemGive(sem_id[0]), OS_SUCCESS);
190-
OS_TaskDelay(100);
191-
UtAssert_UINT32_EQ(task_counter[0], 1);
192-
UtAssert_UINT32_EQ(task_counter[1] + task_counter[2], 0);
191+
test_val = 0;
192+
193+
/* In permissive mode, priorities are not enforced, and thus there is no
194+
* guarantee of which task will run first. If priorities are enabled then
195+
* it should be guaranteed that Task_1 will get the sem first. By getting the
196+
* task properties we can check if the priority is in effect */
197+
UtAssert_INT32_EQ(OS_TaskGetInfo(task_id[1], &task_prop), OS_SUCCESS);
198+
if (task_prop.priority == OSAL_PRIORITY_C(100))
199+
{
200+
UtAssert_INT32_EQ(OS_CountSemGive(sem_id[0]), OS_SUCCESS);
201+
OS_TaskDelay(100);
202+
UtAssert_UINT32_EQ(task_counter[1], 1);
203+
UtAssert_UINT32_EQ(task_counter[0] + task_counter[2], 0);
204+
++test_val;
205+
}
206+
else
207+
{
208+
UtPrintf("Task Priorities not in effect, skipping sem priority test");
209+
}
193210

194211
/* Give loop for tasks to complete */
195-
test_val = 1;
196212
while (test_val < 9)
197213
{
198214
test_val++;

ut_assert/inc/utstubs.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,14 @@ void UT_SetHookFunction(UT_EntryKey_t FuncKey, UT_HookFunc_t HookFunc, void *Use
317317
*
318318
* This allows the user to completely replace the handler for a given function.
319319
*
320+
* If both a handler and a hook function are set, the hook is called first, then the handler.
321+
*
320322
* The handler assumes all responsibility for the final behavior of the stub,
321323
* including translating return values, and any outputs/side effects the stub
322324
* function should have. The default handler for the stub is NOT used.
323325
*
324326
* \param FuncKey The stub function to add the hook to.
325-
* \param HandlerFunc User defined hook function. Set NULL to delete/clear an entry.
327+
* \param HandlerFunc User defined handler function. Set NULL to delete/clear an entry.
326328
* \param UserObj Arbitrary user data object to pass to the hook function
327329
*/
328330
void UT_SetHandlerFunction(UT_EntryKey_t FuncKey, UT_HandlerFunc_t HandlerFunc, void *UserObj);

0 commit comments

Comments
 (0)