+2010-04-19 Roland McGrath <roland@redhat.com>
+
+ * stdio-common/tst-fmemopen.c (TEST_FILE): Macro removed.
+ (main): Take arguments. Construct test file name from ARGV[0].
+
2010-04-15 H.J. Lu <hongjiu.lu@intel.com>
* string/test-strncmp.c (check_result): New function.
#include <sys/stat.h>
#include <sys/types.h>
-#define TEST_FILE "test-1"
-
int
-main (void)
+main (int argc, char **argv)
{
+ const char *test_file;
const char blah[] = "BLAH";
FILE *fp;
char *mmap_data;
struct stat fs;
const char *cp;
+ /* Construct the test file name based on ARGV[0], which will be
+ an absolute file name in the build directory. Don't touch the
+ source directory, which might be read-only. */
+ if (argc != 1 || asprintf (&test_file, "%s.test", argv[0]) < 0)
+ exit (99);
+
/* setup the physical file, and use it */
- if ((fp = fopen (TEST_FILE, "w+")) == NULL)
+ if ((fp = fopen (test_file, "w+")) == NULL)
exit (1);
if (fwrite (blah, 1, strlen (blah), fp) != strlen (blah))
exit (2);
fclose (fp);
/* Now, mmap the file into a buffer, and do that too */
- if ((fd = open (TEST_FILE, O_RDONLY)) == -1)
+ if ((fd = open (test_file, O_RDONLY)) == -1)
exit (3);
if (fstat (fd, &fs) == -1)
exit (4);
munmap (mmap_data, fs.st_size);
- unlink (TEST_FILE);
+ unlink (test_file);
+ free (test_file);
return 0;
}