[Intel-gfx] [PATCH i-g-t 1/3] lib: igt_fork_hang_helper must be run in fixtures
Daniel Vetter
daniel.vetter at ffwll.ch
Wed Dec 2 22:45:34 PST 2015
Because it opens an intel-specific drm fd. Fixes crashes when running
igt on no-intel.
Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
---
lib/igt_gt.c | 23 ++++++-----------------
lib/igt_gt.h | 2 +-
tests/gem_evict_alignment.c | 26 +++++++++++++-------------
tests/gem_evict_everything.c | 36 ++++++++++++++++++------------------
4 files changed, 38 insertions(+), 49 deletions(-)
diff --git a/lib/igt_gt.c b/lib/igt_gt.c
index 69cf3654f207..688ea5e6de38 100644
--- a/lib/igt_gt.c
+++ b/lib/igt_gt.c
@@ -190,31 +190,22 @@ hang_helper_process(pid_t pid, int fd)
* This is useful to exercise slow running code (such as aperture placement)
* which needs to be robust against a GPU reset.
*
- * In tests with subtests this function can be called outside of failure
- * catching code blocks like #igt_fixture or #igt_subtest.
+ * This function automatically skips when test requirements aren't met using
+ * igt_skip().
*/
-int igt_fork_hang_helper(void)
+void igt_fork_hang_helper(void)
{
int fd, gen;
- if (igt_only_list_subtests())
- return 1;
-
fd = drm_open_driver(DRIVER_INTEL);
- if (fd == -1)
- return 0;
gen = intel_gen(intel_get_drm_devid(fd));
- if (gen < 5) {
- close(fd);
- return 0;
- }
+ igt_skip_on(gen < 5);
igt_fork_helper(&hang_helper)
hang_helper_process(getppid(), fd);
close(fd);
- return 1;
}
/**
@@ -227,10 +218,8 @@ int igt_fork_hang_helper(void)
*/
void igt_stop_hang_helper(void)
{
- if (igt_only_list_subtests())
- return;
-
- igt_stop_helper(&hang_helper);
+ if (hang_helper.running)
+ igt_stop_helper(&hang_helper);
}
/**
diff --git a/lib/igt_gt.h b/lib/igt_gt.h
index 510542339c44..b70bbd155a35 100644
--- a/lib/igt_gt.h
+++ b/lib/igt_gt.h
@@ -36,7 +36,7 @@ typedef struct igt_hang_ring {
struct igt_hang_ring igt_hang_ring(int fd, int ring);
void igt_post_hang_ring(int fd, struct igt_hang_ring arg);
-int igt_fork_hang_helper(void);
+void igt_fork_hang_helper(void);
void igt_stop_hang_helper(void);
int igt_open_forcewake_handle(void);
diff --git a/tests/gem_evict_alignment.c b/tests/gem_evict_alignment.c
index 2c0d261df0d0..14b861628516 100644
--- a/tests/gem_evict_alignment.c
+++ b/tests/gem_evict_alignment.c
@@ -220,22 +220,22 @@ igt_main
major_evictions(fd, size, count);
}
- if (igt_fork_hang_helper()) {
- igt_subtest("minor-hang") {
- size = 1024 * 1024;
- count = 3*gem_aperture_size(fd) / size / 4;
- minor_evictions(fd, size, count);
- }
+ igt_subtest("minor-hang") {
+ igt_fork_hang_helper();
+ size = 1024 * 1024;
+ count = 3*gem_aperture_size(fd) / size / 4;
+ minor_evictions(fd, size, count);
+ }
- igt_subtest("major-hang") {
- size = 3*gem_aperture_size(fd) / 4;
- count = 4;
- major_evictions(fd, size, count);
- }
- igt_stop_hang_helper();
+ igt_subtest("major-hang") {
+ size = 3*gem_aperture_size(fd) / 4;
+ count = 4;
+ major_evictions(fd, size, count);
}
igt_stop_signal_helper();
- igt_fixture
+ igt_fixture {
+ igt_stop_hang_helper();
close(fd);
+ }
}
diff --git a/tests/gem_evict_everything.c b/tests/gem_evict_everything.c
index ebf59f9090e4..db6c333b1915 100644
--- a/tests/gem_evict_everything.c
+++ b/tests/gem_evict_everything.c
@@ -243,32 +243,32 @@ igt_main
test_major_evictions(fd, size, count);
}
- if (igt_fork_hang_helper()) {
- igt_fixture {
- size = 1024 * 1024;
- count = 3*gem_aperture_size(fd) / size / 4;
- }
+ igt_fixture {
+ igt_fork_hang_helper();
- igt_subtest("mlocked-hang")
- test_mlocked_evictions(fd, size, count);
+ size = 1024 * 1024;
+ count = 3*gem_aperture_size(fd) / size / 4;
+ }
- igt_subtest("swapping-hang")
- test_swapping_evictions(fd, size, count);
+ igt_subtest("mlocked-hang")
+ test_mlocked_evictions(fd, size, count);
- igt_subtest("minor-hang")
- test_minor_evictions(fd, size, count);
+ igt_subtest("swapping-hang")
+ test_swapping_evictions(fd, size, count);
- igt_subtest("major-hang") {
- size = 3*gem_aperture_size(fd) / 4;
- count = 4;
- test_major_evictions(fd, size, count);
- }
+ igt_subtest("minor-hang")
+ test_minor_evictions(fd, size, count);
- igt_stop_hang_helper();
+ igt_subtest("major-hang") {
+ size = 3*gem_aperture_size(fd) / 4;
+ count = 4;
+ test_major_evictions(fd, size, count);
}
- igt_stop_signal_helper();
+
+ igt_stop_hang_helper();
igt_fixture {
+ igt_stop_signal_helper();
close(fd);
}
}
--
2.5.1
More information about the Intel-gfx
mailing list