Discussion:
[PATCH] tests: Adjust to recent SET_BINARY change
(too old to reply)
Paul Eggert
2017-02-15 23:33:52 UTC
Permalink
Raw Message
* tests/test-binary-io.c (main):
* tests/test-binary-io.sh: Remove test for SET_BINARY.
* tests/test-closein.c, tests/test-fflush2.c, tests/test-ftell.c:
* tests/test-ftello.c, tests/test-nonblocking-pipe-child.c:
* tests/test-yesno.c: Use set_binary_mode, not SET_BINARY.
---
ChangeLog | 7 +++++++
tests/test-binary-io.c | 6 ------
tests/test-binary-io.sh | 2 --
tests/test-closein.c | 2 +-
tests/test-fflush2.c | 2 +-
tests/test-ftell.c | 2 +-
tests/test-ftello.c | 2 +-
tests/test-nonblocking-pipe-child.c | 2 +-
tests/test-yesno.c | 2 +-
9 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 756858d..f7bccee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2017-02-15 Paul Eggert <***@cs.ucla.edu>

+ tests: Adjust to recent SET_BINARY change
+ * tests/test-binary-io.c (main):
+ * tests/test-binary-io.sh: Remove test for SET_BINARY.
+ * tests/test-closein.c, tests/test-fflush2.c, tests/test-ftell.c:
+ * tests/test-ftello.c, tests/test-nonblocking-pipe-child.c:
+ * tests/test-yesno.c: Use set_binary_mode, not SET_BINARY.
+
xsetmode: new module
This is to fix a problem noted by Eric Blake.
Code was using xfreopen to change files to binary mode, but this
diff --git a/tests/test-binary-io.c b/tests/test-binary-io.c
index f53a1ae..46ccce5 100644
--- a/tests/test-binary-io.c
+++ b/tests/test-binary-io.c
@@ -55,12 +55,6 @@ main (int argc, char *argv[])
fputs ("Hello\n", stdout);
break;

- case '2':
- /* Test the SET_BINARY macro. */
- SET_BINARY (1);
- fputs ("Hello\n", stdout);
- break;
-
default:
break;
}
diff --git a/tests/test-binary-io.sh b/tests/test-binary-io.sh
index c4dd6e9..3af53c6 100755
--- a/tests/test-binary-io.sh
+++ b/tests/test-binary-io.sh
@@ -6,8 +6,6 @@ trap 'rm -fr $tmpfiles' 1 2 3 15
tmpfiles="$tmpfiles t-bin-out0.tmp t-bin-out1.tmp t-bin-out2.tmp"
./test-binary-io${EXEEXT} 1 > t-bin-out1.tmp || exit 1
cmp t-bin-out0.tmp t-bin-out1.tmp > /dev/null || exit 1
-./test-binary-io${EXEEXT} 2 > t-bin-out2.tmp || exit 1
-cmp t-bin-out0.tmp t-bin-out2.tmp > /dev/null || exit 1

rm -fr $tmpfiles

diff --git a/tests/test-closein.c b/tests/test-closein.c
index 7e3ffa0..bd2b33e 100644
--- a/tests/test-closein.c
+++ b/tests/test-closein.c
@@ -38,7 +38,7 @@ main (int argc, char **argv)

/* close_stdin currently relies on ftell, but mingw ftell is
unreliable on text mode input. */
- SET_BINARY (0);
+ set_binary_mode (0, O_BINARY);

if (argc > 2)
close (0);
diff --git a/tests/test-fflush2.c b/tests/test-fflush2.c
index 2d8d33a..4d1237b 100644
--- a/tests/test-fflush2.c
+++ b/tests/test-fflush2.c
@@ -28,7 +28,7 @@ main (int argc, char **argv)

/* Avoid the well-known bugs of fflush() on streams in O_TEXT mode
on native Windows platforms. */
- SET_BINARY (0);
+ set_binary_mode (0, O_BINARY);

if (argc > 1)
switch (argv[1][0])
diff --git a/tests/test-ftell.c b/tests/test-ftell.c
index 7df08fd..3307702 100644
--- a/tests/test-ftell.c
+++ b/tests/test-ftell.c
@@ -45,7 +45,7 @@ main (int argc, char **argv)
}

/* mingw ftell is unreliable on text mode input. */
- SET_BINARY (0);
+ set_binary_mode (0, O_BINARY);

/* Simple tests. */
ASSERT (ftell (stdin) == 0);
diff --git a/tests/test-ftello.c b/tests/test-ftello.c
index 9ea9240..1e9f400 100644
--- a/tests/test-ftello.c
+++ b/tests/test-ftello.c
@@ -46,7 +46,7 @@ main (int argc, char **argv _GL_UNUSED)
}

/* mingw ftell is unreliable on text mode input. */
- SET_BINARY (0);
+ set_binary_mode (0, O_BINARY);

/* Simple tests. For each test, make sure ftell and ftello agree. */
ASSERT (ftell (stdin) == 0);
diff --git a/tests/test-nonblocking-pipe-child.c b/tests/test-nonblocking-pipe-child.c
index c965231..421bfc9 100644
--- a/tests/test-nonblocking-pipe-child.c
+++ b/tests/test-nonblocking-pipe-child.c
@@ -42,7 +42,7 @@ main (int argc, char *argv[])
/* STDIN_FILENO was created as binary in the parent process. But since an
fd's mode is stored in the process, not in the kernel, on native Windows
we need to set it as binary in the child process again. */
- SET_BINARY (STDIN_FILENO);
+ set_binary_mode (STDIN_FILENO, O_BINARY);

main_reader_loop (test, PIPE_DATA_BLOCK_SIZE, STDIN_FILENO);

diff --git a/tests/test-yesno.c b/tests/test-yesno.c
index 417d007..fdfd3b5 100644
--- a/tests/test-yesno.c
+++ b/tests/test-yesno.c
@@ -47,7 +47,7 @@ main (int argc, char **argv)
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);
+ set_binary_mode (0, O_BINARY);

if (1 < argc)
i = atoi (argv[1]);
--
2.9.3
Bruno Haible
2017-02-16 02:42:30 UTC
Permalink
Raw Message
Hi Paul,
Post by Paul Eggert
--- a/tests/test-binary-io.sh
+++ b/tests/test-binary-io.sh
@@ -6,8 +6,6 @@ trap 'rm -fr $tmpfiles' 1 2 3 15
tmpfiles="$tmpfiles t-bin-out0.tmp t-bin-out1.tmp t-bin-out2.tmp"
./test-binary-io${EXEEXT} 1 > t-bin-out1.tmp || exit 1
cmp t-bin-out0.tmp t-bin-out1.tmp > /dev/null || exit 1
-./test-binary-io${EXEEXT} 2 > t-bin-out2.tmp || exit 1
-cmp t-bin-out0.tmp t-bin-out2.tmp > /dev/null || exit 1
rm -fr $tmpfiles
Here's a followup cleanup:

--- a/tests/test-binary-io.sh
+++ b/tests/test-binary-io.sh
@@ -3,7 +3,7 @@
tmpfiles=""
trap 'rm -fr $tmpfiles' 1 2 3 15

-tmpfiles="$tmpfiles t-bin-out0.tmp t-bin-out1.tmp t-bin-out2.tmp"
+tmpfiles="$tmpfiles t-bin-out0.tmp t-bin-out1.tmp"
./test-binary-io${EXEEXT} 1 > t-bin-out1.tmp || exit 1
cmp t-bin-out0.tmp t-bin-out1.tmp > /dev/null || exit 1


Bruno

Loading...