|
From: Jeremy F. <je...@go...> - 2005-01-24 08:53:02
|
CVS commit by fitzhardinge:
Check pthread_create return, so that we're also checking that threads
are being cleaned up properly.
M +21 -5 thread-exits.c 1.2
--- valgrind/none/tests/thread-exits.c #1.1:1.2
@@ -13,6 +13,12 @@
grow the stack. If we don't get the siginfo, then it just looks
like the program crashed.
+
+ Oh, and this test also makes sure that thread resources are cleaned
+ up properly.
*/
#include <pthread.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
static void *thr(void *v)
@@ -37,16 +43,26 @@ int main()
int i;
- /* create lots of threads */
+ /* Create lots of threads */
for(i = 0; i < 1300; i++) {
pthread_t t;
+ int ret;
- pthread_create(&t, NULL, thr, NULL);
- pthread_join(t, NULL);
+ ret = pthread_create(&t, NULL, thr, NULL);
+ if (ret) {
+ printf("pthread_create failed: %s\n", strerror(ret));
+ exit(1);
}
- /* grow the stack */
+ ret = pthread_join(t, NULL);
+ if (ret) {
+ printf("pthread_join failed: %s\n", strerror(ret));
+ exit(1);
+ }
+ }
+
+ /* Grow the stack */
grow(10);
- /* if we didn't die with SIGSEGV in grow(), it is a pass */
+ /* If we didn't die with SIGSEGV in grow(), it is a pass */
printf("PASS\n");
|