00001
00002
00003
00004
00005
00006
00007 #include <ctype.h>
00008 #include <stdio.h>
00009 #include <stdlib.h>
00010 #include <syscall.h>
00011 #include "tests/lib.h"
00012
00013 const char *test_name = "child-rox";
00014
00015 static void
00016 try_write (void)
00017 {
00018 int handle;
00019 char buffer[19];
00020
00021 quiet = true;
00022 CHECK ((handle = open ("child-rox")) > 1, "open \"child-rox\"");
00023 quiet = false;
00024
00025 CHECK (write (handle, buffer, sizeof buffer) == 0,
00026 "try to write \"child-rox\"");
00027
00028 close (handle);
00029 }
00030
00031 int
00032 main (int argc UNUSED, char *argv[])
00033 {
00034 msg ("begin");
00035 try_write ();
00036
00037 if (!isdigit (*argv[1]))
00038 fail ("bad command-line arguments");
00039 if (atoi (argv[1]) > 1)
00040 {
00041 char cmd[128];
00042 int child;
00043
00044 snprintf (cmd, sizeof cmd, "child-rox %d", atoi (argv[1]) - 1);
00045 CHECK ((child = exec (cmd)) != -1, "exec \"%s\"", cmd);
00046 quiet = true;
00047 CHECK (wait (child) == 12, "wait for \"child-rox\"");
00048 quiet = false;
00049 }
00050
00051 try_write ();
00052 msg ("end");
00053
00054 return 12;
00055 }