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 #755, resolve subtasks not ending on time #756

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
45 changes: 13 additions & 32 deletions src/tests/select-test/select-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ OS_SockAddr_t s2_addr;
OS_SockAddr_t c_addr;
OS_SockAddr_t c2_addr;
osal_id_t bin_sem_id;
osal_id_t bin_sem_id2;

/* *************************************** MAIN ************************************** */

Expand All @@ -67,24 +66,16 @@ void BinSemSetup(void)
{
uint32 status;
OS_bin_sem_prop_t bin_sem_prop;
OS_bin_sem_prop_t bin_sem_prop2;

/*
* Create the binary semaphore
* BinSem1 is used to control when the server can accept connections
* BinSem2 is used to make sure all sub task finish before the main task does.
*/
status = OS_BinSemCreate(&bin_sem_id, "BinSem1", 0, 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);

status = OS_BinSemCreate(&bin_sem_id2, "BinSem2", 0, 0);
UtAssert_True(status == OS_SUCCESS, "BinSem2 create Id=%lx Rc=%d", OS_ObjectIdToInteger(bin_sem_id2), (int)status);

status = OS_BinSemGetInfo(bin_sem_id2, &bin_sem_prop2);
UtAssert_True(status == OS_SUCCESS, "BinSem2 value=%d Rc=%d", (int)bin_sem_prop2.value, (int)status);
}

void Setup_Server(void)
Expand Down Expand Up @@ -167,9 +158,6 @@ void Server_Fn(void)

status = OS_close(connsock_id);
UtAssert_True(status == OS_SUCCESS, "status after close connsock_id = %d", (int)status);

status = OS_BinSemGive(bin_sem_id2);
UtAssert_True(status == OS_SUCCESS, "BinSem2 Server 1 give Rc=%d", (int)status);
} /* end Server_Fn */

void Setup_Server2(void)
Expand Down Expand Up @@ -267,24 +255,17 @@ void Setup_Multi(void)

void Teardown_Single(void)
{
uint32 status;

OS_close(c_socket_id);
status = OS_BinSemTake(bin_sem_id2);
UtAssert_True(status == OS_SUCCESS, "BinSem2 Teardown single take Rc=%d", (int)status);

OS_BinSemDelete(bin_sem_id);
OS_BinSemDelete(bin_sem_id2);
OS_close(c_socket_id);
OS_BinSemDelete(bin_sem_id);
}

void Teardown_Multi(void)
{
uint32 status;

status = OS_BinSemGive(bin_sem_id);
UtAssert_True(status == OS_SUCCESS, "BinSem1 Teardown multi give Rc=%d", (int)status);
{
//Server 1 is intentionaly left waiting so we close it out here.
OS_close(s_socket_id);
OS_TaskDelete(s_task_id);

OS_close(c2_socket_id);
OS_close(c2_socket_id);
Teardown_Single();
}

Expand All @@ -303,7 +284,7 @@ void TestSelectSingleRead(void)
*/

/* Create a server task/thread */
int32 status = OS_TaskCreate(&s_task_id, "Server", Server_Fn, OSAL_TASK_STACK_ALLOCATE, OSAL_SIZE_C(16384),
int32 status = OS_TaskCreate(&s_task_id, "ServerSingleRead", Server_Fn, OSAL_TASK_STACK_ALLOCATE, OSAL_SIZE_C(16384),
OSAL_PRIORITY_C(50), 0);
UtAssert_True(status == OS_SUCCESS, "OS_TaskCreate() (%ld) == OS_SUCCESS", (long)status);

Expand Down Expand Up @@ -353,15 +334,15 @@ void TestSelectMultipleRead(void)
*/

/* Create a server task/thread */
status = OS_TaskCreate(&s_task_id, "Server", Server_Fn, OSAL_TASK_STACK_ALLOCATE, OSAL_SIZE_C(16384),
status = OS_TaskCreate(&s_task_id, "ServerMultiRead", Server_Fn, OSAL_TASK_STACK_ALLOCATE, OSAL_SIZE_C(16384),
OSAL_PRIORITY_C(50), 0);
UtAssert_True(status == OS_SUCCESS, "OS_TaskCreate() (%ld) == OS_SUCCESS", (long)status);

/* Connect to a server */
actual = OS_SocketConnect(c_socket_id, &s_addr, 10);
UtAssert_True(actual == expected, "OS_SocketConnect() (%ld) == OS_SUCCESS", (long)actual);

status = OS_TaskCreate(&s2_task_id, "Server2", Server_Fn2, OSAL_TASK_STACK_ALLOCATE, OSAL_SIZE_C(16384),
status = OS_TaskCreate(&s2_task_id, "ServerMultiRead2", Server_Fn2, OSAL_TASK_STACK_ALLOCATE, OSAL_SIZE_C(16384),
OSAL_PRIORITY_C(50), 0);
UtAssert_True(status == OS_SUCCESS, "OS_TaskCreate() (%ld) == OS_SUCCESS", (long)status);

Expand Down Expand Up @@ -402,7 +383,7 @@ void TestSelectSingleWrite(void)
*/

/* Create a server task/thread */
int32 status = OS_TaskCreate(&s_task_id, "Server", Server_Fn, OSAL_TASK_STACK_ALLOCATE, OSAL_SIZE_C(16384),
int32 status = OS_TaskCreate(&s_task_id, "ServerSingleWrite", Server_Fn, OSAL_TASK_STACK_ALLOCATE, OSAL_SIZE_C(16384),
OSAL_PRIORITY_C(50), 0);
UtAssert_True(status == OS_SUCCESS, "OS_TaskCreate() (%ld) == OS_SUCCESS", (long)status);

Expand Down Expand Up @@ -470,15 +451,15 @@ void TestSelectMultipleWrite(void)
*/

/* Create a server task/thread */
status = OS_TaskCreate(&s_task_id, "Server", Server_Fn, OSAL_TASK_STACK_ALLOCATE, OSAL_SIZE_C(16384),
status = OS_TaskCreate(&s_task_id, "ServerMultiWrite", Server_Fn, OSAL_TASK_STACK_ALLOCATE, OSAL_SIZE_C(16384),
OSAL_PRIORITY_C(50), 0);
UtAssert_True(status == OS_SUCCESS, "OS_TaskCreate() (%ld) == OS_SUCCESS", (long)status);

/* Connect to a server */
actual = OS_SocketConnect(c_socket_id, &s_addr, 10);
UtAssert_True(actual == expected, "OS_SocketConnect() (%ld) == OS_SUCCESS", (long)actual);

status = OS_TaskCreate(&s2_task_id, "Server2", Server_Fn2, OSAL_TASK_STACK_ALLOCATE, OSAL_SIZE_C(16384),
status = OS_TaskCreate(&s2_task_id, "ServerMultiWrite2", Server_Fn2, OSAL_TASK_STACK_ALLOCATE, OSAL_SIZE_C(16384),
OSAL_PRIORITY_C(50), 0);
UtAssert_True(status == OS_SUCCESS, "OS_TaskCreate() (%ld) == OS_SUCCESS", (long)status);

Expand Down