about summary refs log tree commit diff
path: root/REORG.TODO/libio/tst-memstream1.c
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2017-06-08 15:39:03 -0400
committerZack Weinberg <zackw@panix.com>2017-06-08 15:39:03 -0400
commit5046dbb4a7eba5eccfd258f92f4735c9ffc8d069 (patch)
tree4470480d904b65cf14ca524f96f79eca818c3eaf /REORG.TODO/libio/tst-memstream1.c
parent199fc19d3aaaf57944ef036e15904febe877fc93 (diff)
downloadglibc-5046dbb4a7eba5eccfd258f92f4735c9ffc8d069.tar.gz
glibc-5046dbb4a7eba5eccfd258f92f4735c9ffc8d069.tar.xz
glibc-5046dbb4a7eba5eccfd258f92f4735c9ffc8d069.zip
Prepare for radical source tree reorganization. zack/build-layout-experiment
All top-level files and directories are moved into a temporary storage
directory, REORG.TODO, except for files that will certainly still
exist in their current form at top level when we're done (COPYING,
COPYING.LIB, LICENSES, NEWS, README), all old ChangeLog files (which
are moved to the new directory OldChangeLogs, instead), and the
generated file INSTALL (which is just deleted; in the new order, there
will be no generated files checked into version control).
Diffstat (limited to 'REORG.TODO/libio/tst-memstream1.c')
-rw-r--r--REORG.TODO/libio/tst-memstream1.c90
1 files changed, 90 insertions, 0 deletions
diff --git a/REORG.TODO/libio/tst-memstream1.c b/REORG.TODO/libio/tst-memstream1.c
new file mode 100644
index 0000000000..adc2aec257
--- /dev/null
+++ b/REORG.TODO/libio/tst-memstream1.c
@@ -0,0 +1,90 @@
+#include <mcheck.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+#ifndef CHAR_T
+# define CHAR_T char
+# define W(o) o
+# define OPEN_MEMSTREAM open_memstream
+#endif
+
+#define S(s) S1 (s)
+#define S1(s) #s
+
+
+static void
+mcheck_abort (enum mcheck_status ev)
+{
+  printf ("mecheck failed with status %d\n", (int) ev);
+  exit (1);
+}
+
+
+static int
+do_test (void)
+{
+  mcheck_pedantic (mcheck_abort);
+
+  CHAR_T *buf = (CHAR_T *) 1l;
+  size_t len = 12345;
+  FILE *fp = OPEN_MEMSTREAM (&buf, &len);
+  if (fp == NULL)
+    {
+      printf ("%s failed\n", S(OPEN_MEMSTREAM));
+      return 1;
+    }
+
+  if (fflush (fp) != 0)
+    {
+      puts ("fflush failed");
+      return 1;
+    }
+
+  if (len != 0)
+    {
+      puts ("string after no write not empty");
+      return 1;
+    }
+  if (buf == (CHAR_T *) 1l)
+    {
+      puts ("buf not updated");
+      return 1;
+    }
+  if (buf[0] != W('\0'))
+    {
+      puts ("buf[0] != 0");
+      return 1;
+    }
+
+  buf = (CHAR_T *) 1l;
+  len = 12345;
+  if (fclose (fp) != 0)
+    {
+      puts ("fclose failed");
+      return 1;
+    }
+
+  if (len != 0)
+    {
+      puts ("string after close with no write not empty");
+      return 1;
+    }
+  if (buf == (CHAR_T *) 1l)
+    {
+      puts ("buf not updated");
+      return 1;
+    }
+  if (buf[0] != W('\0'))
+    {
+      puts ("buf[0] != 0");
+      return 1;
+    }
+
+  free (buf);
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"