mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
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
This commit is contained in:
parent
c425bca5d4
commit
72b55444fb
1 changed files with 27 additions and 0 deletions
27
Tests/base/NSThread/lazy_thread.m
Normal file
27
Tests/base/NSThread/lazy_thread.m
Normal file
|
@ -0,0 +1,27 @@
|
|||
#import "ObjectTesting.h"
|
||||
#import <Foundation/NSThread.h>
|
||||
#include <pthread.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in a new issue