[RFC] gdb/testsuite/gdb.base/fileio.exp patch for cygwin

Pierre Muller muller@ics.u-strasbg.fr
Mon Dec 3 10:02:00 GMT 2007

I tried to expose some cygwin testsuite problems
related to the fact that dejagnu does not seem
to be able to fool the cygwin system, to
get it to believe that the output is not redirected.


  The main effect is that, Cygwin knowing that 
the output is redirected to a non-tty, it will start
to use file buffering that will interact badly
with the expectation of the gdb testsuite.

  A typical example is gdb.base/fileio.exp,
because it shows both sides of what I am

  By simply adding a setbuf (stdout, NULL);
at the start of main, I reduce the number of
failures from 38 to 3.
  The three remaining failures are
the three tests for isatty function on stdin, stdout and stderr descriptors,
which are the cause of the described problem.

  As said in the referenced email, I do not know
if this is only because the cygwin port of dejagnu is old
or if it is more general.

  Is a patch like this suitable for inclusion 
in gdb testsuite? 
  If not, is there another way to try to improve
the testsuite on cygwin?

Pierre Muller

ChangeLog entry:

2007-12-02  Pierre Muller  <muller@ics.u-strasbg.fr>

	* gdb.base/fileio.c (main): Disable file buffering for Cygwin.

$ cvs diff -up gdb.base/fileio.c
Index: gdb.base/fileio.c
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/fileio.c,v
retrieving revision 1.10
diff -u -p -r1.10 fileio.c
--- gdb.base/fileio.c   13 Jun 2006 08:55:22 -0000      1.10
+++ gdb.base/fileio.c   3 Dec 2007 09:58:17 -0000
@@ -1,5 +1,5 @@
-#include <stdio.h>
 #include <stdlib.h>
+#include <stdio.h>
 #include <string.h>
 #include <sys/errno.h>
 #include <sys/types.h>
@@ -542,6 +542,9 @@ strerrno (int err)
 main ()
+#ifdef __CYGWIN__
+  setbuf (stdout, NULL);
+#endif /* __CYGWIN__ */
   /* Don't change the order of the calls.  They partly depend on each other
   test_open ();
   test_write ();

More information about the Gdb-patches mailing list