00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <random.h>
00011 #include <stdlib.h>
00012 #include <syscall.h>
00013 #include "tests/filesys/extended/syn-rw.h"
00014 #include "tests/lib.h"
00015
00016 const char *test_name = "child-syn-rw";
00017
00018 static char buf1[BUF_SIZE];
00019 static char buf2[BUF_SIZE];
00020
00021 int
00022 main (int argc, const char *argv[])
00023 {
00024 int child_idx;
00025 int fd;
00026 size_t ofs;
00027
00028 quiet = true;
00029
00030 CHECK (argc == 2, "argc must be 2, actually %d", argc);
00031 child_idx = atoi (argv[1]);
00032
00033 random_init (0);
00034 random_bytes (buf1, sizeof buf1);
00035
00036 CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name);
00037 ofs = 0;
00038 while (ofs < sizeof buf2)
00039 {
00040 int bytes_read = read (fd, buf2 + ofs, sizeof buf2 - ofs);
00041 CHECK (bytes_read >= -1 && bytes_read <= (int) (sizeof buf2 - ofs),
00042 "%zu-byte read on \"%s\" returned invalid value of %d",
00043 sizeof buf2 - ofs, file_name, bytes_read);
00044 if (bytes_read > 0)
00045 {
00046 compare_bytes (buf2 + ofs, buf1 + ofs, bytes_read, ofs, file_name);
00047 ofs += bytes_read;
00048 }
00049 }
00050 close (fd);
00051
00052 return child_idx;
00053 }