summaryrefslogtreecommitdiff
path: root/tests/Gtest-concurrent.c
diff options
context:
space:
mode:
authorhp.com!davidm <hp.com!davidm>2005-05-03 09:13:17 +0000
committerhp.com!davidm <hp.com!davidm>2005-05-03 09:13:17 +0000
commitc0e81195b7e1fc1db66b4c324ba0d356ef7a0032 (patch)
tree6b92149a4daac224aa6d0c6b2e689d3bdc7305af /tests/Gtest-concurrent.c
parente8b25005e7a7ff0f67a2fb8b97b16a86dc572dde (diff)
downloadlibunwind-c0e81195b7e1fc1db66b4c324ba0d356ef7a0032.tar.gz
(doit): Fail gracefully if we fail to create all NTHREADS threads.
(Logical change 1.290)
Diffstat (limited to 'tests/Gtest-concurrent.c')
-rw-r--r--tests/Gtest-concurrent.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/tests/Gtest-concurrent.c b/tests/Gtest-concurrent.c
index 638ad342..8fe2ef30 100644
--- a/tests/Gtest-concurrent.c
+++ b/tests/Gtest-concurrent.c
@@ -1,5 +1,5 @@
/* libunwind - a platform-independent unwind library
- Copyright (C) 2003-2004 Hewlett-Packard Co
+ Copyright (C) 2003-2005 Hewlett-Packard Co
Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
Permission is hereby granted, free of charge, to any person obtaining
@@ -84,7 +84,13 @@ doit (void)
int i;
for (i = 0; i < NTHREADS; ++i)
- pthread_create (th + i, NULL, worker, NULL);
+ if (pthread_create (th + i, NULL, worker, NULL))
+ {
+ fprintf (stderr, "FAILURE: Failed to create %u threads "
+ "(after %u threads)\n",
+ NTHREADS, i);
+ exit (-1);
+ }
for (i = 0; i < NTHREADS; ++i)
pthread_join (th[i], NULL);
@@ -110,7 +116,10 @@ main (int argc, char **argv)
unw_set_caching_policy (unw_local_addr_space, UNW_CACHE_PER_THREAD);
if (nerrors)
- fprintf (stderr, "FAILURE: detected %d errors\n", nerrors);
+ {
+ fprintf (stderr, "FAILURE: detected %d errors\n", nerrors);
+ exit (-1);
+ }
if (verbose)
printf ("SUCCESS\n");