diff options
author | Ulrich Drepper <drepper@redhat.com> | 2007-10-13 07:33:09 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2007-10-13 07:33:09 +0000 |
commit | 7e39d8025d5c9d02c61f1506642c7dd91a1e461a (patch) | |
tree | bab2e92125e1a88efe62fea64c7b503d0671c2b4 /libio/tst-ext2.c | |
parent | ed36f224c30088f10ecb0f190091508e917379a3 (diff) | |
download | glibc-7e39d8025d5c9d02c61f1506642c7dd91a1e461a.tar glibc-7e39d8025d5c9d02c61f1506642c7dd91a1e461a.tar.gz glibc-7e39d8025d5c9d02c61f1506642c7dd91a1e461a.tar.bz2 glibc-7e39d8025d5c9d02c61f1506642c7dd91a1e461a.zip |
* libio/Makefile (tests): Add tst-ext2.
* libio/tst-ext2.c: New file.
Diffstat (limited to 'libio/tst-ext2.c')
-rw-r--r-- | libio/tst-ext2.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/libio/tst-ext2.c b/libio/tst-ext2.c new file mode 100644 index 0000000000..ed72efa0c7 --- /dev/null +++ b/libio/tst-ext2.c @@ -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" |