From: Bruno Haible Date: Sun, 27 Apr 2008 14:22:30 +0000 (+0200) Subject: Make test-yesno.sh work on mingw. X-Git-Tag: v0.1~7483 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=d51d502c49efdd8e625873420a19e69f63f9fec5;p=gnulib.git Make test-yesno.sh work on mingw. --- diff --git a/ChangeLog b/ChangeLog index fbb9858b1..8ae01efc4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2008-04-27 Bruno Haible + Make test-yesno.sh work on mingw. + * tests/test-yesno.sh: Postprocess the output to convert CR/LF to LF. + * tests/test-yesno.c: Include yesno.h first. Include binary-io.h. + (main): Set stdin to binary mode. + * modules/yesno-tests (Depends-on): Add binary-io. + +2008-04-27 Bruno Haible + Fix 'isfinite' on x86, x86_64, ia64 platforms. * tests/test-isfinite.c (test_isfinitel): Also test the behavior on argument that lie outside the IEEE 854 domain. diff --git a/modules/yesno-tests b/modules/yesno-tests index 7704e90a3..3d484dac0 100644 --- a/modules/yesno-tests +++ b/modules/yesno-tests @@ -4,6 +4,7 @@ tests/test-yesno.sh Depends-on: closein +binary-io configure.ac: diff --git a/tests/test-yesno.c b/tests/test-yesno.c index 1e15acdda..29db60cec 100644 --- a/tests/test-yesno.c +++ b/tests/test-yesno.c @@ -1,5 +1,5 @@ /* Test of yesno module. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007-2008 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 @@ -17,12 +17,15 @@ #include +/* Specification. */ +#include "yesno.h" + #include #include #include #include "closein.h" -#include "yesno.h" +#include "binary-io.h" char *program_name; @@ -35,8 +38,19 @@ main (int argc, char **argv) { int i = 1; program_name = argv[0]; + /* yesno recommends that all clients use close_stdin in main. */ atexit (close_stdin); + /* But on mingw, close_stdin leaves stdin's file descriptor at the expected + position (i.e. where this program left off reading) only if its mode has + been set to O_BINARY. If it has been set to O_TEXT, and the file + descriptor is seekable, and stdin is buffered, the MSVCRT runtime ends up + setting the file descriptor's position to the expected position _minus_ + the number of LFs not preceded by CR that were read between the expected + position and the last filled buffer end position. (I.e. the repositioning + from the end-of-buffer to the expected position does not work if the input + file contains end-of-line markers in Unix convention.) */ + SET_BINARY (0); if (1 < argc) i = atoi (argv[1]); diff --git a/tests/test-yesno.sh b/tests/test-yesno.sh index 5de918c6f..52b94ef05 100755 --- a/tests/test-yesno.sh +++ b/tests/test-yesno.sh @@ -4,13 +4,21 @@ tmpfiles= trap 'rm -fr $tmpfiles' 1 2 3 15 p=t-yesno- -tmpfiles="${p}in.tmp ${p}xout.tmp ${p}out.tmp ${p}err.tmp" +tmpfiles="${p}in.tmp ${p}xout.tmp ${p}out1.tmp ${p}out.tmp ${p}err.tmp" # For now, only test with C locale LC_ALL=C export LC_ALL -# Test with seekable stdin; followon process must see remaining data +# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr +# does not understand '\r'. +if echo solaris | tr -d '\r' | grep solais > /dev/null; then + cr='\015' +else + cr='\r' +fi + +# Test with seekable stdin; the followon process must see remaining data. cat < ${p}in.tmp nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn - entire line consumed yn - backspace does not change result @@ -18,6 +26,7 @@ y does not match either yesexpr or noexpr n EOF + cat < ${p}xout.tmp N Y @@ -25,12 +34,15 @@ Y N n EOF + (./test-yesno${EXEEXT}; ./test-yesno${EXEEXT} 3; cat) \ - < ${p}in.tmp > ${p}out.tmp || exit 1 + < ${p}in.tmp > ${p}out1.tmp || exit 1 +LC_ALL=C tr -d "$cr" < ${p}out1.tmp > ${p}out.tmp || exit 1 cmp ${p}xout.tmp ${p}out.tmp || exit 1 (./test-yesno${EXEEXT} 3; ./test-yesno${EXEEXT}; cat) \ - < ${p}in.tmp > ${p}out.tmp || exit 1 + < ${p}in.tmp > ${p}out1.tmp || exit 1 +LC_ALL=C tr -d "$cr" < ${p}out1.tmp > ${p}out.tmp || exit 1 cmp ${p}xout.tmp ${p}out.tmp || exit 1 # Test for behavior on pipe @@ -38,18 +50,21 @@ cat < ${p}xout.tmp Y N EOF -echo yes | ./test-yesno${EXEEXT} 2 > ${p}out.tmp || exit 1 +echo yes | ./test-yesno${EXEEXT} 2 > ${p}out1.tmp || exit 1 +LC_ALL=C tr -d "$cr" < ${p}out1.tmp > ${p}out.tmp || exit 1 cmp ${p}xout.tmp ${p}out.tmp || exit 1 # Test for behavior on EOF cat < ${p}xout.tmp N EOF -./test-yesno${EXEEXT} ${p}out.tmp || exit 1 +./test-yesno${EXEEXT} ${p}out1.tmp || exit 1 +LC_ALL=C tr -d "$cr" < ${p}out1.tmp > ${p}out.tmp || exit 1 cmp ${p}xout.tmp ${p}out.tmp || exit 1 # Test for behavior when stdin is closed -./test-yesno${EXEEXT} 0 <&- > ${p}out.tmp 2> ${p}err.tmp && exit 1 +./test-yesno${EXEEXT} 0 <&- > ${p}out1.tmp 2> ${p}err.tmp && exit 1 +LC_ALL=C tr -d "$cr" < ${p}out1.tmp > ${p}out.tmp || exit 1 cmp ${p}xout.tmp ${p}out.tmp || exit 1 test -s ${p}err.tmp || exit 1