diff options
| author | Michael Ellerman <mpe@ellerman.id.au> | 2014-06-10 08:23:08 -0400 |
|---|---|---|
| committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2014-06-11 03:03:49 -0400 |
| commit | de506f73dd40cc1f3ba3312bd454e06f2803335b (patch) | |
| tree | 35e149b0e30b5b7a24a9bf3a3981f29df279f137 | |
| parent | 0a6121cf337d8f5183ef1f8a8bca0734f14f4bb1 (diff) | |
selftests/powerpc: Put the test in a separate process group
Allows us to kill the test and any children it has spawned.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
| -rw-r--r-- | tools/testing/selftests/powerpc/harness.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/tools/testing/selftests/powerpc/harness.c b/tools/testing/selftests/powerpc/harness.c index e80c42a584fe..532ddff8a669 100644 --- a/tools/testing/selftests/powerpc/harness.c +++ b/tools/testing/selftests/powerpc/harness.c | |||
| @@ -30,12 +30,15 @@ int run_test(int (test_function)(void), char *name) | |||
| 30 | 30 | ||
| 31 | pid = fork(); | 31 | pid = fork(); |
| 32 | if (pid == 0) { | 32 | if (pid == 0) { |
| 33 | setpgid(0, 0); | ||
| 33 | exit(test_function()); | 34 | exit(test_function()); |
| 34 | } else if (pid == -1) { | 35 | } else if (pid == -1) { |
| 35 | perror("fork"); | 36 | perror("fork"); |
| 36 | return 1; | 37 | return 1; |
| 37 | } | 38 | } |
| 38 | 39 | ||
| 40 | setpgid(pid, pid); | ||
| 41 | |||
| 39 | /* Wake us up in timeout seconds */ | 42 | /* Wake us up in timeout seconds */ |
| 40 | alarm(TIMEOUT); | 43 | alarm(TIMEOUT); |
| 41 | terminated = false; | 44 | terminated = false; |
| @@ -50,17 +53,20 @@ wait: | |||
| 50 | 53 | ||
| 51 | if (terminated) { | 54 | if (terminated) { |
| 52 | printf("!! force killing %s\n", name); | 55 | printf("!! force killing %s\n", name); |
| 53 | kill(pid, SIGKILL); | 56 | kill(-pid, SIGKILL); |
| 54 | return 1; | 57 | return 1; |
| 55 | } else { | 58 | } else { |
| 56 | printf("!! killing %s\n", name); | 59 | printf("!! killing %s\n", name); |
| 57 | kill(pid, SIGTERM); | 60 | kill(-pid, SIGTERM); |
| 58 | terminated = true; | 61 | terminated = true; |
| 59 | alarm(KILL_TIMEOUT); | 62 | alarm(KILL_TIMEOUT); |
| 60 | goto wait; | 63 | goto wait; |
| 61 | } | 64 | } |
| 62 | } | 65 | } |
| 63 | 66 | ||
| 67 | /* Kill anything else in the process group that is still running */ | ||
| 68 | kill(-pid, SIGTERM); | ||
| 69 | |||
| 64 | if (WIFEXITED(status)) | 70 | if (WIFEXITED(status)) |
| 65 | status = WEXITSTATUS(status); | 71 | status = WEXITSTATUS(status); |
| 66 | else { | 72 | else { |
