unit-tests: Add a thread cleanup pop test
This commit is contained in:
@@ -513,6 +513,38 @@ START_TEST(test_cleanup_cancel)
|
|||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
static void *cleanup_pop_run(void *data)
|
||||||
|
{
|
||||||
|
thread_cleanup_push(cleanup3, data);
|
||||||
|
thread_cleanup_push(cleanup2, data);
|
||||||
|
thread_cleanup_push(cleanup1, data);
|
||||||
|
|
||||||
|
thread_cleanup_push(cleanup2, data);
|
||||||
|
thread_cleanup_pop(FALSE);
|
||||||
|
|
||||||
|
thread_cleanup_pop(TRUE);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(test_cleanup_pop)
|
||||||
|
{
|
||||||
|
thread_t *threads[THREADS];
|
||||||
|
uintptr_t values[THREADS];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < THREADS; i++)
|
||||||
|
{
|
||||||
|
values[i] = 1;
|
||||||
|
threads[i] = thread_create(cleanup_pop_run, &values[i]);
|
||||||
|
}
|
||||||
|
for (i = 0; i < THREADS; i++)
|
||||||
|
{
|
||||||
|
threads[i]->join(threads[i]);
|
||||||
|
ck_assert_int_eq(values[i], 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
Suite *threading_suite_create()
|
Suite *threading_suite_create()
|
||||||
{
|
{
|
||||||
Suite *s;
|
Suite *s;
|
||||||
@@ -544,6 +576,7 @@ Suite *threading_suite_create()
|
|||||||
tcase_add_test(tc, test_cleanup);
|
tcase_add_test(tc, test_cleanup);
|
||||||
tcase_add_test(tc, test_cleanup_exit);
|
tcase_add_test(tc, test_cleanup_exit);
|
||||||
tcase_add_test(tc, test_cleanup_cancel);
|
tcase_add_test(tc, test_cleanup_cancel);
|
||||||
|
tcase_add_test(tc, test_cleanup_pop);
|
||||||
suite_add_tcase(s, tc);
|
suite_add_tcase(s, tc);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
|||||||
Reference in New Issue
Block a user