provided code

This commit is contained in:
LabTS
2024-10-01 23:37:39 +01:00
commit 8724a2641e
697 changed files with 74252 additions and 0 deletions

View 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\"");
}