Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #424, Add looping wait for self exiting task #426

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions src/tests/osal-core-test/osal-core-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#include "uttest.h"
#include "utbsp.h"

/* Defines */
#define UT_EXIT_LOOP_MAX 100 /* Used to limit wait for self-exiting task to exit */

/* OS Constructs */

void TestTasks (void);
Expand Down Expand Up @@ -73,6 +76,8 @@ void TestTasks(void)
int tasknum;
uint32 saved_task0_id;
static TestTaskData TaskData[OS_MAX_TASKS + 1];
OS_task_prop_t taskprop;
int loopcnt;

/* OS_TaskRegister(); */

Expand Down Expand Up @@ -118,16 +123,20 @@ void TestTasks(void)
status = OS_TaskCreate( &TaskData[tasknum].task_id, taskname, task_generic_with_exit, TaskData[tasknum].task_stack,
TASK_0_STACK_SIZE, (250 - OS_MAX_TASKS) + tasknum, 0);

/*
* A small delay in this parent task to allow the child task to run.
* It should exit immediately....
*/
OS_TaskDelay(10);

UtDebug("Create %s Status = %d, Id = %d\n",taskname,(int)status,(int)TaskData[tasknum].task_id);

UtAssert_True(status == OS_SUCCESS, "OS_TaskCreate, self exiting task");

/* Looping delay in parent task to wait for child task to exit */
loopcnt = 0;
while ((OS_TaskGetInfo(TaskData[tasknum].task_id, &taskprop) == OS_SUCCESS) && (loopcnt < UT_EXIT_LOOP_MAX))
{
OS_TaskDelay(10);
loopcnt++;
}
UtDebug("Looped %d times waiting for child task Id %d to exit\n", loopcnt, (int)TaskData[tasknum].task_id);
UtAssert_True(loopcnt < UT_EXIT_LOOP_MAX, "Looped %d times without self-exiting task exiting", loopcnt);

/*
* Attempting to delete the task that exited itself should always fail
*/
Expand Down