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/userprog/rox-child.inc

34 lines
919 B
PHP
Raw Normal View History

/* -*- c -*- */
#include <syscall.h>
#include "tests/lib.h"
#include "tests/main.h"
void
test_main (void)
{
const char *child_cmd = "child-rox " CHILD_CNT;
int handle;
pid_t child;
char buffer[16];
/* Open child-rox, read from it, write back same data. */
CHECK ((handle = open ("child-rox")) > 1, "open \"child-rox\"");
CHECK (read (handle, buffer, sizeof buffer) == (int) sizeof buffer,
"read \"child-rox\"");
seek (handle, 0);
CHECK (write (handle, buffer, sizeof buffer) == (int) sizeof buffer,
"write \"child-rox\"");
/* Execute child-rox and wait for it. */
CHECK ((child = exec (child_cmd)) != -1, "exec \"%s\"", child_cmd);
quiet = true;
CHECK (wait (child) == 12, "wait for child");
quiet = false;
/* Write to child-rox again. */
seek (handle, 0);
CHECK (write (handle, buffer, sizeof buffer) == (int) sizeof buffer,
"write \"child-rox\"");
}