12 main (int argc, char **argv)
15 const char blah[] = "BLAH";
22 /* Construct the test file name based on ARGV[0], which will be
23 an absolute file name in the build directory. Don't touch the
24 source directory, which might be read-only. */
25 if (argc != 1 || asprintf (&test_file, "%s.test", argv[0]) < 0)
28 /* setup the physical file, and use it */
29 if ((fp = fopen (test_file, "w+")) == NULL)
31 if (fwrite (blah, 1, strlen (blah), fp) != strlen (blah))
37 while ((ch = getc (fp)) != EOF)
42 printf ("\ncharacter %td: '%c' instead of '%c'\n",
63 /* Now, mmap the file into a buffer, and do that too */
64 if ((fd = open (test_file, O_RDONLY)) == -1)
66 if (fstat (fd, &fs) == -1)
69 if ((mmap_data = (char *) mmap (NULL, fs.st_size, PROT_READ,
70 MAP_SHARED, fd, 0)) == MAP_FAILED)
77 if ((fp = fmemopen (mmap_data, fs.st_size, "r")) == NULL)
82 while ((ch = getc (fp)) != EOF)
87 printf ("%td character: '%c' instead of '%c'\n",
102 printf ("fp: EOF\n");
111 munmap (mmap_data, fs.st_size);