unit-tests: Sync threads with main thread in test_cleanup_cancel()

Without synchronization threads could get canceled before they could
disable their cancelability.
This commit is contained in:
Tobias Brunner
2014-05-19 16:06:52 +02:00
parent 403ad5dd85
commit b9dfeb5de4
@@ -1215,6 +1215,8 @@ static void *cleanup_cancel_run(void *data)
{
thread_cancelability(FALSE);
barrier_wait(barrier);
thread_cleanup_push(cleanup3, data);
thread_cleanup_push(cleanup2, data);
thread_cleanup_push(cleanup1, data);
@@ -1234,11 +1236,13 @@ START_TEST(test_cleanup_cancel)
uintptr_t values[THREADS];
int i;
barrier = barrier_create(THREADS+1);
for (i = 0; i < THREADS; i++)
{
values[i] = 1;
threads[i] = thread_create(cleanup_cancel_run, &values[i]);
}
barrier_wait(barrier);
for (i = 0; i < THREADS; i++)
{
threads[i]->cancel(threads[i]);
@@ -1248,6 +1252,7 @@ START_TEST(test_cleanup_cancel)
threads[i]->join(threads[i]);
ck_assert_int_eq(values[i], 4);
}
barrier_destroy(barrier);
}
END_TEST