summaryrefslogtreecommitdiff
path: root/tests/test_stack.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2011-09-21 12:46:39 +0400
committerIvan Maidanski <ivmai@mail.ru>2011-09-21 12:46:39 +0400
commit565d6fd90cceba30cb9bbfff3a1c2a74a67e5f0f (patch)
tree85917b582237e765f0eaf83852054bbb53725460 /tests/test_stack.c
parentf64bf53267764b611667a0135d9400b0388d0339 (diff)
downloadlibatomic_ops-565d6fd90cceba30cb9bbfff3a1c2a74a67e5f0f.tar.gz
tests: Invoke exit() instead of abort() in case of out of memory
* tests/test_malloc.c (cons, run_one_test): Call exit with a non-zero code (instead of abort) if out of memory. * tests/test_stack.c (add_elements): Likewise. * tests/test_stack.c (main): Use a distinct exit code if a thread creation failed.
Diffstat (limited to 'tests/test_stack.c')
-rw-r--r--tests/test_stack.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/test_stack.c b/tests/test_stack.c
index fc23c52..eaad708 100644
--- a/tests/test_stack.c
+++ b/tests/test_stack.c
@@ -68,7 +68,7 @@ void add_elements(int n)
if (le == 0)
{
fprintf(stderr, "Out of memory\n");
- abort();
+ exit(2);
}
le -> data = n;
AO_stack_push(&the_list, (AO_t *)le);
@@ -203,12 +203,12 @@ int main(int argc, char **argv)
ops_performed = 0;
start_time = get_msecs();
for (i = 1; i < nthreads; ++i) {
- int code;
+ int code;
if ((code = pthread_create(thread+i, 0, run_one_test,
(void *)(long)i)) != 0) {
fprintf(stderr, "Thread creation failed %u\n", code);
- exit(1);
+ exit(3);
}
}
/* We use the main thread to run one test. This allows gprof */