ce426f
commit c5c13355132e73578bbc0c612ddff964e6199747
ce426f
Author: Will Newton <will.newton@linaro.org>
ce426f
Date:   Fri Apr 11 15:21:23 2014 +0100
ce426f
ce426f
    test-skeleton.c: Use stdout for error messages
ce426f
    
ce426f
    At the moment the test skeleton uses a mixture of stdout and
ce426f
    stderr for error message output. Using stdout for all test output
ce426f
    keeps all output correctly ordered and properly redirected to the
ce426f
    output file. The suggestion to use stdout is also made on the wiki:
ce426f
    
ce426f
    https://sourceware.org/glibc/wiki/Testing/Testsuite#Writing_a_test_case
ce426f
    
ce426f
    ChangeLog:
ce426f
    
ce426f
    2014-06-23  Will Newton  <will.newton@linaro.org>
ce426f
    
ce426f
            * test-skeleton.c (signal_handler): Use printf and %m
ce426f
            rather than perror.  Use printf rather than fprintf to
ce426f
            stderr.  Use puts rather than fputs to stderr.
ce426f
            (main): Likewise.
ce426f
ce426f
Index: b/test-skeleton.c
ce426f
===================================================================
ce426f
--- a/test-skeleton.c
ce426f
+++ b/test-skeleton.c
ce426f
@@ -188,7 +188,7 @@ signal_handler (int sig __attribute__ ((
ce426f
     }
ce426f
   if (killed != 0 && killed != pid)
ce426f
     {
ce426f
-      perror ("Failed to kill test process");
ce426f
+      printf ("Failed to kill test process: %m\n");
ce426f
       exit (1);
ce426f
     }
ce426f
 
ce426f
@@ -209,16 +209,16 @@ signal_handler (int sig __attribute__ ((
ce426f
 #endif
ce426f
 
ce426f
   if (killed == 0 || (WIFSIGNALED (status) && WTERMSIG (status) == SIGKILL))
ce426f
-    fputs ("Timed out: killed the child process\n", stderr);
ce426f
+    puts ("Timed out: killed the child process");
ce426f
   else if (WIFSTOPPED (status))
ce426f
-    fprintf (stderr, "Timed out: the child process was %s\n",
ce426f
-	     strsignal (WSTOPSIG (status)));
ce426f
+    printf ("Timed out: the child process was %s\n",
ce426f
+	    strsignal (WSTOPSIG (status)));
ce426f
   else if (WIFSIGNALED (status))
ce426f
-    fprintf (stderr, "Timed out: the child process got signal %s\n",
ce426f
-	     strsignal (WTERMSIG (status)));
ce426f
+    printf ("Timed out: the child process got signal %s\n",
ce426f
+	    strsignal (WTERMSIG (status)));
ce426f
   else
ce426f
-    fprintf (stderr, "Timed out: killed the child process but it exited %d\n",
ce426f
-	     WEXITSTATUS (status));
ce426f
+    printf ("Timed out: killed the child process but it exited %d\n",
ce426f
+	    WEXITSTATUS (status));
ce426f
 
ce426f
   /* Exit with an error.  */
ce426f
   exit (1);
ce426f
@@ -308,7 +308,7 @@ main (int argc, char *argv[])
ce426f
 
ce426f
       if (chdir (test_dir) < 0)
ce426f
 	{
ce426f
-	  perror ("chdir");
ce426f
+	  printf ("chdir: %m\n");
ce426f
 	  exit (1);
ce426f
 	}
ce426f
     }
ce426f
@@ -367,10 +367,10 @@ main (int argc, char *argv[])
ce426f
 	    data_limit.rlim_cur = MIN ((rlim_t) TEST_DATA_LIMIT,
ce426f
 				       data_limit.rlim_max);
ce426f
 	  if (setrlimit (RLIMIT_DATA, &data_limit) < 0)
ce426f
-	    perror ("setrlimit: RLIMIT_DATA");
ce426f
+	    printf ("setrlimit: RLIMIT_DATA: %m\n");
ce426f
 	}
ce426f
       else
ce426f
-	perror ("getrlimit: RLIMIT_DATA");
ce426f
+	printf ("getrlimit: RLIMIT_DATA: %m\n");
ce426f
 #endif
ce426f
 
ce426f
       /* We put the test process in its own pgrp so that if it bogusly
ce426f
@@ -382,7 +382,7 @@ main (int argc, char *argv[])
ce426f
     }
ce426f
   else if (pid < 0)
ce426f
     {
ce426f
-      perror ("Cannot fork test program");
ce426f
+      printf ("Cannot fork test program: %m\n");
ce426f
       exit (1);
ce426f
     }
ce426f
 
ce426f
@@ -420,18 +420,16 @@ main (int argc, char *argv[])
ce426f
       if (EXPECTED_SIGNAL != 0)
ce426f
 	{
ce426f
 	  if (WTERMSIG (status) == 0)
ce426f
-	    fprintf (stderr,
ce426f
-		     "Expected signal '%s' from child, got none\n",
ce426f
-		     strsignal (EXPECTED_SIGNAL));
ce426f
+	    printf ("Expected signal '%s' from child, got none\n",
ce426f
+		    strsignal (EXPECTED_SIGNAL));
ce426f
 	  else
ce426f
-	    fprintf (stderr,
ce426f
-		     "Incorrect signal from child: got `%s', need `%s'\n",
ce426f
-		     strsignal (WTERMSIG (status)),
ce426f
-		     strsignal (EXPECTED_SIGNAL));
ce426f
+	    printf ("Incorrect signal from child: got `%s', need `%s'\n",
ce426f
+		    strsignal (WTERMSIG (status)),
ce426f
+		    strsignal (EXPECTED_SIGNAL));
ce426f
 	}
ce426f
       else
ce426f
-	fprintf (stderr, "Didn't expect signal from child: got `%s'\n",
ce426f
-		 strsignal (WTERMSIG (status)));
ce426f
+	printf ("Didn't expect signal from child: got `%s'\n",
ce426f
+		strsignal (WTERMSIG (status)));
ce426f
       exit (1);
ce426f
     }
ce426f
 
ce426f
@@ -441,8 +439,8 @@ main (int argc, char *argv[])
ce426f
 #else
ce426f
   if (WEXITSTATUS (status) != EXPECTED_STATUS)
ce426f
     {
ce426f
-      fprintf (stderr, "Expected status %d, got %d\n",
ce426f
-	       EXPECTED_STATUS, WEXITSTATUS (status));
ce426f
+      printf ("Expected status %d, got %d\n",
ce426f
+	      EXPECTED_STATUS, WEXITSTATUS (status));
ce426f
       exit (1);
ce426f
     }
ce426f