Skip to content

Commit

Permalink
test: minor improvements in remain test (#931)
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredh authored Sep 4, 2023
1 parent b73a8c5 commit 84208bc
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions test/remain.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ static void tmr_handler(void *arg)

mtx_unlock(data->mutex);

/* Stop re_main loop */
re_cancel();
}

Expand All @@ -56,11 +57,12 @@ static int thread_handler(void *arg)

tmr_init(&tmr);

/* Add a worker thread for this thread */
err = re_thread_init();
if (err) {
DEBUG_WARNING("re thread init: %m\n", err);
data->err = err;
return 0;
return err;
}

#ifndef WIN32
Expand All @@ -80,22 +82,21 @@ static int thread_handler(void *arg)
data->err = err;
tmr_cancel(&tmr);

/* cleanup */
tmr_debug();

/* Remove the worker thread for this thread */
re_thread_close();

data->thread_exited = true;

return 0;
return err;
}


static int test_remain_thread(void)
{
struct data data;
int i, err;

memset(&data, 0, sizeof(data));
struct data data = { 0 };
int err;

err = mutex_alloc(&data.mutex);
if (err)
Expand All @@ -105,7 +106,7 @@ static int test_remain_thread(void)
TEST_ERR(err);

/* wait for timer to be called */
for (i=0; i<500; i++) {
for (size_t i=0; i<500; i++) {
mtx_lock(data.mutex);

if (data.tmr_called || data.err) {
Expand Down

0 comments on commit 84208bc

Please sign in to comment.