From: Peter Rosin Date: Mon, 23 Jan 2012 08:18:46 +0000 (+0100) Subject: tests: improve diagnostics when write(2) fails X-Git-Tag: ng-0.5a~27^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3794d01e0d62f5f93118ca6b3c75ddc84995d541;p=thirdparty%2Fautomake.git tests: improve diagnostics when write(2) fails MinGW programs can't redirect file descriptor 9, they can only redirect stdin, stdout and stderr. So, improve the information in the test log. See automake bug#10466. * tests/parallel-tests-fd-redirect.test (baz.c, zardoz.c): Check the return value from the write(2) call, and report detected errors. --- diff --git a/tests/parallel-tests-fd-redirect.test b/tests/parallel-tests-fd-redirect.test index 73a134e25..8b1637896 100755 --- a/tests/parallel-tests-fd-redirect.test +++ b/tests/parallel-tests-fd-redirect.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2011 Free Software Foundation, Inc. +# Copyright (C) 2011, 2012 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -65,20 +65,26 @@ END chmod a+x foo.sh bar cat > baz.c <<'END' +#include #include int main (void) { - write (9, " bazbazbaz\n", 11); - return 0; + ssize_t res = write (9, " bazbazbaz\n", 11); + if (res < 0) + perror("write failed"); + return res != 11; } END cat > zardoz.c <<'END' +#include #include int main (void) { - write (9, " quxquxqux\n", 11); - return 0; + ssize_t res = write (9, " quxquxqux\n", 11); + if (res < 0) + perror("write failed"); + return res != 11; } END