This repository has been archived on 2021-05-26. You can view files and clone it, but cannot push or open issues or pull requests.
OS/pintos-env/pintos/tests/filesys/base/syn-read.c

32 lines
785 B
C
Raw Permalink Normal View History

/* 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);
}