From f2775039b1d2f3c24876622e4528604496de8abc Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 26 Sep 2014 10:22:33 +0100 Subject: igt/gem_userptr_blits: Test interruptible create-destroy In order to exercise https://bugs.freedesktop.org/show_bug.cgi?id=84207 we need to interrupt the mmu_notifier_register with a signal. This is likely to be quite difficult, but let's just try running the create-destroy test in an interruptible loop for 5s. Signed-off-by: Chris Wilson --- tests/gem_userptr_blits.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/tests/gem_userptr_blits.c b/tests/gem_userptr_blits.c index 96aee524..638b74c2 100644 --- a/tests/gem_userptr_blits.c +++ b/tests/gem_userptr_blits.c @@ -47,6 +47,7 @@ #include #include #include +#include #include "drm.h" #include "i915_drm.h" @@ -833,19 +834,32 @@ static int test_usage_restrictions(int fd) return 0; } -static int test_create_destroy(int fd) +static int test_create_destroy(int fd, int time) { - void *ptr; - int ret; + struct timespec start, now; uint32_t handle; + void *ptr; + int n; - igt_assert(posix_memalign(&ptr, PAGE_SIZE, PAGE_SIZE) == 0); + igt_fork_signal_helper(); - ret = gem_userptr(fd, ptr, PAGE_SIZE, 0, &handle); - igt_assert(ret == 0); + clock_gettime(CLOCK_MONOTONIC, &start); + do { + for (n = 0; n < 1000; n++) { + igt_assert(posix_memalign(&ptr, PAGE_SIZE, PAGE_SIZE) == 0); - gem_close(fd, handle); - free(ptr); + do_or_die(gem_userptr(fd, ptr, PAGE_SIZE, 0, &handle)); + + gem_close(fd, handle); + free(ptr); + } + + clock_gettime(CLOCK_MONOTONIC, &now); + now.tv_sec -= time; + } while (now.tv_sec < start.tv_sec || + (now.tv_sec == start.tv_sec && now.tv_nsec < start.tv_nsec)); + + igt_stop_signal_helper(); return 0; } @@ -1264,7 +1278,7 @@ int main(int argc, char **argv) gem_userptr_test_unsynchronized(); igt_subtest("create-destroy-unsync") - test_create_destroy(fd); + test_create_destroy(fd, 5); igt_subtest("unsync-overlap") test_overlap(fd, 0); @@ -1355,7 +1369,7 @@ int main(int argc, char **argv) test_process_exit(fd, PE_GTT_MAP | PE_BUSY); igt_subtest("create-destroy-sync") - test_create_destroy(fd); + test_create_destroy(fd, 5); igt_subtest("sync-overlap") test_overlap(fd, EINVAL); -- cgit v1.2.3