1 /* Test of fwrite() function, adapted from gnulib-tests in grep.
2 Copyright (C) 2011-2017 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
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.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */
26 char tmpl
[] = "/tmp/tst-fwrite-error.XXXXXX";
27 int fd
= mkstemp (tmpl
);
30 printf ("mkstemp failed with errno %d\n", errno
);
33 FILE *fp
= fdopen (fd
, "w");
36 printf ("fdopen failed with errno %d\n", errno
);
41 setvbuf (fp
, NULL
, _IONBF
, 0);
46 int ret
= fwrite (buf
, 1, sizeof (buf
), fp
);
49 printf ("fwrite returned %d\n", ret
);
54 printf ("Errno is not EBADF: %d\n", errno
);
59 printf ("ferror not set\n");
66 #define TEST_FUNCTION do_test ()
67 #include "../test-skeleton.c"