mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
Impement test for main thread on linux
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@38443 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8a265fe615
commit
a79dd60102
6 changed files with 37 additions and 24 deletions
|
@ -4,24 +4,32 @@
|
|||
|
||||
void *thread(void *ignored)
|
||||
{
|
||||
return [NSThread currentThread];
|
||||
return [NSThread currentThread];
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
pthread_t thr;
|
||||
void *ret;
|
||||
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");
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue