diff options
Diffstat (limited to 'winsup/testsuite/winsup.api/pthread/self2.c')
-rw-r--r-- | winsup/testsuite/winsup.api/pthread/self2.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/winsup/testsuite/winsup.api/pthread/self2.c b/winsup/testsuite/winsup.api/pthread/self2.c new file mode 100644 index 000000000..83339f101 --- /dev/null +++ b/winsup/testsuite/winsup.api/pthread/self2.c @@ -0,0 +1,46 @@ +/* + * self2.c + * + * Test for pthread_self(). + * + * Depends on API functions: + * pthread_create() + * pthread_self() + * + * Implicitly depends on: + * pthread_getspecific() + * pthread_setspecific() + */ + +#include "test.h" +#include <string.h> + +static pthread_t me; + +void * +entry(void * arg) +{ + me = pthread_self(); + + return arg; +} + +int +main() +{ + pthread_t t; + + assert(pthread_create(&t, NULL, entry, NULL) == 0); + + Sleep(2000); + + /* + * Not much more we can do here but bytewise compare t with + * what pthread_self returned. + */ + assert(t == me); + assert(memcmp((const void *) t, (const void *) me, sizeof t) == 0); + + /* Success. */ + return 0; +} |