diff options
| author | manuel <manuel@mausz.at> | 2012-03-27 11:51:08 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2012-03-27 11:51:08 +0200 |
| commit | 4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b (patch) | |
| tree | 868c52e06f207b5ec8a3cc141f4b8b2bdfcc165c /tests/userprog/multi-recurse.c | |
| parent | eae0bd57f0a26314a94785061888d193d186944a (diff) | |
| download | progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.tar.gz progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.tar.bz2 progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.zip | |
reorganize file structure to match the upstream requirements
Diffstat (limited to 'tests/userprog/multi-recurse.c')
| -rw-r--r-- | tests/userprog/multi-recurse.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/userprog/multi-recurse.c b/tests/userprog/multi-recurse.c new file mode 100644 index 0000000..7172ec3 --- /dev/null +++ b/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 | |||
| 10 | const char *test_name = "multi-recurse"; | ||
| 11 | |||
| 12 | int | ||
| 13 | main (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 | } | ||
