]> git.saurik.com Git - apple/libpthread.git/blame_incremental - tests/pthread_cancel.c
libpthread-454.100.8.tar.gz
[apple/libpthread.git] / tests / pthread_cancel.c
... / ...
CommitLineData
1#include <pthread.h>
2
3#include "darwintest_defaults.h"
4
5static void *
6run(void * __unused arg)
7{
8 while (true) {
9 pthread_testcancel();
10 sched_yield();
11 }
12}
13
14T_DECL(pthread_cancel, "pthread_cancel",
15 T_META_ALL_VALID_ARCHS(YES))
16{
17 pthread_t thread;
18 void *join_result = NULL;
19 T_ASSERT_POSIX_ZERO(pthread_create(&thread, NULL, run, NULL), NULL);
20 T_ASSERT_POSIX_ZERO(pthread_cancel(thread), NULL);
21 T_ASSERT_POSIX_ZERO(pthread_join(thread, &join_result), NULL);
22 T_ASSERT_EQ(join_result, PTHREAD_CANCELED, NULL);
23}