00001
00002
00003
00004
00005
00006
00007 #include <random.h>
00008 #include <stdio.h>
00009 #include <stdlib.h>
00010 #include <syscall.h>
00011 #include "tests/lib.h"
00012 #include "tests/filesys/base/syn-read.h"
00013
00014 const char *test_name = "child-syn-read";
00015
00016 static char buf[BUF_SIZE];
00017
00018 int
00019 main (int argc, const char *argv[])
00020 {
00021 int child_idx;
00022 int fd;
00023 size_t i;
00024
00025 quiet = true;
00026
00027 CHECK (argc == 2, "argc must be 2, actually %d", argc);
00028 child_idx = atoi (argv[1]);
00029
00030 random_init (0);
00031 random_bytes (buf, sizeof buf);
00032
00033 CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name);
00034 for (i = 0; i < sizeof buf; i++)
00035 {
00036 char c;
00037 CHECK (read (fd, &c, 1) > 0, "read \"%s\"", file_name);
00038 compare_bytes (&c, buf + i, 1, i, file_name);
00039 }
00040 close (fd);
00041
00042 return child_idx;
00043 }
00044