00001
00002
00003
00004 #include <debug.h>
00005 #include <stdlib.h>
00006 #include <stdio.h>
00007 #include <syscall.h>
00008 #include "tests/lib.h"
00009
00010 const char *test_name = "multi-recurse";
00011
00012 int
00013 main (int argc UNUSED, char *argv[])
00014 {
00015 int n = atoi (argv[1]);
00016
00017 msg ("begin %d", n);
00018 if (n != 0)
00019 {
00020 char child_cmd[128];
00021 pid_t child_pid;
00022 int code;
00023
00024 snprintf (child_cmd, sizeof child_cmd, "multi-recurse %d", n - 1);
00025 CHECK ((child_pid = exec (child_cmd)) != -1, "exec(\"%s\")", child_cmd);
00026
00027 code = wait (child_pid);
00028 if (code != n - 1)
00029 fail ("wait(exec(\"%s\")) returned %d", child_cmd, code);
00030 }
00031
00032 msg ("end %d", n);
00033 return n;
00034 }