* libio/tst-eof.c: Rewrite to let test-skeleton.c deal with
	creation and removal of the temp file.
This commit is contained in:
Ulrich Drepper 2002-07-23 00:31:41 +00:00
parent 3fa3d0b25c
commit 97887d3553
2 changed files with 21 additions and 20 deletions

View File

@ -1,5 +1,8 @@
2002-07-22 Ulrich Drepper <drepper@redhat.com> 2002-07-22 Ulrich Drepper <drepper@redhat.com>
* libio/tst-eof.c: Rewrite to let test-skeleton.c deal with
creation and removal of the temp file.
* libio/bug-rewind.c: Use test skeleton. Use create_temp_file for * libio/bug-rewind.c: Use test skeleton. Use create_temp_file for
file creation. file creation.
* test-skeleton.c (create_temp_file): New function. * test-skeleton.c (create_temp_file): New function.

View File

@ -4,36 +4,34 @@
#include <unistd.h> #include <unistd.h>
static void do_prepare (void);
#define PREPARE(argc, argv) do_prepare ()
static int do_test (void); static int do_test (void);
#define TEST_FUNCTION do_test () #define TEST_FUNCTION do_test ()
#include <test-skeleton.c> #include <test-skeleton.c>
int fd;
static void
do_prepare (void)
{
fd = create_temp_file ("tst-eof.", NULL);
if (fd == -1)
{
printf ("cannot create temporary file: %m\n");
exit (1);
}
}
static int static int
do_test (void) do_test (void)
{ {
char *buf; char buf[40];
int fd;
FILE *fp; FILE *fp;
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);
if (fd == -1)
{
printf ("cannot open temporary file: %m\n");
return 1;
}
/* Make sure it gets removed. */
add_temp_file (buf);
if (write (fd, "some string\n", 12) != 12) if (write (fd, "some string\n", 12) != 12)
{ {
printf ("cannot write temporary file: %m\n"); printf ("cannot write temporary file: %m\n");