tests: Log messages to stdout instead of stderr
authorIvan Maidanski <ivmai@mail.ru>
Tue, 18 Sep 2012 11:21:16 +0000 (15:21 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 18 Sep 2012 11:21:16 +0000 (15:21 +0400)
* tests/run_parallel.h (run_parallel): Print logging (non-error)
messages using printf() instead of fprintf(stderr).
* tests/test_atomic_include.template (MISSING): Likewise.
* tests/test_malloc.c (print_list): Likewise.
* tests/run_parallel.h (run_parallel): Reformat code.

tests/run_parallel.h
tests/test_atomic_include.template
tests/test_malloc.c

index 2a2b456..7fae0b0 100644 (file)
@@ -55,7 +55,7 @@ void * run_parallel(int nthreads, thr_func f1, test_func t, const char *name)
   int i;
   int code;
 
-  fprintf(stderr, "Testing %s\n", name);
+  printf("Testing %s\n", name);
   if (nthreads > 100)
     {
       fprintf(stderr, "run_parallel: requested too many threads\n");
@@ -65,10 +65,11 @@ void * run_parallel(int nthreads, thr_func f1, test_func t, const char *name)
 # ifdef _HPUX_SOURCE
    /* Default stack size is too small, especially with the 64 bit ABI */
    /* Increase it.                                                    */
-    if (pthread_default_stacksize_np(1024*1024, 0) != 0) {
-      fprintf(stderr, "pthread_default_stacksize_np failed. "
-                  "OK after first call.\n");
-    }
+    if (pthread_default_stacksize_np(1024*1024, 0) != 0)
+      {
+        fprintf(stderr, "pthread_default_stacksize_np failed. "
+                        "OK after first call.\n");
+      }
 # endif
 
   pthread_attr_init(&attr);
@@ -76,22 +77,22 @@ void * run_parallel(int nthreads, thr_func f1, test_func t, const char *name)
   for (i = 0; i < nthreads; ++i)
     {
       if ((code = pthread_create(thr + i, &attr, f1, (void *)(long)i)) != 0)
-    {
-      fprintf(stderr, "Pthread_create returned %d, thread %d\n", code, i);
-      abort();
-        }
+      {
+        fprintf(stderr, "pthread_create returned %d, thread %d\n", code, i);
+        abort();
+      }
     }
   for (i = 0; i < nthreads; ++i)
     {
       if ((code = pthread_join(thr[i], NULL)) != 0)
-    {
-      fprintf(stderr, "Pthread_join returned %d, thread %d\n", code, i);
-      abort();
-        }
+      {
+        fprintf(stderr, "pthread_join returned %d, thread %d\n", code, i);
+        abort();
+      }
     }
   if (t())
     {
-      fprintf(stderr, "Succeeded\n");
+      printf("Succeeded\n");
     }
   else
     {
@@ -108,7 +109,7 @@ void * run_parallel(int nthreads, thr_func f1, test_func t, const char *name)
   int thr[100];
   int i;
 
-  fprintf(stderr, "Testing %s\n", name);
+  printf("Testing %s\n", name);
   if (nthreads > 100)
     {
       fprintf(stderr, "run_parallel: requested too many threads\n");
@@ -120,11 +121,11 @@ void * run_parallel(int nthreads, thr_func f1, test_func t, const char *name)
       thr[i] = taskSpawn((char*) name, 180, 0, 32768, (FUNCPTR) f1, i,
                          1, 2, 3, 4, 5, 6, 7, 8, 9);
       if (thr[i] == ERROR)
-    {
-      fprintf(stderr, "taskSpawn failed with %d, thread %d\n",
-              errno, i);
-      taskSuspend(0);
-        }
+      {
+        fprintf(stderr, "taskSpawn failed with %d, thread %d\n",
+                errno, i);
+        taskSuspend(0);
+      }
     }
   for (i = 0; i < nthreads; ++i)
     {
@@ -133,7 +134,7 @@ void * run_parallel(int nthreads, thr_func f1, test_func t, const char *name)
     }
   if (t())
     {
-      fprintf(stderr, "Succeeded\n");
+      printf("Succeeded\n");
     }
   else
     {
@@ -165,7 +166,7 @@ void * run_parallel(int nthreads, thr_func f1, test_func t, const char *name)
   int i;
   DWORD code;
 
-  fprintf(stderr, "Testing %s\n", name);
+  printf("Testing %s\n", name);
   if (nthreads > 100)
     {
       fprintf(stderr, "run_parallel: requested too many threads\n");
@@ -177,25 +178,25 @@ void * run_parallel(int nthreads, thr_func f1, test_func t, const char *name)
       args[i].fn = f1;
       args[i].arg = i;
       if ((thr[i] = CreateThread(NULL, 0, tramp, (LPVOID)(args+i), 0, NULL))
-      == NULL)
-    {
-      fprintf(stderr, "CreateThread failed with %lu, thread %d\n",
-              (unsigned long)GetLastError(), i);
-      abort();
+          == NULL)
+        {
+          fprintf(stderr, "CreateThread failed with %lu, thread %d\n",
+                  (unsigned long)GetLastError(), i);
+          abort();
         }
     }
   for (i = 0; i < nthreads; ++i)
     {
       if ((code = WaitForSingleObject(thr[i], INFINITE)) != WAIT_OBJECT_0)
-    {
-      fprintf(stderr, "WaitForSingleObject returned %lu, thread %d\n",
-              (unsigned long)code, i);
-      abort();
-        }
+      {
+        fprintf(stderr, "WaitForSingleObject returned %lu, thread %d\n",
+                (unsigned long)code, i);
+        abort();
+      }
     }
   if (t())
     {
-      fprintf(stderr, "Succeeded\n");
+      printf("Succeeded\n");
     }
   else
     {
index 8a4dda9..c8b5ba0 100644 (file)
@@ -14,7 +14,7 @@
 
 #undef MISSING
 #define MISSING(name) \
-  fprintf(stderr, "Missing: %s\n", #name "XX")
+  printf("Missing: %s\n", #name "XX")
 
 void test_atomicXX(void)
 {
index 73ca1ea..090dca2 100644 (file)
@@ -97,9 +97,9 @@ void print_list(ln *l)
 
   for (p = l; p != 0; p = p -> next)
     {
-      fprintf(stderr, "%d, ", p -> data);
+      printf("%d, ", p -> data);
     }
-  fprintf(stderr, "\n");
+  printf("\n");
 }
 
 /* Check that l contains numbers from m to n inclusive in ascending order */