aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-10-13 07:33:09 +0000
committerUlrich Drepper <drepper@redhat.com>2007-10-13 07:33:09 +0000
commit7e39d8025d5c9d02c61f1506642c7dd91a1e461a (patch)
treebab2e92125e1a88efe62fea64c7b503d0671c2b4
parented36f224c30088f10ecb0f190091508e917379a3 (diff)
downloadglibc-7e39d8025d5c9d02c61f1506642c7dd91a1e461a.zip
glibc-7e39d8025d5c9d02c61f1506642c7dd91a1e461a.tar.gz
glibc-7e39d8025d5c9d02c61f1506642c7dd91a1e461a.tar.bz2
* libio/Makefile (tests): Add tst-ext2.
* libio/tst-ext2.c: New file.
-rw-r--r--ChangeLog2
-rw-r--r--libio/Makefile4
-rw-r--r--libio/tst-ext2.c58
3 files changed, 62 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 89ec38c..99ae63e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,8 @@
* libio/__freading.c (__freading): Don't return true for
write-only streams. For read/write streams, check whether we
performed a read operation already.
+ * libio/Makefile (tests): Add tst-ext2.
+ * libio/tst-ext2.c: New file.
2007-10-12 Ulrich Drepper <drepper@redhat.com>
diff --git a/libio/Makefile b/libio/Makefile
index 553fbda..31fac70 100644
--- a/libio/Makefile
+++ b/libio/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1995-2002,2003,2004,2006 Free Software Foundation, Inc.
+# Copyright (C) 1995-2002,2003,2004,2006,2007 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
@@ -48,7 +48,7 @@ routines := \
libc_fatal fmemopen
tests = tst_swprintf tst_wprintf tst_swscanf tst_wscanf tst_getwc tst_putwc \
- tst_wprintf2 tst-widetext test-fmemopen tst-ext tst-fopenloc \
+ tst_wprintf2 tst-widetext test-fmemopen tst-ext tst-ext2 tst-fopenloc \
tst-fgetws tst-ungetwc1 tst-ungetwc2 tst-swscanf tst-sscanf \
tst-mmap-setvbuf bug-ungetwc1 bug-ungetwc2 tst-atime tst-eof \
tst-freopen bug-rewind bug-rewind2 bug-ungetc bug-fseek \
diff --git a/libio/tst-ext2.c b/libio/tst-ext2.c
new file mode 100644
index 0000000..ed72efa
--- /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"