tests/gem_suspend: test debugfs/sysfs reads while s/r
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 10 Oct 2013 12:20:43 +0000 (14:20 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 10 Oct 2013 12:20:43 +0000 (14:20 +0200)
Just a very quick hack cobbled together with /bin/sh and exec. We
can't use system since that does stupid things with singals ... Still
we need to whack the child process pretty hard to get rid of it.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
lib/drmtest.c
lib/drmtest.h
tests/gem_suspend.c

index 3cec956..2660af7 100644 (file)
@@ -1080,7 +1080,8 @@ void igt_stop_helper(struct igt_helper_process *proc)
 
        assert(proc->running);
 
-       assert(kill(proc->pid, SIGQUIT) == 0);
+       assert(kill(proc->pid,
+                   proc->use_SIGKILL ? SIGKILL : SIGQUIT) == 0);
        while (waitpid(proc->pid, &status, 0) == -1 &&
               errno == -EINTR)
                ;
index dac12fa..ff2827d 100644 (file)
@@ -243,6 +243,7 @@ void igt_waitchildren(void);
 
 struct igt_helper_process {
        bool running;
+       bool use_SIGKILL;
        pid_t pid;
        int id;
 };
index eea4cfc..c0f71ae 100644 (file)
@@ -95,6 +95,56 @@ test_fence_restore(int fd, bool tiled2untiled)
        munmap(ptr_tiled, OBJECT_SIZE);
 }
 
+static void
+test_debugfs_reader(void)
+{
+       struct igt_helper_process reader = {};
+       reader.use_SIGKILL = true;
+
+       igt_fork_helper(&reader) {
+               static const char dfs_base[] = "/sys/kernel/debug/dri";
+               static char tmp[1024];
+
+               snprintf(tmp, sizeof(tmp) - 1,
+                        "while true; do find %s/%i/ -type f | xargs cat &> /dev/null; done",
+                        dfs_base, drm_get_card());
+               assert(execl("/bin/sh", "sh", "-c", tmp, (char *) NULL) != -1);
+       }
+
+       sleep(1);
+
+       igt_system_suspend_autoresume();
+
+       sleep(1);
+
+       igt_stop_helper(&reader);
+}
+
+static void
+test_sysfs_reader(void)
+{
+       struct igt_helper_process reader = {};
+       reader.use_SIGKILL = true;
+
+       igt_fork_helper(&reader) {
+               static const char dfs_base[] = "/sys/class/drm/card";
+               static char tmp[1024];
+
+               snprintf(tmp, sizeof(tmp) - 1,
+                        "while true; do find %s%i*/ -type f | xargs cat &> /dev/null; done",
+                        dfs_base, drm_get_card());
+               assert(execl("/bin/sh", "sh", "-c", tmp, (char *) NULL) != -1);
+       }
+
+       sleep(1);
+
+       igt_system_suspend_autoresume();
+
+       sleep(1);
+
+       igt_stop_helper(&reader);
+}
+
 int fd;
 
 int main(int argc, char **argv)
@@ -110,6 +160,12 @@ int main(int argc, char **argv)
        igt_subtest("fence-restore-untiled")
                test_fence_restore(fd, false);
 
+       igt_subtest("debugfs-reader")
+               test_debugfs_reader();
+
+       igt_subtest("sysfs-reader")
+               test_sysfs_reader();
+
        igt_fixture
                close(fd);