summaryrefslogtreecommitdiffstats
path: root/pintos-progos/tests/userprog/multi-recurse.c
diff options
context:
space:
mode:
Diffstat (limited to 'pintos-progos/tests/userprog/multi-recurse.c')
-rw-r--r--pintos-progos/tests/userprog/multi-recurse.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/pintos-progos/tests/userprog/multi-recurse.c b/pintos-progos/tests/userprog/multi-recurse.c
new file mode 100644
index 0000000..7172ec3
--- /dev/null
+++ b/pintos-progos/tests/userprog/multi-recurse.c
@@ -0,0 +1,34 @@
1/* Executes itself recursively to the depth indicated by the
2 first command-line argument. */
3
4#include <debug.h>
5#include <stdlib.h>
6#include <stdio.h>
7#include <syscall.h>
8#include "tests/lib.h"
9
10const char *test_name = "multi-recurse";
11
12int
13main (int argc UNUSED, char *argv[])
14{
15 int n = atoi (argv[1]);
16
17 msg ("begin %d", n);
18 if (n != 0)
19 {
20 char child_cmd[128];
21 pid_t child_pid;
22 int code;
23
24 snprintf (child_cmd, sizeof child_cmd, "multi-recurse %d", n - 1);
25 CHECK ((child_pid = exec (child_cmd)) != -1, "exec(\"%s\")", child_cmd);
26
27 code = wait (child_pid);
28 if (code != n - 1)
29 fail ("wait(exec(\"%s\")) returned %d", child_cmd, code);
30 }
31
32 msg ("end %d", n);
33 return n;
34}