bug-automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#10466: [PATCH] tests: improve diagnostics when write(2) fails (was:


From: Peter Rosin
Subject: bug#10466: [PATCH] tests: improve diagnostics when write(2) fails (was: bug#10466: MSYS problem with redirects)
Date: Mon, 23 Jan 2012 09:48:15 +0100
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0) Gecko/20111222 Thunderbird/9.0.1

Stefano Lattarini skrev 2012-01-09 20:32:
> On 01/09/2012 12:29 PM, Peter Rosin wrote:
>> With this diff:
>>
>> diff --git a/tests/parallel-tests-fd-redirect.test 
>> b/tests/parallel-tests-fd-red
>> index 73a134e..5728014 100755
>> --- a/tests/parallel-tests-fd-redirect.test
>> +++ b/tests/parallel-tests-fd-redirect.test
>> @@ -65,20 +65,26 @@ END
>>  chmod a+x foo.sh bar
>>
>>  cat > baz.c <<'END'
>> +#include <stdio.h>
>>  #include <unistd.h>
>>  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 <stdio.h>
>>  #include <unistd.h>
>>  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
>>
> BTW, this change might be independently useful in catching other potential
> unexpected write failures; would you feel like cooking it in a proper patch?

Like this (for master)?

Cheers,
Peter


>From a8265beb4490e9188358d6e761da33ae326aff41 Mon Sep 17 00:00:00 2001
From: Peter Rosin <address@hidden>
Date: Mon, 23 Jan 2012 09:18:46 +0100
Subject: [PATCH] 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.
---
 tests/parallel-tests-fd-redirect.test |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/tests/parallel-tests-fd-redirect.test 
b/tests/parallel-tests-fd-redirect.test
index 73a134e..8b16378 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 <stdio.h>
 #include <unistd.h>
 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 <stdio.h>
 #include <unistd.h>
 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
 
-- 
1.7.5.1






reply via email to

[Prev in Thread] Current Thread [Next in Thread]