diff options
Diffstat (limited to 'tests/filesys/base/child-syn-wrt.c')
| -rw-r--r-- | tests/filesys/base/child-syn-wrt.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/filesys/base/child-syn-wrt.c b/tests/filesys/base/child-syn-wrt.c new file mode 100644 index 0000000..1b52584 --- /dev/null +++ b/tests/filesys/base/child-syn-wrt.c | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | /* Child process for syn-read test. | ||
| 2 | Writes into part of a test file. Other processes will be | ||
| 3 | writing into other parts at the same time. */ | ||
| 4 | |||
| 5 | #include <random.h> | ||
| 6 | #include <stdlib.h> | ||
| 7 | #include <syscall.h> | ||
| 8 | #include "tests/lib.h" | ||
| 9 | #include "tests/filesys/base/syn-write.h" | ||
| 10 | |||
| 11 | char buf[BUF_SIZE]; | ||
| 12 | |||
| 13 | int | ||
| 14 | main (int argc, char *argv[]) | ||
| 15 | { | ||
| 16 | int child_idx; | ||
| 17 | int fd; | ||
| 18 | |||
| 19 | quiet = true; | ||
| 20 | |||
| 21 | CHECK (argc == 2, "argc must be 2, actually %d", argc); | ||
| 22 | child_idx = atoi (argv[1]); | ||
| 23 | |||
| 24 | random_init (0); | ||
| 25 | random_bytes (buf, sizeof buf); | ||
| 26 | |||
| 27 | CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name); | ||
| 28 | seek (fd, CHUNK_SIZE * child_idx); | ||
| 29 | CHECK (write (fd, buf + CHUNK_SIZE * child_idx, CHUNK_SIZE) > 0, | ||
| 30 | "write \"%s\"", file_name); | ||
| 31 | msg ("close \"%s\"", file_name); | ||
| 32 | close (fd); | ||
| 33 | |||
| 34 | return child_idx; | ||
| 35 | } | ||
