diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-07-02 08:59:32 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-07-02 09:13:20 +0100 |
commit | 4227da8c3cc6417c9d9600bddac938759f01ae03 (patch) | |
tree | 7ea3c9d6f7c4483d394e6655aa8471d0322dfc9c | |
parent | 8908055da6a484058caa92c3c2ba3221cb9ce9d9 (diff) |
gem_stress: Add an option to test handling of signals
As signals cause the syscalls to be interrupted, we often need to clean
up partial state before returning to userspace. Often a source of
unamusing bugs, so encourage gem_stress to provoke them.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | tests/gem_stress.c | 40 | ||||
-rw-r--r-- | tests/gem_stress.h | 1 |
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/gem_stress.c b/tests/gem_stress.c index 3bc538ab..a4a5edf2 100644 --- a/tests/gem_stress.c +++ b/tests/gem_stress.c @@ -51,6 +51,8 @@ #include "gem_stress.h" +#include <signal.h> + #define CMD_POLY_STIPPLE_OFFSET 0x7906 /** TODO: @@ -100,6 +102,29 @@ struct { unsigned max_failed_reads; } stats; +static void signal_helper_process(pid_t pid) +{ + /* Interrupt the parent process at 500Hz, just to be annoying */ + while (1) { + usleep(1000 * 1000 / 500); + if (kill(pid, SIGUSR1)) /* Parent has died, so must we. */ + exit(0); + } +} + +static pid_t fork_signal_helper(void) +{ + pid_t pid; + + pid = fork(); + if (pid == 0) { + signal_helper_process(getppid()); + return -1; + } + + return pid; +} + static void tile2xy(struct scratch_buf *buf, unsigned tile, unsigned *x, unsigned *y) { assert(tile < buf->num_tiles); @@ -651,6 +676,7 @@ static void parse_options(int argc, char **argv) {"no-hw", 0, 0, 'd'}, {"buf-size", 1, 0, 's'}, {"gpu-busy-load", 1, 0, 'g'}, + {"no-signals", 0, 0, 'S'}, {"buffer-count", 1, 0, 'c'}, {"trace-tile", 1, 0, 't'}, {"disable-blt", 0, 0, 'b'}, @@ -671,6 +697,7 @@ static void parse_options(int argc, char **argv) options.scratch_buf_size = 256*4096; options.no_hw = 0; + options.use_signal_helper = 1; options.gpu_busy_load = 0; options.num_buffers = 0; options.trace_tile = -1; @@ -692,6 +719,10 @@ static void parse_options(int argc, char **argv) options.no_hw = 1; printf("no-hw debug mode\n"); break; + case 'S': + options.use_signal_helper = 0; + printf("disabling that pesky nuisance who keeps interrupting us\n"); + break; case 's': tmp = atoi(optarg); if (tmp < options.tile_size*8192) @@ -881,12 +912,18 @@ int main(int argc, char **argv) { int i, j; unsigned *current_permutation, *tmp_permutation; + pid_t signal_helper = -1; drm_fd = drm_open_any(); devid = intel_get_drm_devid(drm_fd); parse_options(argc, argv); + /* start our little helper early before too may allocations occur */ + signal(SIGUSR1, SIG_IGN); + if (options.use_signal_helper) + signal_helper = fork_signal_helper(); + init(); check_render_copyfunc(); @@ -935,5 +972,8 @@ int main(int argc, char **argv) close(drm_fd); + if (signal_helper != -1) + kill(signal_helper, SIGQUIT); + return 0; } diff --git a/tests/gem_stress.h b/tests/gem_stress.h index 759a5296..f44773d6 100644 --- a/tests/gem_stress.h +++ b/tests/gem_stress.h @@ -42,6 +42,7 @@ struct option_struct { int ducttape; int tile_size; int check_render_cpyfn; + int use_signal_helper; }; extern struct option_struct options; |