From 547aa11ebad61aefb3ed27028580dd6873bcc1b5 Mon Sep 17 00:00:00 2001 From: bje Date: Sun, 4 Oct 1998 22:07:33 +0000 Subject: 1998-10-05 Ben Elliston * tests/self.c: Remove; rename to self1.c. * tests/self1.c: This is the old self.c. * tests/self2.c: New file. Test pthread_self() with a single thread. Passes. * tests/self3.c: New file. Test pthread_self() with a couple of threads to ensure their thread IDs differ. Passes. --- ChangeLog | 10 ++++++++++ tests/self.c | 21 --------------------- tests/self1.c | 21 +++++++++++++++++++++ tests/self2.c | 31 +++++++++++++++++++++++++++++++ tests/self3.c | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 96 insertions(+), 21 deletions(-) delete mode 100644 tests/self.c create mode 100644 tests/self1.c create mode 100644 tests/self2.c create mode 100644 tests/self3.c diff --git a/ChangeLog b/ChangeLog index 91c1c68..231b868 100644 --- a/ChangeLog +++ b/ChangeLog @@ -30,6 +30,16 @@ * tests/equal1.c New file; test pthread_equal(). Passes. * tests/once1.c: New file; test for pthread_once(). Passes. + + * tests/self.c: Remove; rename to self1.c. + + * tests/self1.c: This is the old self.c. + + * tests/self2.c: New file. Test pthread_self() with a single + thread. Passes. + + * tests/self3.c: New file. Test pthread_self() with a couple of + threads to ensure their thread IDs differ. Passes. 1998-10-04 Ben Elliston diff --git a/tests/self.c b/tests/self.c deleted file mode 100644 index 0addfc8..0000000 --- a/tests/self.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Test for pthread_self(). - * - * Depends on API functions: None. - */ - -#include - -int -main(int argc, char * argv[]) -{ - pthread_t id; - - /* We can't do anything with this, though, because it is not - safe to assume anything about the internal structure of - a `pthread_t'. */ - - id = pthread_self(); - - return 0; -} diff --git a/tests/self1.c b/tests/self1.c new file mode 100644 index 0000000..0addfc8 --- /dev/null +++ b/tests/self1.c @@ -0,0 +1,21 @@ +/* + * Test for pthread_self(). + * + * Depends on API functions: None. + */ + +#include + +int +main(int argc, char * argv[]) +{ + pthread_t id; + + /* We can't do anything with this, though, because it is not + safe to assume anything about the internal structure of + a `pthread_t'. */ + + id = pthread_self(); + + return 0; +} diff --git a/tests/self2.c b/tests/self2.c new file mode 100644 index 0000000..76d7b71 --- /dev/null +++ b/tests/self2.c @@ -0,0 +1,31 @@ +#include +/* Hack. Peer into implementation details. */ +#include +#include +#include + +void * +entry(void * arg) +{ + /* Like systems such as HP-UX, we can't print the value of the thread ID + because it's not an integral type. Instead, we'll poke our noses into + the pthread_t structure and dump a useful internal value. This is + ordinarily bad, m'kay? */ + + pthread_t t = pthread_self(); + printf("my thread is %lx\n", t->win32handle); + return arg; +} + +int +main() +{ + int rc; + pthread_t t; + + rc = pthread_create(&t, NULL, entry, NULL); + assert(rc == 0); + + Sleep(2000); + return 0; +} diff --git a/tests/self3.c b/tests/self3.c new file mode 100644 index 0000000..17d5ed3 --- /dev/null +++ b/tests/self3.c @@ -0,0 +1,34 @@ +#include +/* Hack. Peer into implementation details. */ +#include +#include +#include + +void * +entry(void * arg) +{ + /* Like systems such as HP-UX, we can't print the value of the thread ID + because it's not an integral type. Instead, we'll poke our noses into + the pthread_t structure and dump a useful internal value. This is + ordinarily bad, m'kay? */ + + pthread_t t = pthread_self(); + printf("thread no. %d has id %lx\n", (int) arg, t->win32handle); + return 0; +} + +int +main() +{ + int rc; + pthread_t t[2]; + + rc = pthread_create(&t[0], NULL, entry, (void *) 1); + assert(rc == 0); + + rc = pthread_create(&t[1], NULL, entry, (void *) 2); + assert(rc == 0); + + Sleep(2000); + return 0; +} -- cgit v1.2.3