[T106][ZXW-22]7520V3SCV2.01.01.02P42U09_VEC_V0.8_AP_VEC origin source commit
Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/ap/libc/glibc/glibc-2.22/libio/tst-ext2.c b/ap/libc/glibc/glibc-2.22/libio/tst-ext2.c
new file mode 100644
index 0000000..ed72efa
--- /dev/null
+++ b/ap/libc/glibc/glibc-2.22/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"