provided code
This commit is contained in:
33
src/tests/userprog/rox-child.inc
Normal file
33
src/tests/userprog/rox-child.inc
Normal file
@@ -0,0 +1,33 @@
|
||||
/* -*- 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\"");
|
||||
}
|
||||
Reference in New Issue
Block a user