[igt-dev] [PATCH i-g-t] tests: close(fd) without igt_fixture considered harmful

Daniel Vetter daniel.vetter at ffwll.ch
Mon Nov 26 10:08:24 UTC 2018


Some tests assume that close on an unopened fd is fine, except it's
not just unopened but actually stack garbage. There's a good chance we
end up running close(0), which wreaks the testcase enumeration. Fix
this.

Not sure there's a better way to catch this than git grep plus lots of
manual auditing ... The unit tests only catch it by accident (x86
works fine, I hit it in one testcase only cross-building to aarch64).

Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
---
 tests/i915/gem_pread_after_blit.c  | 3 ++-
 tests/i915/gem_tiled_fence_blits.c | 3 ++-
 tests/i915/gem_tiled_swapping.c    | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/tests/i915/gem_pread_after_blit.c b/tests/i915/gem_pread_after_blit.c
index 6ef3ca200776..cee9212749d6 100644
--- a/tests/i915/gem_pread_after_blit.c
+++ b/tests/i915/gem_pread_after_blit.c
@@ -248,5 +248,6 @@ igt_main
 		drm_intel_bufmgr_destroy(bufmgr);
 	}
 
-	close(fd);
+	igt_fixture
+		close(fd);
 }
diff --git a/tests/i915/gem_tiled_fence_blits.c b/tests/i915/gem_tiled_fence_blits.c
index c02e35a5fe4c..2453bcc0b271 100644
--- a/tests/i915/gem_tiled_fence_blits.c
+++ b/tests/i915/gem_tiled_fence_blits.c
@@ -230,5 +230,6 @@ igt_main
 		run_test(fd, count);
 	}
 
-	close(fd);
+	igt_fixture
+		close(fd);
 }
diff --git a/tests/i915/gem_tiled_swapping.c b/tests/i915/gem_tiled_swapping.c
index dce668063014..ddf2a748fc84 100644
--- a/tests/i915/gem_tiled_swapping.c
+++ b/tests/i915/gem_tiled_swapping.c
@@ -235,5 +235,6 @@ igt_main
 			thread_fini(&threads[n]);
 	}
 
-	close(fd);
+	igt_fixture
+		close(fd);
 }
-- 
2.19.1



More information about the igt-dev mailing list