tests: Invoke exit() instead of abort() in case of out of memory
authorIvan Maidanski <ivmai@mail.ru>
Wed, 21 Sep 2011 08:46:39 +0000 (12:46 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 21 Sep 2011 08:46:39 +0000 (12:46 +0400)
* 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.

tests/test_malloc.c
tests/test_stack.c

index 0cc07ef..cf9185d 100644 (file)
@@ -74,7 +74,7 @@ ln *cons(int d, ln *tail)
     {
       fprintf(stderr, "Out of memory\n");
         /* Normal for more than about 10 threads without mmap? */
-      abort();
+      exit(2);
     }
 
   result -> data = d;
@@ -164,7 +164,7 @@ void * run_one_test(void * arg) {
       {
         fprintf(stderr, "Out of memory\n");
           /* Normal for more than about 10 threads without mmap? */
-        abort();
+        exit(2);
       }
     q[0] = q[LARGE_OBJ_SIZE/2] = q[LARGE_OBJ_SIZE-1] = 'b';
     if (p[0] != 'a' || p[LARGE_OBJ_SIZE/2] != 'a'
index fc23c52..eaad708 100644 (file)
@@ -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   */