00001
00002
00003
00004 #include <random.h>
00005 #include <syscall.h>
00006 #include "tests/filesys/extended/syn-rw.h"
00007 #include "tests/lib.h"
00008 #include "tests/main.h"
00009
00010 char buf[BUF_SIZE];
00011
00012 #define CHILD_CNT 4
00013
00014 void
00015 test_main (void)
00016 {
00017 pid_t children[CHILD_CNT];
00018 size_t ofs;
00019 int fd;
00020
00021 CHECK (create (file_name, 0), "create \"%s\"", file_name);
00022 CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name);
00023
00024 exec_children ("child-syn-rw", children, CHILD_CNT);
00025
00026 random_bytes (buf, sizeof buf);
00027 quiet = true;
00028 for (ofs = 0; ofs < BUF_SIZE; ofs += CHUNK_SIZE)
00029 CHECK (write (fd, buf + ofs, CHUNK_SIZE) > 0,
00030 "write %d bytes at offset %zu in \"%s\"",
00031 (int) CHUNK_SIZE, ofs, file_name);
00032 quiet = false;
00033
00034 wait_children (children, CHILD_CNT);
00035 }