diff options
author | Bruno Haible <bruno@clisp.org> | 2012-05-13 22:54:49 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2012-05-13 22:57:52 +0200 |
commit | 290f951644e3c7ae4a9bc14ae89ed071b33b9a18 (patch) | |
tree | 482a0c16ef0f22b2942e4d8fa81613805b093a19 /tests | |
parent | 81e2fe40473d40b254dea9484525c343d896a439 (diff) | |
download | gnulib-290f951644e3c7ae4a9bc14ae89ed071b33b9a18.tar.gz |
binary-io: Define set_binary_mode function.
* lib/binary-io.h (set_binary_mode): New function.
(SET_BINARY): Define in terms of set_binary_mode.
* modules/binary-io (configure.ac): Require AC_C_INLINE.
* tests/test-binary-io.c (main): Accept an argument, and test either
set_binary_mode or SET_BINARY depending on the argument.
* tests/test-binary-io.sh: Invoke test-binary-io twice, with an
argument. Clean up also t-bin-out0.tmp.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-binary-io.c | 26 | ||||
-rwxr-xr-x | tests/test-binary-io.sh | 8 |
2 files changed, 25 insertions, 9 deletions
diff --git a/tests/test-binary-io.c b/tests/test-binary-io.c index c695454ecd..4f284e7015 100644 --- a/tests/test-binary-io.c +++ b/tests/test-binary-io.c @@ -30,26 +30,40 @@ #include "macros.h" int -main () +main (int argc, char *argv[]) { /* Test the O_BINARY macro. */ { int fd = - open ("t-bin-out2.tmp", O_CREAT | O_TRUNC | O_RDWR | O_BINARY, 0600); + open ("t-bin-out0.tmp", O_CREAT | O_TRUNC | O_RDWR | O_BINARY, 0600); if (write (fd, "Hello\n", 6) < 0) exit (1); close (fd); } { struct stat statbuf; - if (stat ("t-bin-out2.tmp", &statbuf) < 0) + if (stat ("t-bin-out0.tmp", &statbuf) < 0) exit (1); ASSERT (statbuf.st_size == 6); } - /* Test the SET_BINARY macro. */ - SET_BINARY (1); - fputs ("Hello\n", stdout); + switch (argv[1][0]) + { + case '1': + /* Test the set_binary_mode() function. */ + set_binary_mode (1, O_BINARY); + fputs ("Hello\n", stdout); + break; + + case '2': + /* Test the SET_BINARY macro. */ + SET_BINARY (1); + fputs ("Hello\n", stdout); + break; + + default: + break; + } return 0; } diff --git a/tests/test-binary-io.sh b/tests/test-binary-io.sh index 272edef179..c4dd6e9295 100755 --- a/tests/test-binary-io.sh +++ b/tests/test-binary-io.sh @@ -3,9 +3,11 @@ tmpfiles="" trap 'rm -fr $tmpfiles' 1 2 3 15 -tmpfiles="$tmpfiles t-bin-out1.tmp t-bin-out2.tmp" -./test-binary-io${EXEEXT} > t-bin-out1.tmp || exit 1 -cmp t-bin-out1.tmp t-bin-out2.tmp > /dev/null || exit 1 +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 |