1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
/* Spawns 10 child processes, all of which read from the same
file and make sure that the contents are what they should
be. */
#include <random.h>
#include <stdio.h>
#include <syscall.h>
#include "tests/lib.h"
#include "tests/main.h"
#include "tests/filesys/base/syn-read.h"
static char buf[BUF_SIZE];
#define CHILD_CNT 10
void
test_main (void)
{
pid_t children[CHILD_CNT];
int fd;
CHECK (create (file_name, sizeof buf), "create \"%s\"", file_name);
CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name);
random_bytes (buf, sizeof buf);
CHECK (write (fd, buf, sizeof buf) > 0, "write \"%s\"", file_name);
msg ("close \"%s\"", file_name);
close (fd);
exec_children ("child-syn-read", children, CHILD_CNT);
wait_children (children, CHILD_CNT);
}
|