ostest/wqueue: Check return value for pthread ops.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
This commit is contained in:
parent
8757c6934c
commit
87838bb62c
@ -143,27 +143,72 @@ static void run_once(int interval, int priority_test, int priority_verify)
|
|||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
pthread_attr_t attr;
|
pthread_attr_t attr;
|
||||||
struct sched_param sparam;
|
struct sched_param sparam;
|
||||||
|
int status;
|
||||||
|
|
||||||
|
status = pthread_attr_init(&attr);
|
||||||
|
if (status != 0)
|
||||||
|
{
|
||||||
|
printf("wqueue_test: pthread_attr_init failed, status=%d\n", status);
|
||||||
|
}
|
||||||
|
|
||||||
pthread_attr_init(&attr);
|
|
||||||
memset(&sparam, 0, sizeof(sparam));
|
memset(&sparam, 0, sizeof(sparam));
|
||||||
|
|
||||||
/* Tester: try race conditions. */
|
/* Tester: try race conditions. */
|
||||||
|
|
||||||
sparam.sched_priority = priority_test;
|
sparam.sched_priority = priority_test;
|
||||||
pthread_attr_setschedparam(&attr, &sparam);
|
status = pthread_attr_setschedparam(&attr, &sparam);
|
||||||
|
if (status != 0)
|
||||||
|
{
|
||||||
|
printf("wqueue_test: pthread_attr_setschedparam failed for tester, "
|
||||||
|
"status=%d\n", status);
|
||||||
|
}
|
||||||
|
|
||||||
pthread_create(&thread, &attr, tester, (FAR void *)(intptr_t)interval);
|
status = pthread_create(&thread, &attr, tester,
|
||||||
pthread_join(thread, NULL);
|
(FAR void *)(intptr_t)interval);
|
||||||
|
if (status != 0)
|
||||||
|
{
|
||||||
|
printf("wqueue_test: pthread_create failed for tester, "
|
||||||
|
"status=%d\n", status);
|
||||||
|
}
|
||||||
|
|
||||||
|
status = pthread_join(thread, NULL);
|
||||||
|
if (status != 0)
|
||||||
|
{
|
||||||
|
printf("wqueue_test: pthread_join failed for tester, "
|
||||||
|
"status=%d\n", status);
|
||||||
|
}
|
||||||
|
|
||||||
/* Verifier: make sure queue is still working properly. */
|
/* Verifier: make sure queue is still working properly. */
|
||||||
|
|
||||||
sparam.sched_priority = priority_verify;
|
sparam.sched_priority = priority_verify;
|
||||||
pthread_attr_setschedparam(&attr, &sparam);
|
status = pthread_attr_setschedparam(&attr, &sparam);
|
||||||
pthread_attr_setstacksize(&attr,
|
if (status != 0)
|
||||||
VERIFY_COUNT * sizeof(struct work_s) + CONFIG_PTHREAD_STACK_DEFAULT);
|
{
|
||||||
|
printf("wqueue_test: pthread_attr_setschedparam failed for verifier, "
|
||||||
|
"status=%d\n", status);
|
||||||
|
}
|
||||||
|
|
||||||
pthread_create(&thread, &attr, verifier, NULL);
|
status = pthread_attr_setstacksize(&attr,
|
||||||
pthread_join(thread, NULL);
|
VERIFY_COUNT * sizeof(struct work_s) + CONFIG_PTHREAD_STACK_DEFAULT);
|
||||||
|
if (status != 0)
|
||||||
|
{
|
||||||
|
printf("wqueue_test: pthread_attr_setstacksize failed for verifier, "
|
||||||
|
"status=%d\n", status);
|
||||||
|
}
|
||||||
|
|
||||||
|
status = pthread_create(&thread, &attr, verifier, NULL);
|
||||||
|
if (status != 0)
|
||||||
|
{
|
||||||
|
printf("wqueue_test: pthread_create failed for verifier, "
|
||||||
|
"status=%d\n", status);
|
||||||
|
}
|
||||||
|
|
||||||
|
status = pthread_join(thread, NULL);
|
||||||
|
if (status != 0)
|
||||||
|
{
|
||||||
|
printf("wqueue_test: pthread_join failed for verifier, "
|
||||||
|
"status=%d\n", status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
Loading…
x
Reference in New Issue
Block a user