diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-07-02 11:24:57 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-07-02 11:29:26 +0100 |
commit | ae452e327aa8dab739ca521e924a9ac9fcc506cf (patch) | |
tree | 89c95003b5cd841db64bf422b14ce6fa944cdfe4 | |
parent | faf2a0223cb8655e7ac826592b50ad4e08ec04ee (diff) |
tests/gem_(linear|tiled)_blits: Repeat whilst being interrupted
Since these two tests exercise a working set larger than aperture, they
require stalls which are prone to being interrupted - so interrupt them
and check that everything still works.
-rw-r--r-- | tests/gem_linear_blits.c | 60 | ||||
-rw-r--r-- | tests/gem_tiled_blits.c | 73 |
2 files changed, 80 insertions, 53 deletions
diff --git a/tests/gem_linear_blits.c b/tests/gem_linear_blits.c index ec2dc56d..4a6e5064 100644 --- a/tests/gem_linear_blits.c +++ b/tests/gem_linear_blits.c @@ -176,30 +176,11 @@ check_bo(int fd, uint32_t handle, uint32_t val) } } -int main(int argc, char **argv) +static void run_test(int fd, int count) { uint32_t *handle, *start_val; uint32_t start = 0; - int i, fd, count; - - fd = drm_open_any(); - - count = 0; - if (argc > 1) - count = atoi(argv[1]); - if (count == 0) - count = 3 * gem_aperture_size(fd) / (1024*1024) / 2; - else if (count < 2) { - fprintf(stderr, "count must be >= 2\n"); - return 1; - } - - if (count > intel_get_total_ram_mb() * 9 / 10) { - count = intel_get_total_ram_mb() * 9 / 10; - printf("not enough RAM to run test, reducing buffer count\n"); - } - - printf("Using %d 1MiB buffers\n", count); + int i; handle = malloc(sizeof(uint32_t)*count*2); start_val = handle + count; @@ -247,8 +228,43 @@ int main(int argc, char **argv) copy(fd, handle[dst], handle[src]); start_val[dst] = start_val[src]; } - for (i = 0; i < count; i++) + for (i = 0; i < count; i++) { check_bo(fd, handle[i], start_val[i]); + gem_close(fd, handle[i]); + } + + free(handle); +} + +int main(int argc, char **argv) +{ + int fd, count; + + fd = drm_open_any(); + + count = 0; + if (argc > 1) + count = atoi(argv[1]); + if (count == 0) + count = 3 * gem_aperture_size(fd) / (1024*1024) / 2; + else if (count < 2) { + fprintf(stderr, "count must be >= 2\n"); + return 1; + } + + if (count > intel_get_total_ram_mb() * 9 / 10) { + count = intel_get_total_ram_mb() * 9 / 10; + printf("not enough RAM to run test, reducing buffer count\n"); + } + + printf("Using %d 1MiB buffers\n", count); + + run_test(fd, count); + + /* and repeat under the rude interrupter */ + drmtest_fork_signal_helper(); + run_test(fd, count); + drmtest_stop_signal_helper(); return 0; } diff --git a/tests/gem_tiled_blits.c b/tests/gem_tiled_blits.c index bb439760..34b96fdc 100644 --- a/tests/gem_tiled_blits.c +++ b/tests/gem_tiled_blits.c @@ -117,41 +117,16 @@ check_bo(drm_intel_bo *bo, uint32_t start_val) drm_intel_bo_unreference(linear_bo); } -int main(int argc, char **argv) +static void run_test(int count) { drm_intel_bo **bo; uint32_t *bo_start_val; uint32_t start = 0; - int i, fd, count; - - fd = drm_open_any(); - - count = 0; - if (argc > 1) - count = atoi(argv[1]); - if (count == 0) { - count = 3 * gem_aperture_size(fd) / (1024*1024) / 2; - count += (count & 1) == 0; - } else if (count < 2) { - fprintf(stderr, "count must be >= 2\n"); - return 1; - } - - if (count > intel_get_total_ram_mb() * 9 / 10) { - count = intel_get_total_ram_mb() * 9 / 10; - printf("not enough RAM to run test, reducing buffer count\n"); - } - - printf("Using %d 1MiB buffers\n", count); + int i; bo = malloc(sizeof(drm_intel_bo *)*count); bo_start_val = malloc(sizeof(uint32_t)*count); - bufmgr = drm_intel_bufmgr_gem_init(fd, 4096); - drm_intel_bufmgr_gem_enable_reuse(bufmgr); - drm_intel_bufmgr_gem_set_vma_cache_size(bufmgr, 32); - batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd)); - for (i = 0; i < count; i++) { bo[i] = create_bo(start); bo_start_val[i] = start; @@ -200,14 +175,50 @@ int main(int argc, char **argv) intel_copy_bo(batch, bo[dst], bo[src], width, height); bo_start_val[dst] = bo_start_val[src]; } - for (i = 0; i < count; i++) - check_bo(bo[i], bo_start_val[i]); - for (i = 0; i < count; i++) { + check_bo(bo[i], bo_start_val[i]); drm_intel_bo_unreference(bo[i]); - bo[i] = NULL; } + free(bo); +} + +int main(int argc, char **argv) +{ + int fd, count; + + fd = drm_open_any(); + + count = 0; + if (argc > 1) + count = atoi(argv[1]); + if (count == 0) { + count = 3 * gem_aperture_size(fd) / (1024*1024) / 2; + count += (count & 1) == 0; + } else if (count < 2) { + fprintf(stderr, "count must be >= 2\n"); + return 1; + } + + if (count > intel_get_total_ram_mb() * 9 / 10) { + count = intel_get_total_ram_mb() * 9 / 10; + printf("not enough RAM to run test, reducing buffer count\n"); + } + + printf("Using %d 1MiB buffers\n", count); + + bufmgr = drm_intel_bufmgr_gem_init(fd, 4096); + drm_intel_bufmgr_gem_enable_reuse(bufmgr); + drm_intel_bufmgr_gem_set_vma_cache_size(bufmgr, 32); + batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd)); + + run_test(count); + + /* and again whilst being rudely interrupted */ + drmtest_fork_signal_helper(); + run_test(count); + drmtest_stop_signal_helper(); + intel_batchbuffer_free(batch); drm_intel_bufmgr_destroy(bufmgr); |