Setup LOCPATH for tst-ftell-active-handler and tst-ftell-partial-wide in libio
[platform/upstream/glibc.git] / libio / tst-eof.c
index 627eaf8..6baa122 100644 (file)
@@ -4,37 +4,33 @@
 #include <unistd.h>
 
 
+static void do_prepare (void);
+#define PREPARE(argc, argv) do_prepare ()
 static int do_test (void);
 #define TEST_FUNCTION do_test ()
 #include <test-skeleton.c>
 
 
-static int
-do_test (void)
-{
-  char *buf;
-  int fd;
-  FILE *fp;
-  int ch;
-  char tm[20];
+int fd;
 
-  buf = (char *) malloc (strlen (test_dir) + sizeof "/tst-eof.XXXXXX");
-  if (buf == NULL)
-    {
-      printf ("cannot allocate memory: %m\n");
-      return 1;
-    }
-  stpcpy (stpcpy (buf, test_dir), "/tst-eof.XXXXXX");
 
-  fd = mkstemp (buf);
+static void
+do_prepare (void)
+{
+  fd = create_temp_file ("tst-eof.", NULL);
   if (fd == -1)
     {
-      printf ("cannot open temporary file: %m\n");
-      return 1;
+      printf ("cannot create temporary file: %m\n");
+      exit (1);
     }
+}
 
-  /* Make sure it gets removed.  */
-  add_temp_file (buf);
+
+static int
+do_test (void)
+{
+  char buf[40];
+  FILE *fp;
 
   if (write (fd, "some string\n", 12) != 12)
     {