]> granicus.if.org Git - gc/commitdiff
tests: Log error messages to stderr instead of stdout
authorIvan Maidanski <ivmai@mail.ru>
Tue, 18 Sep 2012 11:47:36 +0000 (15:47 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 18 Sep 2012 11:47:36 +0000 (15:47 +0400)
* tests/initsecondarythread.c (main): Print error messages using
fprintf(stderr) instead of printf().
* tests/subthread_create.c (entry, main): Likewise.
* tests/thread_leak_test.c (main): Likewise.
* tests/trace_test.c (mktree): Likewise.
* tests/thread_leak_test.c (main): Call exit(2) if thread creation or
joining failed.

tests/initsecondarythread.c
tests/subthread_create.c
tests/thread_leak_test.c
tests/trace_test.c

index 70063ebd46dc27497b3d76a9d0a4038cf14e0792..4a13ca95f55b927ef77b73191e47d2921c95f501 100644 (file)
@@ -76,21 +76,21 @@ int main(void)
 # endif
 # ifdef GC_PTHREADS
     if ((code = pthread_create (&t, NULL, thread, NULL)) != 0) {
-      printf("Thread creation failed %d\n", code);
+      fprintf(stderr, "Thread creation failed %d\n", code);
       return 1;
     }
     if ((code = pthread_join (t, NULL)) != 0) {
-      printf("Thread join failed %d\n", code);
+      fprintf(stderr, "Thread join failed %d\n", code);
       return 1;
     }
 # else
     t = CreateThread(NULL, 0, thread, 0, 0, &thread_id);
     if (t == NULL) {
-      printf("Thread creation failed %d\n", (int)GetLastError());
+      fprintf(stderr, "Thread creation failed %d\n", (int)GetLastError());
       return 1;
     }
     if (WaitForSingleObject(t, INFINITE) != WAIT_OBJECT_0) {
-      printf("Thread join failed %d\n", (int)GetLastError());
+      fprintf(stderr, "Thread join failed %d\n", (int)GetLastError());
       CloseHandle(t);
       return 1;
     }
index 9352f339284a451e1d3df30f4a9302c16e917165..9a7095b6dd328900fa140546a0db571358481535 100644 (file)
@@ -70,7 +70,7 @@ volatile AO_t thread_ended_cnt = 0;
         DWORD thread_id;
         th = CreateThread(NULL, 0, entry, (LPVOID)my_depth, 0, &thread_id);
         if (th == NULL) {
-            printf("Thread #%d creation failed: %d\n", thread_num,
+            fprintf(stderr, "Thread #%d creation failed: %d\n", thread_num,
                    (int)GetLastError());
             exit(2);
         }
@@ -104,7 +104,8 @@ int main(void)
         DWORD thread_id;
         th[i] = CreateThread(NULL, 0, entry, 0, 0, &thread_id);
         if (th[i] == NULL) {
-            printf("Thread creation failed: %d\n", (int)GetLastError());
+            fprintf(stderr, "Thread creation failed: %d\n",
+                    (int)GetLastError());
             exit(1);
         }
 #     endif
@@ -120,7 +121,8 @@ int main(void)
         }
 #     else
         if (WaitForSingleObject(th[i], INFINITE) != WAIT_OBJECT_0) {
-            printf("Failed to join thread: %d\n", (int)GetLastError());
+            fprintf(stderr, "Failed to join thread: %d\n",
+                    (int)GetLastError());
             CloseHandle(th[i]);
             exit(1);
         }
index 8b7f82d613e33e80ce5a77822e49db93d576d373..845de00ecd9049a95ee4f2c179389a9ee5efa835 100644 (file)
@@ -63,7 +63,8 @@ int main(void) {
           code = t[i] != NULL ? 0 : (int)GetLastError();
 #       endif
         if (code != 0) {
-            printf("Thread creation failed %d\n", code);
+            fprintf(stderr, "Thread creation failed %d\n", code);
+            exit(2);
         }
     }
 
@@ -75,7 +76,8 @@ int main(void) {
                                                         (int)GetLastError();
 #       endif
         if (code != 0) {
-            printf("Thread join failed %d\n", code);
+            fprintf(stderr, "Thread join failed %d\n", code);
+            exit(2);
         }
     }
 
index 923e0f88a3a34b77c3831804d76cbdaf4a1eb8d2..79c353f71a61bd32fe35dc056b75db29239eefc7 100644 (file)
@@ -18,7 +18,7 @@ struct treenode * mktree(int i) {
   if (0 == i) return 0;
   if (1 == i) r = GC_MALLOC_ATOMIC(sizeof(struct treenode));
   if (r == NULL) {
-    printf("Out of memory\n");
+    fprintf(stderr, "Out of memory\n");
     exit(1);
   }
   r -> x = mktree(i-1);