]> git.ipfire.org Git - thirdparty/glibc.git/blob - stdio-common/tst-put-error.c
* configure.in: Compile source test file with -fPIC for -shared.
[thirdparty/glibc.git] / stdio-common / tst-put-error.c
1 #include <errno.h>
2 #include <error.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <unistd.h>
6
7
8 static int
9 do_test (void)
10 {
11 char tmpl[] = "/tmp/tst-put-error.XXXXXX";
12 int fd = mkstemp (tmpl);
13 if (fd == -1)
14 error (EXIT_FAILURE, errno, "cannot create temporary file");
15 FILE *fp = fdopen (fd, "w");
16 if (fp == NULL)
17 error (EXIT_FAILURE, errno, "fdopen");
18 setlinebuf (fp);
19 close (fd);
20 unlink (tmpl);
21 int n = fprintf (fp, "hello world\n");
22 printf ("fprintf = %d\n", n);
23 if (n >= 0)
24 error (EXIT_FAILURE, 0, "first fprintf succeeded");
25 n = fprintf (fp, "hello world\n");
26 printf ("fprintf = %d\n", n);
27 if (n >= 0)
28 error (EXIT_FAILURE, 0, "second fprintf succeeded");
29 return 0;
30 }
31
32 #define TEST_FUNCTION do_test ()
33 #include "../test-skeleton.c"