Mercurial > hg > octave-lojdl > gnulib-hg
annotate tests/test-binary-io.c @ 13575:34fed8ca014c
autoupdate
author | Karl Berry <karl@freefriends.org> |
---|---|
date | Thu, 26 Aug 2010 06:33:40 -0700 |
parents | c2cbabec01dd |
children | 97fc9a21a8fb |
rev | line source |
---|---|
7869 | 1 /* Test of binary mode I/O. |
12559
c2cbabec01dd
update nearly all FSF copyright year lists to include 2010
Jim Meyering <meyering@redhat.com>
parents:
12496
diff
changeset
|
2 Copyright (C) 2005, 2007-2010 Free Software Foundation, Inc. |
7869 | 3 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8910
diff
changeset
|
4 This program is free software: you can redistribute it and/or modify |
7869 | 5 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8910
diff
changeset
|
6 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8910
diff
changeset
|
7 (at your option) any later version. |
7869 | 8 |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License | |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8910
diff
changeset
|
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
7869 | 16 |
17 /* Written by Bruno Haible <bruno@clisp.org>, 2005. */ | |
18 | |
8891
633babea5f62
Unconditionally include <config.h> in unit tests.
Eric Blake <ebb9@byu.net>
parents:
8754
diff
changeset
|
19 #include <config.h> |
7869 | 20 |
21 #include "binary-io.h" | |
22 | |
23 #include <sys/types.h> | |
24 #include <sys/stat.h> | |
25 #include <fcntl.h> | |
26 #include <stdio.h> | |
27 #include <stdlib.h> | |
28 #include <unistd.h> | |
29 | |
12496
a48d3d749ca5
Refactor common macros used in tests.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
30 #include "macros.h" |
7869 | 31 |
32 int | |
33 main () | |
34 { | |
35 /* Test the O_BINARY macro. */ | |
36 { | |
8910
a7e0b65d5c78
Attempt to fix a test failure on Solaris (open fails with EACCES).
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
37 int fd = |
a7e0b65d5c78
Attempt to fix a test failure on Solaris (open fails with EACCES).
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
38 open ("t-bin-out2.tmp", O_CREAT | O_TRUNC | O_RDWR | O_BINARY, 0600); |
7869 | 39 if (write (fd, "Hello\n", 6) < 0) |
40 exit (1); | |
41 close (fd); | |
42 } | |
43 { | |
44 struct stat statbuf; | |
8412
6db7303a6033
Choose better temporary filenames.
Bruno Haible <bruno@clisp.org>
parents:
7869
diff
changeset
|
45 if (stat ("t-bin-out2.tmp", &statbuf) < 0) |
7869 | 46 exit (1); |
47 ASSERT (statbuf.st_size == 6); | |
48 } | |
8412
6db7303a6033
Choose better temporary filenames.
Bruno Haible <bruno@clisp.org>
parents:
7869
diff
changeset
|
49 unlink ("t-bin-out2.tmp"); |
7869 | 50 |
51 /* Test the SET_BINARY macro. */ | |
52 SET_BINARY (1); | |
53 fputs ("Hello\n", stdout); | |
54 fclose (stdout); | |
55 fclose (stderr); | |
56 { | |
57 struct stat statbuf; | |
8412
6db7303a6033
Choose better temporary filenames.
Bruno Haible <bruno@clisp.org>
parents:
7869
diff
changeset
|
58 if (stat ("t-bin-out1.tmp", &statbuf) < 0) |
7869 | 59 exit (1); |
60 ASSERT (statbuf.st_size == 6); | |
61 } | |
62 | |
63 return 0; | |
64 } |