Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* libio/Makefile (tests): Add tst-ext2.
* libio/tst-ext2.c: New file.
- Loading branch information
Ulrich Drepper
committed
Oct 13, 2007
1 parent
ed36f22
commit 7e39d80
Showing
3 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include <stdio.h> | ||
#include <stdio_ext.h> | ||
|
||
|
||
static char *fname; | ||
|
||
#define PREPARE(argc, argv) \ | ||
do { \ | ||
int fd = create_temp_file ("tst-ext2", &fname); \ | ||
if (fd == -1) \ | ||
{ \ | ||
puts ("cannot create temporary file"); \ | ||
exit (1); \ | ||
} \ | ||
close (fd); \ | ||
} while (0) | ||
|
||
|
||
static int | ||
do_test (void) | ||
{ | ||
int res = 0; | ||
|
||
FILE *fp; | ||
|
||
fp = fopen (fname, "w"); | ||
printf ("Initial state for write-only stream: %d %d\n", | ||
__freading (fp) != 0, __fwriting (fp) != 0); | ||
res |= ((__freading (fp) != 0) != 0 | ||
|| (__fwriting (fp) != 0) != 1); | ||
fclose (fp); | ||
|
||
fp = fopen (fname, "r"); | ||
printf ("Initial state for read-only stream: %d %d\n", | ||
__freading (fp) != 0, __fwriting (fp) != 0); | ||
res |= ((__freading (fp) != 0) != 1 | ||
|| (__fwriting (fp) != 0) != 0); | ||
fclose (fp); | ||
|
||
fp = fopen (fname, "r+"); | ||
printf ("Initial state for read-write stream: %d %d\n", | ||
__freading (fp) != 0, __fwriting (fp) != 0); | ||
res |= ((__freading (fp) != 0) != 0 | ||
|| (__fwriting (fp) != 0) != 0); | ||
fclose (fp); | ||
|
||
fp = fopen (fname, "w+"); | ||
printf ("Initial state for read-write stream: %d %d\n", | ||
__freading (fp) != 0, __fwriting (fp) != 0); | ||
res |= ((__freading (fp) != 0) != 0 | ||
|| (__fwriting (fp) != 0) != 0); | ||
fclose (fp); | ||
|
||
return res; | ||
} | ||
|
||
#define TEST_FUNCTION do_test () | ||
#include "../test-skeleton.c" |