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