Message ID | 1397210429-28716-1-git-send-email-will.newton@linaro.org |
---|---|
State | Superseded |
Headers | show |
On Fri, Apr 11, 2014 at 11:00:29AM +0100, Will Newton wrote: > At the moment a mixture of stderr and stdout is used for error > messages. Switch to using stderr for consistency. > Looks ok except that > ChangeLog: > > 2014-04-09 Will Newton <will.newton@linaro.org> > > * test-skeleton.c (create_temp_file): Use stderr for > outputting error messages. (main): Likewise. (main): should be at new line
On Fri, Apr 11, 2014 at 11:00:29AM +0100, Will Newton wrote: > At the moment a mixture of stderr and stdout is used for error > messages. Switch to using stderr for consistency. > > ChangeLog: > > 2014-04-09 Will Newton <will.newton@linaro.org> > > * test-skeleton.c (create_temp_file): Use stderr for > outputting error messages. (main): Likewise. There was a discussion in the past about sticking to stdout for everything for consistency. I can't find the link to it, but it is mentioned on the wiki: https://sourceware.org/glibc/wiki/Testing/Testsuite#Writing_a_test_case Siddhesh
On 11 April 2014 14:16, Siddhesh Poyarekar <siddhesh@redhat.com> wrote: > On Fri, Apr 11, 2014 at 11:00:29AM +0100, Will Newton wrote: >> At the moment a mixture of stderr and stdout is used for error >> messages. Switch to using stderr for consistency. >> >> ChangeLog: >> >> 2014-04-09 Will Newton <will.newton@linaro.org> >> >> * test-skeleton.c (create_temp_file): Use stderr for >> outputting error messages. (main): Likewise. > > There was a discussion in the past about sticking to stdout for > everything for consistency. I can't find the link to it, but it is > mentioned on the wiki: > > https://sourceware.org/glibc/wiki/Testing/Testsuite#Writing_a_test_case So we should really be going the other way and outputting everything to stdout? At the moment test stdout goes to the test output file but stderr goes to the console. I'm not sure which is the more useful behaviour but consistency certainly seems good.
On Fri, Apr 11, 2014 at 02:39:21PM +0100, Will Newton wrote: > On 11 April 2014 14:16, Siddhesh Poyarekar <siddhesh@redhat.com> wrote: > > On Fri, Apr 11, 2014 at 11:00:29AM +0100, Will Newton wrote: > >> At the moment a mixture of stderr and stdout is used for error > >> messages. Switch to using stderr for consistency. > >> > >> ChangeLog: > >> > >> 2014-04-09 Will Newton <will.newton@linaro.org> > >> > >> * test-skeleton.c (create_temp_file): Use stderr for > >> outputting error messages. (main): Likewise. > > > > There was a discussion in the past about sticking to stdout for > > everything for consistency. I can't find the link to it, but it is > > mentioned on the wiki: > > > > https://sourceware.org/glibc/wiki/Testing/Testsuite#Writing_a_test_case > > So we should really be going the other way and outputting everything to stdout? Yes, that is also why we avoid using perror in test cases. There are some that do, but they need to be updated. Ideally I think we need a WARN status for test cases that want to warn of a condition and not actually fail, but that's probably something for later. Siddhesh
diff --git a/test-skeleton.c b/test-skeleton.c index d7d2f75..437c51d 100644 --- a/test-skeleton.c +++ b/test-skeleton.c @@ -110,7 +110,7 @@ create_temp_file (const char *base, char **filename) + sizeof ("XXXXXX")); if (fname == NULL) { - puts ("out of memory"); + fputs ("out of memory", stderr); return -1; } strcpy (stpcpy (stpcpy (stpcpy (fname, test_dir), "/"), base), "XXXXXX"); @@ -118,7 +118,7 @@ create_temp_file (const char *base, char **filename) fd = mkstemp (fname); if (fd == -1) { - printf ("cannot open temporary file '%s': %m\n", fname); + fprintf (stderr, "cannot open temporary file '%s': %m\n", fname); free (fname); return -1; } @@ -368,12 +368,12 @@ main (int argc, char *argv[]) termpid = TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)); if (termpid == -1) { - printf ("Waiting for test program failed: %m\n"); + fprintf (stderr, "Waiting for test program failed: %m\n"); exit (1); } if (termpid != pid) { - printf ("Oops, wrong test program terminated: expected %ld, got %ld\n", + fprintf (stderr, "Oops, wrong test program terminated: expected %ld, got %ld\n", (long int) pid, (long int) termpid); exit (1); }