tests: posix: eventfd: Move thread from stack to data section

The test case allocate struct k_thread thread in the stack. This will
lead the random initial value of thread and thus cause the test cases
randomly hang. To fix such issue, move the declartion of struct k_thread
thread outside the function as a stacic variable.

Signed-off-by: Jaxson Han <jaxson.han@arm.com>
This commit is contained in:
Jaxson Han 2023-09-06 15:05:26 +08:00 committed by Carles Cufí
commit eeaf3bdb2d

View file

@ -72,6 +72,7 @@ ZTEST_F(eventfd, test_unset_poll_event_block)
}
K_THREAD_STACK_DEFINE(thread_stack, CONFIG_TEST_STACK_SIZE);
static struct k_thread thread;
static void thread_eventfd_read_42(void *arg1, void *arg2, void *arg3)
{
@ -84,8 +85,6 @@ static void thread_eventfd_read_42(void *arg1, void *arg2, void *arg3)
ZTEST_F(eventfd, test_read_then_write_block)
{
struct k_thread thread;
k_thread_create(&thread, thread_stack, K_THREAD_STACK_SIZEOF(thread_stack),
thread_eventfd_read_42, fixture, NULL, NULL, 0, 0, K_NO_WAIT);
@ -107,7 +106,6 @@ static void thread_eventfd_write(void *arg1, void *arg2, void *arg3)
ZTEST_F(eventfd, test_write_while_pollin)
{
struct k_thread thread;
struct zsock_pollfd fds[] = {
{
.fd = fixture->fd,
@ -143,7 +141,6 @@ static void thread_eventfd_read(void *arg1, void *arg2, void *arg3)
ZTEST_F(eventfd, test_read_while_pollout)
{
struct k_thread thread;
struct zsock_pollfd fds[] = {
{
.fd = fixture->fd,