diff options
author | rpj <rpj> | 2000-08-17 14:43:12 +0000 |
---|---|---|
committer | rpj <rpj> | 2000-08-17 14:43:12 +0000 |
commit | 2ca5c368816d1e48955505e5ecb52a09e3fbe62a (patch) | |
tree | cf78f71ab0c9f1f29eb02793b1282b8e20afa0bd | |
parent | a366b6d8c2e6debf247c82af3d41aa2483711c52 (diff) |
2000-08-17 Ross Johnson <rpj@special.ise.canberra.edu.au>
* create2.c: New; Test that pthread_t contains
the W32 HANDLE before it calls the thread routine
proper.
-rw-r--r-- | tests/ChangeLog | 6 | ||||
-rw-r--r-- | tests/create2.c | 78 |
2 files changed, 84 insertions, 0 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog index 412c09c..0bccb5b 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,9 @@ +2000-08-17 Ross Johnson <rpj@special.ise.canberra.edu.au> + + * create2.c: New; Test that pthread_t contains + the W32 HANDLE before it calls the thread routine + proper. + 2000-08-13 Ross Johnson <rpj@special.ise.canberra.edu.au> * condvar3.c: Minor change to eliminate compiler diff --git a/tests/create2.c b/tests/create2.c new file mode 100644 index 0000000..f6d3263 --- /dev/null +++ b/tests/create2.c @@ -0,0 +1,78 @@ +/* + * File: create2.c + * + * Test Synopsis: + * - Test that threads have a Win32 handle when started. + * + * Test Method (Validation or Falsification): + * - Statistical, not absolute (depends on sample size). + * + * Requirements Tested: + * - + * + * Features Tested: + * - + * + * Cases Tested: + * - + * + * Description: + * - + * + * Environment: + * - + * + * Input: + * - None. + * + * Output: + * - File name, Line number, and failed expression on failure. + * - No output on success. + * + * Assumptions: + * - + * + * Pass Criteria: + * - Process returns zero exit status. + * + * Fail Criteria: + * - Process returns non-zero exit status. + */ + +#include "test.h" + +enum { + NUMTHREADS = 10000; +}; + +static int washere = 0; + +void * func(void * arg) +{ + HANDLE w32ThreadH = (pthread_self())->threadH; + + assert(w32ThreadH != 0); + washere = 1; + return (void *) 0; +} + +int +main() +{ + pthread_t t; + pthread_attr_t attr; + void * result = NULL; + + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); + + for (i = 0; i < NUMTHREADS; i++) + { + washere = 0; + assert(pthread_create(&t, &attr, func, NULL) == 0); + pthread_join(t, &result); + assert(washere == 1); + } + + return 0; +} |