From accb4a97dce84b617ee26300fd325a689440508c Mon Sep 17 00:00:00 2001 From: theraven Date: Mon, 11 Jul 2011 14:07:16 +0000 Subject: [PATCH] Added some tests for lazy allocated thread behaviour. These show deviation from OS X behaviour (the first test passes by accident - it's actually doing the wrong thing in two different ways that cancel each other out). git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33520 72102866-910b-0410-8b05-ffd578937521 --- Tests/base/NSThread/lazy_thread.m | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Tests/base/NSThread/lazy_thread.m 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; +} +