Make tests public. Rewrite most tests. Add tests.
[pintos-anon] / src / tests / userprog / multi-recurse.c
1 #include <debug.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include <syscall.h>
5 #include "tests/lib.h"
6
7 const char *test_name = "multi-recurse";
8
9 int
10 main (int argc UNUSED, char *argv[]) 
11 {
12   int n = atoi (argv[1]);
13   if (n == 0)
14     n = atoi (argv[0]);
15
16   msg ("begin %d", n);
17   if (n != 0) 
18     {
19       char child_cmd[128];
20       pid_t child_pid;
21       int code;
22       
23       snprintf (child_cmd, sizeof child_cmd, "multi-recurse %d", n - 1);
24       CHECK ((child_pid = exec (child_cmd)) != -1, "exec(\"%s\")", child_cmd);
25
26       code = wait (child_pid);
27       if (code != n - 1)
28         fail ("wait(exec(\"%s\")) returned %d", child_cmd, code);
29     }
30   
31   msg ("end %d", n);
32   return n;
33 }