diff --git a/Tests/base/NSThread/lazy_thread.m b/Tests/base/NSThread/lazy_thread.m new file mode 100644 index 000000000..a0c4433a6 --- /dev/null +++ b/Tests/base/NSThread/lazy_thread.m @@ -0,0 +1,27 @@ +#import "ObjectTesting.h" +#import +#include + +void *thread(void *ignored) +{ + return [NSThread currentThread]; +} + +int main(void) +{ + pthread_t thr; + void *ret; + + pthread_create(&thr, NULL, thread, NULL); + pthread_join(thr, &ret); + PASS(ret != 0, "NSThread lazily created from POSIX thread"); + testHopeful = YES; + PASS((ret != 0) && (ret != [NSThread mainThread]), "Spawned thread is not main thread"); + pthread_create(&thr, NULL, thread, NULL); + pthread_join(thr, &ret); + PASS(ret != 0, "NSThread lazily created from POSIX thread"); + PASS((ret != 0) && (ret != [NSThread mainThread]), "Spawned thread is not main thread"); + + return 0; +} +