]>
Commit | Line | Data |
---|---|---|
2546420a A |
1 | #include <pthread.h> |
2 | ||
3 | #include <darwintest.h> | |
4 | ||
5 | static void * | |
6 | run(void * __unused arg) | |
7 | { | |
8 | while (true) { | |
9 | pthread_testcancel(); | |
10 | sched_yield(); | |
11 | } | |
12 | } | |
13 | ||
14 | T_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 | } |