2011-07-11 14:07:16 +00:00
|
|
|
#import "ObjectTesting.h"
|
|
|
|
#import <Foundation/NSThread.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
|
|
|
|
void *thread(void *ignored)
|
|
|
|
{
|
2015-03-31 09:45:40 +00:00
|
|
|
return [NSThread currentThread];
|
2011-07-11 14:07:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
2015-03-31 09:45:40 +00:00
|
|
|
pthread_t thr;
|
|
|
|
void *ret;
|
2011-07-11 14:07:16 +00:00
|
|
|
|
2015-03-31 09:45:40 +00:00
|
|
|
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");
|
2011-07-11 14:07:16 +00:00
|
|
|
|
2015-03-31 09:45:40 +00:00
|
|
|
NSThread *t = [NSThread currentThread];
|
|
|
|
[t setName: @"xxxtestxxx"];
|
|
|
|
NSLog(@"Thread description is '%@'", t);
|
|
|
|
NSRange r = [[t description] rangeOfString: @"name = xxxtestxxx"];
|
|
|
|
PASS(r.length > 0, "thread description contains name");
|
|
|
|
|
|
|
|
return 0;
|
2011-07-11 14:07:16 +00:00
|
|
|
}
|
|
|
|
|