[PATCH i-g-t 2/2] tests: Close device before exit

Mauro Carvalho Chehab mauro.chehab at linux.intel.com
Tue Sep 6 09:59:46 UTC 2022


From: Chris Wilson <chris.p.wilson at intel.com>

Close the device fd before we check for leaks during the atexit
handlers.

Signed-off-by: Chris Wilson <chris.p.wilson at intel.com>
Reviewed-by: Andrzej Hajda <andrzej.hajda at intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab at kernel.org>
---
 tests/core_auth.c                       |  8 +++++---
 tests/drm_import_export.c               |  5 +++++
 tests/drm_read.c                        |  4 +++-
 tests/dumb_buffer.c                     |  4 ++++
 tests/feature_discovery.c               |  5 +++--
 tests/i915/gem_basic.c                  |  8 +++++---
 tests/i915/gem_blits.c                  |  1 +
 tests/i915/gem_close.c                  |  3 ++-
 tests/i915/gem_create.c                 |  3 ++-
 tests/i915/gem_ctx_engines.c            |  3 ++-
 tests/i915/gem_ctx_isolation.c          |  3 ++-
 tests/i915/gem_ctx_shared.c             |  3 ++-
 tests/i915/gem_exec_alignment.c         |  3 ++-
 tests/i915/gem_exec_balancer.c          |  3 ++-
 tests/i915/gem_exec_endless.c           |  3 ++-
 tests/i915/gem_flink_basic.c            | 11 ++++++++---
 tests/i915/gem_linear_blits.c           |  3 ++-
 tests/i915/gem_media_fill.c             |  1 +
 tests/i915/gem_render_copy.c            |  1 +
 tests/i915/gem_render_copy_redux.c      |  4 ++++
 tests/i915/gem_request_retire.c         |  5 +++--
 tests/i915/gem_unfence_active_buffers.c |  1 +
 tests/i915/gem_unref_active_buffers.c   |  1 +
 tests/i915/gem_userptr_blits.c          |  4 +++-
 tests/i915/gem_workarounds.c            |  3 ++-
 tests/i915/i915_pciid.c                 |  2 ++
 tests/i915/i915_pm_dc.c                 |  1 +
 tests/i915/kms_big_fb.c                 |  1 +
 tests/i915/kms_big_joiner.c             |  1 +
 tests/i915/kms_busy.c                   |  1 +
 tests/i915/kms_ccs.c                    |  4 +++-
 tests/i915/kms_cdclk.c                  |  1 +
 tests/i915/kms_fence_pin_leak.c         |  1 +
 tests/i915/kms_flip_scaled_crc.c        |  1 +
 tests/i915/kms_flip_tiling.c            |  1 +
 tests/i915/kms_mmap_write_crc.c         |  1 +
 tests/i915/kms_pipe_b_c_ivb.c           |  1 +
 tests/i915/kms_psr.c                    |  1 +
 tests/i915/kms_psr2_sf.c                |  1 +
 tests/i915/kms_psr2_su.c                |  1 +
 tests/i915/kms_pwrite_crc.c             |  1 +
 tests/kms_3d.c                          |  1 +
 tests/kms_atomic.c                      |  1 +
 tests/kms_atomic_interruptible.c        |  1 +
 tests/kms_atomic_transition.c           |  1 +
 tests/kms_color.c                       |  1 +
 tests/kms_content_protection.c          |  1 +
 tests/kms_cursor_crc.c                  |  1 +
 tests/kms_cursor_edge_walk.c            |  4 +++-
 tests/kms_cursor_legacy.c               |  1 +
 tests/kms_dither.c                      |  1 +
 tests/kms_dp_aux_dev.c                  |  1 +
 tests/kms_flip.c                        |  3 +++
 tests/kms_flip_event_leak.c             |  1 +
 tests/kms_force_connector_basic.c       |  7 ++++++-
 tests/kms_hdmi_inject.c                 |  1 +
 tests/kms_hdr.c                         |  1 +
 tests/kms_invalid_mode.c                |  1 +
 tests/kms_lease.c                       |  4 ++++
 tests/kms_panel_fitting.c               |  4 +++-
 tests/kms_pipe_crc_basic.c              |  1 +
 tests/kms_plane.c                       |  1 +
 tests/kms_plane_alpha_blend.c           |  1 +
 tests/kms_plane_cursor.c                |  1 +
 tests/kms_plane_lowres.c                |  4 +++-
 tests/kms_plane_multiple.c              |  1 +
 tests/kms_plane_scaling.c               |  4 +++-
 tests/kms_properties.c                  |  1 +
 tests/kms_rotation_crc.c                |  1 +
 tests/kms_scaling_modes.c               |  4 +++-
 tests/kms_sequence.c                    |  4 ++++
 tests/kms_universal_plane.c             |  1 +
 tests/kms_vblank.c                      |  4 ++++
 tests/syncobj_basic.c                   |  4 ++++
 tests/syncobj_timeline.c                |  4 ++++
 tests/syncobj_wait.c                    |  4 ++++
 76 files changed, 157 insertions(+), 32 deletions(-)

diff --git a/tests/core_auth.c b/tests/core_auth.c
index c9ad3fb9c875..257f124820a4 100644
--- a/tests/core_auth.c
+++ b/tests/core_auth.c
@@ -25,7 +25,6 @@
  * Testcase: drmGetMagic() and drmAuthMagic()
  */
 
-#include "igt.h"
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdint.h>
@@ -48,6 +47,9 @@
 # include <pthread.h>
 #endif
 
+#include "igt.h"
+#include "igt_types.h"
+
 IGT_TEST_DESCRIPTION("Call drmGetMagic() and drmAuthMagic() and see if it behaves.");
 
 static bool
@@ -192,8 +194,6 @@ static void test_basic_auth(int master)
 
 igt_main
 {
-	int master;
-
 	/* root (which we run igt as) should always be authenticated */
 	igt_describe("Check drm client is always authenticated.");
 	igt_subtest("getclient-simple") {
@@ -220,6 +220,8 @@ igt_main
 
 	/* above tests require that no drm fd is open */
 	igt_subtest_group {
+		igt_fd_t(master);
+
 		igt_fixture
 			master = drm_open_driver_master(DRIVER_ANY);
 	
diff --git a/tests/drm_import_export.c b/tests/drm_import_export.c
index 06245e8bac9f..2dd2f3cb9fff 100644
--- a/tests/drm_import_export.c
+++ b/tests/drm_import_export.c
@@ -296,4 +296,9 @@ igt_main {
 		pthread_join(test_thread_id3, NULL);
 		pthread_join(test_thread_id4, NULL);
 	}
+
+	igt_fixture {
+		close(fd);
+		close(fd1);
+	}
 }
diff --git a/tests/drm_read.c b/tests/drm_read.c
index 4a966a23b550..36dc623ede13 100644
--- a/tests/drm_read.c
+++ b/tests/drm_read.c
@@ -46,6 +46,8 @@
 #include <pthread.h>
 #include "drm.h"
 
+#include "igt_types.h"
+
 IGT_TEST_DESCRIPTION("Call read(drm) and see if it behaves.");
 
 static void sighandler(int sig, siginfo_t * info, void *context)
@@ -253,10 +255,10 @@ static void test_short_buffer_wakeup(int in, enum pipe pipe)
 
 igt_main
 {
-	int fd;
 	igt_display_t display;
 	struct igt_fb fb;
 	enum pipe pipe;
+	igt_fd_t(fd);
 
 	igt_fixture {
 		struct sigaction alarm_action = {};
diff --git a/tests/dumb_buffer.c b/tests/dumb_buffer.c
index 2c6261bd7d75..ded6b809c262 100644
--- a/tests/dumb_buffer.c
+++ b/tests/dumb_buffer.c
@@ -392,4 +392,8 @@ igt_main
 
 	igt_subtest("create-clear")
 		always_clear(fd, 30);
+
+	igt_fixture {
+		close(fd);
+	}
 }
diff --git a/tests/feature_discovery.c b/tests/feature_discovery.c
index 1978ce890de2..d369812ae614 100644
--- a/tests/feature_discovery.c
+++ b/tests/feature_discovery.c
@@ -29,15 +29,16 @@
 #include "igt_kms.h"
 #include "igt_psr.h"
 #include "igt_sysfs.h"
+#include "igt_types.h"
 
-static int fd;
-static int debugfs_fd;
 static igt_display_t display;
 
 IGT_TEST_DESCRIPTION("A metatest that checks for \"features\" presence. "
 		     "The subtests here should only skip or pass, "
 		     "anything else means we have a serious problem.");
 igt_main {
+	igt_fd_t(debugfs_fd);
+	igt_fd_t(fd);
 
 	igt_fixture {
 		fd = drm_open_driver_master(DRIVER_ANY);
diff --git a/tests/i915/gem_basic.c b/tests/i915/gem_basic.c
index 17ae190cb2cb..2aa5d850cc10 100644
--- a/tests/i915/gem_basic.c
+++ b/tests/i915/gem_basic.c
@@ -25,7 +25,6 @@
  *
  */
 
-#include "igt.h"
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -37,7 +36,10 @@
 #include <sys/ioctl.h>
 
 #include "drm.h"
+
 #include "i915/gem_create.h"
+#include "igt.h"
+#include "igt_types.h"
 
 IGT_TEST_DESCRIPTION("Tests basic gem_create and gem_close IOCTLs");
 
@@ -78,10 +80,10 @@ test_create_fd_close(int fd)
 	close(fd);
 }
 
-int fd;
-
 igt_main
 {
+	igt_fd_t(fd);
+
 	igt_fixture
 		fd = drm_open_driver(DRIVER_INTEL);
 
diff --git a/tests/i915/gem_blits.c b/tests/i915/gem_blits.c
index 46f157b9367a..24e83b9f512d 100644
--- a/tests/i915/gem_blits.c
+++ b/tests/i915/gem_blits.c
@@ -852,5 +852,6 @@ igt_main
 
 	igt_fixture {
 		put_ahnd(device.ahnd);
+		close(device.fd);
 	}
 }
diff --git a/tests/i915/gem_close.c b/tests/i915/gem_close.c
index ee2d690bfb54..e1ae701c17a1 100644
--- a/tests/i915/gem_close.c
+++ b/tests/i915/gem_close.c
@@ -24,6 +24,7 @@
 #include "i915/gem.h"
 #include "i915/gem_create.h"
 #include "igt.h"
+#include "igt_types.h"
 
 static int batch_create(int fd)
 {
@@ -125,7 +126,7 @@ static void test_many_handles(int fd)
 
 igt_main
 {
-	int fd = -1;
+	igt_fd_t(fd);
 
 	igt_fixture {
 		/* Create an flink requires DRM_AUTH */
diff --git a/tests/i915/gem_create.c b/tests/i915/gem_create.c
index d7d2a017223d..f3e5f15408fe 100644
--- a/tests/i915/gem_create.c
+++ b/tests/i915/gem_create.c
@@ -54,6 +54,7 @@
 #include "intel_chipset.h"
 #include "igt_aux.h"
 #include "igt_dummyload.h"
+#include "igt_types.h"
 #include "igt_x86.h"
 #include "i915/gem.h"
 #include "i915/gem_create.h"
@@ -780,7 +781,7 @@ static void create_ext_cpu_access_big(int fd)
 
 igt_main
 {
-	int fd = -1;
+	igt_fd_t(fd);
 
 	igt_fixture {
 		fd = drm_open_driver(DRIVER_INTEL);
diff --git a/tests/i915/gem_ctx_engines.c b/tests/i915/gem_ctx_engines.c
index 4b8e51457a8f..b0646516fa6f 100644
--- a/tests/i915/gem_ctx_engines.c
+++ b/tests/i915/gem_ctx_engines.c
@@ -41,6 +41,7 @@
 #include "i915/gem_context.h"
 #include "i915/gem_create.h"
 #include "igt.h"
+#include "igt_types.h"
 #include "sw_sync.h"
 
 #define engine_class(e, n) ((e)->engines[(n)].engine_class)
@@ -593,7 +594,7 @@ static void independent_all(int i915, const intel_ctx_t *ctx)
 igt_main
 {
 	const struct intel_execution_engine2 *e;
-	int i915 = -1;
+	igt_fd_t(i915);
 
 	igt_fixture {
 		i915 = drm_open_driver(DRIVER_INTEL);
diff --git a/tests/i915/gem_ctx_isolation.c b/tests/i915/gem_ctx_isolation.c
index 95d13969fa61..dc52a9a03130 100644
--- a/tests/i915/gem_ctx_isolation.c
+++ b/tests/i915/gem_ctx_isolation.c
@@ -25,6 +25,7 @@
 #include "i915/gem_create.h"
 #include "igt.h"
 #include "igt_dummyload.h"
+#include "igt_types.h"
 
 #define MAX_REG 0x200000
 #define NUM_REGS (MAX_REG / sizeof(uint32_t))
@@ -979,7 +980,7 @@ igt_main
 	unsigned int has_context_isolation = 0;
 	const struct intel_execution_engine2 *e;
 	intel_ctx_cfg_t cfg;
-	int i915 = -1;
+	igt_fd_t(i915);
 
 	igt_fixture {
 		int gen;
diff --git a/tests/i915/gem_ctx_shared.c b/tests/i915/gem_ctx_shared.c
index eb3b024f8e5b..d6b56b72abdc 100644
--- a/tests/i915/gem_ctx_shared.c
+++ b/tests/i915/gem_ctx_shared.c
@@ -42,6 +42,7 @@
 #include "i915/gem_engine_topology.h"
 #include "i915/gem_vm.h"
 #include "igt.h"
+#include "igt_types.h"
 #include "igt_rand.h"
 #include "igt_vgem.h"
 #include "sw_sync.h"
@@ -987,7 +988,7 @@ igt_main
 {
 	const struct intel_execution_engine2 *e;
 	intel_ctx_cfg_t cfg;
-	int i915 = -1;
+	igt_fd_t(i915);
 
 	igt_fixture {
 		i915 = drm_open_driver(DRIVER_INTEL);
diff --git a/tests/i915/gem_exec_alignment.c b/tests/i915/gem_exec_alignment.c
index 3e5f9d52cbed..a9fcd2a747d1 100644
--- a/tests/i915/gem_exec_alignment.c
+++ b/tests/i915/gem_exec_alignment.c
@@ -44,6 +44,7 @@
 #include "i915/gem.h"
 #include "i915/gem_create.h"
 #include "igt.h"
+#include "igt_types.h"
 
 IGT_TEST_DESCRIPTION("Exercises the basic execbuffer using object alignments");
 
@@ -525,7 +526,7 @@ static void single(int fd)
 
 igt_main
 {
-	int fd = -1;
+	igt_fd_t(fd);
 
 	igt_fixture {
 		fd = drm_open_driver(DRIVER_INTEL);
diff --git a/tests/i915/gem_exec_balancer.c b/tests/i915/gem_exec_balancer.c
index 6e6bf47043d5..4300dbd12f37 100644
--- a/tests/i915/gem_exec_balancer.c
+++ b/tests/i915/gem_exec_balancer.c
@@ -35,6 +35,7 @@
 #include "igt_gt.h"
 #include "igt_perf.h"
 #include "igt_sysfs.h"
+#include "igt_types.h"
 #include "sw_sync.h"
 
 IGT_TEST_DESCRIPTION("Exercise in-kernel load-balancing");
@@ -3302,7 +3303,7 @@ static bool has_parallel_execbuf(int i915)
 
 igt_main
 {
-	int i915 = -1;
+	igt_fd_t(i915);
 
 	igt_fixture {
 		i915 = drm_open_driver(DRIVER_INTEL);
diff --git a/tests/i915/gem_exec_endless.c b/tests/i915/gem_exec_endless.c
index b83d5a2c1480..2c56cc212036 100644
--- a/tests/i915/gem_exec_endless.c
+++ b/tests/i915/gem_exec_endless.c
@@ -28,6 +28,7 @@
 #include "igt.h"
 #include "igt_device.h"
 #include "igt_sysfs.h"
+#include "igt_types.h"
 #include "sw_sync.h"
 
 #define MAX_ENGINES 64
@@ -341,7 +342,7 @@ static void unpin_rps(int sysfs)
 igt_main
 {
 	const struct intel_execution_engine2 *e;
-	int i915 = -1;
+	igt_fd_t(i915);
 
 	igt_skip_on_simulation();
 
diff --git a/tests/i915/gem_flink_basic.c b/tests/i915/gem_flink_basic.c
index 4e207c2ab546..2620bc55daf0 100644
--- a/tests/i915/gem_flink_basic.c
+++ b/tests/i915/gem_flink_basic.c
@@ -25,7 +25,6 @@
  *
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -34,8 +33,12 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
+
 #include "drm.h"
 
+#include "igt.h"
+#include "igt_types.h"
+
 IGT_TEST_DESCRIPTION("Tests for flink - a way to export a gem object by name");
 
 static void
@@ -152,12 +155,14 @@ test_flink_lifetime(int fd)
 	ret = ioctl(fd2, DRM_IOCTL_GEM_OPEN, &open_struct);
 	igt_assert_eq(ret, 0);
 	igt_assert(open_struct.handle != 0);
-}
 
-int fd;
+	close(fd2);
+}
 
 igt_main
 {
+	igt_fd_t(fd);
+
 	igt_fixture
 		fd = drm_open_driver(DRIVER_INTEL);
 
diff --git a/tests/i915/gem_linear_blits.c b/tests/i915/gem_linear_blits.c
index 1fd5b733c3ce..d02751be9232 100644
--- a/tests/i915/gem_linear_blits.c
+++ b/tests/i915/gem_linear_blits.c
@@ -47,6 +47,7 @@
 #include "i915/gem.h"
 #include "i915/gem_create.h"
 #include "igt.h"
+#include "igt_types.h"
 
 IGT_TEST_DESCRIPTION("Test doing many blits with a working set larger than the"
 		     " aperture size.");
@@ -236,7 +237,7 @@ igt_main
 	const int ncpus = sysconf(_SC_NPROCESSORS_ONLN);
 	uint64_t count = 0;
 	bool do_relocs;
-	int fd = -1;
+	igt_fd_t(fd);
 
 	igt_fixture {
 		fd = drm_open_driver(DRIVER_INTEL);
diff --git a/tests/i915/gem_media_fill.c b/tests/i915/gem_media_fill.c
index 1d08df2473d1..e418047c2e74 100644
--- a/tests/i915/gem_media_fill.c
+++ b/tests/i915/gem_media_fill.c
@@ -173,5 +173,6 @@ igt_main
 	igt_fixture {
 		igt_collection_destroy(set);
 		igt_stop_hang_detector();
+		close(data.drm_fd);
 	}
 }
diff --git a/tests/i915/gem_render_copy.c b/tests/i915/gem_render_copy.c
index 3da29ec4e316..70b96c8f42ad 100644
--- a/tests/i915/gem_render_copy.c
+++ b/tests/i915/gem_render_copy.c
@@ -879,5 +879,6 @@ igt_main_args("dac", NULL, help_str, opt_handler, NULL)
 		igt_stop_hang_detector();
 		buf_ops_destroy(data.bops);
 		igt_collection_destroy(set);
+		close(data.drm_fd);
 	}
 }
diff --git a/tests/i915/gem_render_copy_redux.c b/tests/i915/gem_render_copy_redux.c
index 525c14d1814d..5e1daccf1801 100644
--- a/tests/i915/gem_render_copy_redux.c
+++ b/tests/i915/gem_render_copy_redux.c
@@ -233,4 +233,8 @@ igt_main
 			copy_flink(&data);
 		igt_stop_signal_helper();
 	}
+
+	igt_fixture {
+		data_fini(&data);
+	}
 }
diff --git a/tests/i915/gem_request_retire.c b/tests/i915/gem_request_retire.c
index da9d405ed443..9e163bd3af60 100644
--- a/tests/i915/gem_request_retire.c
+++ b/tests/i915/gem_request_retire.c
@@ -48,6 +48,7 @@
 
 #include "i915/gem.h"
 #include "igt.h"
+#include "igt_types.h"
 
 IGT_TEST_DESCRIPTION("Collection of tests targeting request retirement code"
 		     " paths.");
@@ -103,10 +104,10 @@ test_retire_vma_not_inactive(int fd)
 	put_ahnd(ahnd);
 }
 
-int fd;
-
 igt_main
 {
+	igt_fd_t(fd);
+
 	igt_fixture {
 		fd = drm_open_driver(DRIVER_INTEL);
 		igt_require_gem(fd);
diff --git a/tests/i915/gem_unfence_active_buffers.c b/tests/i915/gem_unfence_active_buffers.c
index 532eed2e76d4..a0a601de241d 100644
--- a/tests/i915/gem_unfence_active_buffers.c
+++ b/tests/i915/gem_unfence_active_buffers.c
@@ -99,4 +99,5 @@ igt_simple_main
 
 	igt_spin_free(i915, spin);
 	put_ahnd(ahnd);
+	close(i915);
 }
diff --git a/tests/i915/gem_unref_active_buffers.c b/tests/i915/gem_unref_active_buffers.c
index 3b8c981dae62..735c1472038a 100644
--- a/tests/i915/gem_unref_active_buffers.c
+++ b/tests/i915/gem_unref_active_buffers.c
@@ -121,4 +121,5 @@ igt_simple_main
 
 	igt_spin_free(i915, spin);
 	put_ahnd(ahnd);
+	close(i915);
 }
diff --git a/tests/i915/gem_userptr_blits.c b/tests/i915/gem_userptr_blits.c
index 1343b1097aef..6985086694c4 100644
--- a/tests/i915/gem_userptr_blits.c
+++ b/tests/i915/gem_userptr_blits.c
@@ -62,6 +62,7 @@
 #include "i915/gem_create.h"
 #include "igt.h"
 #include "igt_sysfs.h"
+#include "igt_types.h"
 #include "sw_sync.h"
 
 #include "eviction_common.c"
@@ -2299,7 +2300,7 @@ static void test_userfault(int i915)
 
 uint64_t total_ram;
 uint64_t aperture_size;
-int fd, count;
+int count;
 
 static int opt_handler(int opt, int opt_index, void *data)
 {
@@ -2319,6 +2320,7 @@ const char *help_str = "  -c\tBuffer count\n";
 igt_main_args("c:", NULL, help_str, opt_handler, NULL)
 {
 	int size = sizeof(linear);
+	igt_fd_t(fd);
 
 	igt_fixture {
 		unsigned int mmo_max = 0;
diff --git a/tests/i915/gem_workarounds.c b/tests/i915/gem_workarounds.c
index fc5184925a88..5fb2d73fdd30 100644
--- a/tests/i915/gem_workarounds.c
+++ b/tests/i915/gem_workarounds.c
@@ -31,6 +31,7 @@
 #include "i915/gem_create.h"
 #include "igt.h"
 #include "igt_device.h"
+#include "igt_types.h"
 
 #define PAGE_SIZE 4096
 #define PAGE_ALIGN(x) ALIGN(x, PAGE_SIZE)
@@ -238,7 +239,6 @@ static void check_workarounds(int fd, enum operation op, unsigned int flags)
 igt_main
 {
 	struct intel_mmio_data mmio_data;
-	int device = -1;
 	const struct {
 		const char *name;
 		enum operation op;
@@ -258,6 +258,7 @@ igt_main
 		{ "-fd", FD },
 		{ }
 	}, *m;
+	igt_fd_t(device);
 
 	igt_fixture {
 		FILE *file;
diff --git a/tests/i915/i915_pciid.c b/tests/i915/i915_pciid.c
index 7de44ff2ff1f..377eec58cf13 100644
--- a/tests/i915/i915_pciid.c
+++ b/tests/i915/i915_pciid.c
@@ -64,4 +64,6 @@ igt_simple_main
 	int intel = drm_open_driver(DRIVER_INTEL);
 
 	igt_assert(has_known_intel_chipset(intel));
+
+	close(intel);
 }
diff --git a/tests/i915/i915_pm_dc.c b/tests/i915/i915_pm_dc.c
index f664a2a2c14b..c7090f589de2 100644
--- a/tests/i915/i915_pm_dc.c
+++ b/tests/i915/i915_pm_dc.c
@@ -552,6 +552,7 @@ int main(int argc, char *argv[])
 		close(data.debugfs_fd);
 		close(data.msr_fd);
 		display_fini(&data);
+		close(data.drm_fd);
 	}
 
 	igt_exit();
diff --git a/tests/i915/kms_big_fb.c b/tests/i915/kms_big_fb.c
index 0c4cd95e7c96..8c7a38160f85 100644
--- a/tests/i915/kms_big_fb.c
+++ b/tests/i915/kms_big_fb.c
@@ -991,5 +991,6 @@ igt_main
 	igt_fixture {
 		igt_display_fini(&data.display);
 		buf_ops_destroy(data.bops);
+		close(data.drm_fd);
 	}
 }
diff --git a/tests/i915/kms_big_joiner.c b/tests/i915/kms_big_joiner.c
index 7d400616f7b5..71b2526d683c 100644
--- a/tests/i915/kms_big_joiner.c
+++ b/tests/i915/kms_big_joiner.c
@@ -328,5 +328,6 @@ igt_main
 	igt_fixture {
 		igt_remove_fb(data.drm_fd, &data.fb);
 		igt_display_fini(&data.display);
+		close(data.drm_fd);
 	}
 }
diff --git a/tests/i915/kms_busy.c b/tests/i915/kms_busy.c
index 99a07c2aecbd..171ae4ecebff 100644
--- a/tests/i915/kms_busy.c
+++ b/tests/i915/kms_busy.c
@@ -436,5 +436,6 @@ igt_main_args("e", NULL, help_str, opt_handler, NULL)
 
 	igt_fixture {
 		igt_display_fini(&display);
+		close(display.drm_fd);
 	}
 }
diff --git a/tests/i915/kms_ccs.c b/tests/i915/kms_ccs.c
index 4df611f77e0c..6721da493af5 100644
--- a/tests/i915/kms_ccs.c
+++ b/tests/i915/kms_ccs.c
@@ -699,6 +699,8 @@ igt_main_args("cs:", NULL, help_str, opt_handler, &data)
 		}
 	}
 
-	igt_fixture
+	igt_fixture {
 		igt_display_fini(&data.display);
+		close(data.drm_fd);
+	}
 }
diff --git a/tests/i915/kms_cdclk.c b/tests/i915/kms_cdclk.c
index 002b631c4b7e..991a7c507a10 100644
--- a/tests/i915/kms_cdclk.c
+++ b/tests/i915/kms_cdclk.c
@@ -373,5 +373,6 @@ igt_main
 
 	igt_fixture {
 		igt_display_fini(&data.display);
+		close(data.drm_fd);
 	}
 }
diff --git a/tests/i915/kms_fence_pin_leak.c b/tests/i915/kms_fence_pin_leak.c
index 16eb595fd65d..f1eac1c600ad 100644
--- a/tests/i915/kms_fence_pin_leak.c
+++ b/tests/i915/kms_fence_pin_leak.c
@@ -229,4 +229,5 @@ igt_simple_main
 
 	buf_ops_destroy(data.bops);
 	igt_display_fini(&data.display);
+	close(data.drm_fd);
 }
diff --git a/tests/i915/kms_flip_scaled_crc.c b/tests/i915/kms_flip_scaled_crc.c
index 764eb70fde31..364f622ba699 100644
--- a/tests/i915/kms_flip_scaled_crc.c
+++ b/tests/i915/kms_flip_scaled_crc.c
@@ -676,5 +676,6 @@ igt_main
 		}
 		kmstest_set_vt_text_mode();
 		igt_display_fini(&data.display);
+		close(data.drm_fd);
 	}
 }
diff --git a/tests/i915/kms_flip_tiling.c b/tests/i915/kms_flip_tiling.c
index ba9ff46ed150..0d8cc341c0b9 100644
--- a/tests/i915/kms_flip_tiling.c
+++ b/tests/i915/kms_flip_tiling.c
@@ -229,5 +229,6 @@ igt_main
 
 	igt_fixture {
 		igt_display_fini(&data.display);
+		close(data.drm_fd);
 	}
 }
diff --git a/tests/i915/kms_mmap_write_crc.c b/tests/i915/kms_mmap_write_crc.c
index a57938b5b8ff..b693c276b2c3 100644
--- a/tests/i915/kms_mmap_write_crc.c
+++ b/tests/i915/kms_mmap_write_crc.c
@@ -299,5 +299,6 @@ igt_main_args("n", NULL, NULL, opt_handler, NULL)
 		close(data.drm_fd);
 
 		igt_stop_helper(&hog);
+		close(data.drm_fd);
 	}
 }
diff --git a/tests/i915/kms_pipe_b_c_ivb.c b/tests/i915/kms_pipe_b_c_ivb.c
index 5823ae2a0885..05ac87702077 100644
--- a/tests/i915/kms_pipe_b_c_ivb.c
+++ b/tests/i915/kms_pipe_b_c_ivb.c
@@ -291,5 +291,6 @@ igt_main
 
 	igt_fixture {
 		igt_display_fini(&data.display);
+		close(data.drm_fd);
 	}
 }
diff --git a/tests/i915/kms_psr.c b/tests/i915/kms_psr.c
index 480e2cc77a2b..59f38e20e55f 100644
--- a/tests/i915/kms_psr.c
+++ b/tests/i915/kms_psr.c
@@ -592,5 +592,6 @@ igt_main_args("", long_options, help_str, opt_handler, &data)
 		close(data.debugfs_fd);
 		buf_ops_destroy(data.bops);
 		display_fini(&data);
+		close(data.drm_fd);
 	}
 }
diff --git a/tests/i915/kms_psr2_sf.c b/tests/i915/kms_psr2_sf.c
index 6612587c6b24..c9e6f2d0862b 100644
--- a/tests/i915/kms_psr2_sf.c
+++ b/tests/i915/kms_psr2_sf.c
@@ -1034,5 +1034,6 @@ igt_main
 	igt_fixture {
 		close(data.debugfs_fd);
 		display_fini(&data);
+		close(data.drm_fd);
 	}
 }
diff --git a/tests/i915/kms_psr2_su.c b/tests/i915/kms_psr2_su.c
index caccf713d86e..6062f9d87186 100644
--- a/tests/i915/kms_psr2_su.c
+++ b/tests/i915/kms_psr2_su.c
@@ -335,5 +335,6 @@ igt_main
 	igt_fixture {
 		close(data.debugfs_fd);
 		display_fini(&data);
+		close(data.drm_fd);
 	}
 }
diff --git a/tests/i915/kms_pwrite_crc.c b/tests/i915/kms_pwrite_crc.c
index 584e6a19ce9d..7df4b36924fa 100644
--- a/tests/i915/kms_pwrite_crc.c
+++ b/tests/i915/kms_pwrite_crc.c
@@ -191,4 +191,5 @@ igt_simple_main
 	run_test(&data);
 
 	igt_display_fini(&data.display);
+	close(data.drm_fd);
 }
diff --git a/tests/kms_3d.c b/tests/kms_3d.c
index 1488cc146728..c6bef67c1c0f 100644
--- a/tests/kms_3d.c
+++ b/tests/kms_3d.c
@@ -111,4 +111,5 @@ igt_simple_main
 	kmstest_force_edid(drm_fd, connector, NULL);
 
 	drmModeFreeConnector(connector);
+	close(drm_fd);
 }
diff --git a/tests/kms_atomic.c b/tests/kms_atomic.c
index 253829f2bd14..831ba2587292 100644
--- a/tests/kms_atomic.c
+++ b/tests/kms_atomic.c
@@ -1436,5 +1436,6 @@ igt_main
 		igt_remove_fb(display.drm_fd, &fb);
 
 		igt_display_fini(&display);
+		close(display.drm_fd);
 	}
 }
diff --git a/tests/kms_atomic_interruptible.c b/tests/kms_atomic_interruptible.c
index 038cb2867989..f461a15c9f4c 100644
--- a/tests/kms_atomic_interruptible.c
+++ b/tests/kms_atomic_interruptible.c
@@ -349,5 +349,6 @@ igt_main
 	/* TODO: legacy gamma_set/get, object set/getprop, getcrtc, getconnector */
 	igt_fixture {
 		igt_display_fini(&display);
+		close(display.drm_fd);
 	}
 }
diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c
index 10b21c929e3b..05c76ebbce9f 100644
--- a/tests/kms_atomic_transition.c
+++ b/tests/kms_atomic_transition.c
@@ -1231,5 +1231,6 @@ igt_main_args("", long_opts, help_str, opt_handler, &data)
 
 	igt_fixture {
 		igt_display_fini(&data.display);
+		close(data.drm_fd);
 	}
 }
diff --git a/tests/kms_color.c b/tests/kms_color.c
index c202547e59ea..69c180c119df 100644
--- a/tests/kms_color.c
+++ b/tests/kms_color.c
@@ -1058,5 +1058,6 @@ igt_main
 
 	igt_fixture {
 		igt_display_fini(&data.display);
+		close(data.drm_fd);
 	}
 }
diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c
index 3041f1cddf8b..095cc94b446b 100644
--- a/tests/kms_content_protection.c
+++ b/tests/kms_content_protection.c
@@ -839,5 +839,6 @@ igt_main
 	igt_fixture {
 		test_content_protection_cleanup();
 		igt_display_fini(&data.display);
+		close(data.drm_fd);
 	}
 }
diff --git a/tests/kms_cursor_crc.c b/tests/kms_cursor_crc.c
index 53f18f4f1add..febaf810e116 100644
--- a/tests/kms_cursor_crc.c
+++ b/tests/kms_cursor_crc.c
@@ -909,5 +909,6 @@ igt_main
 		}
 
 		igt_display_fini(&data.display);
+		close(data.drm_fd);
 	}
 }
diff --git a/tests/kms_cursor_edge_walk.c b/tests/kms_cursor_edge_walk.c
index b75fc216f9f2..74187613276e 100644
--- a/tests/kms_cursor_edge_walk.c
+++ b/tests/kms_cursor_edge_walk.c
@@ -362,6 +362,8 @@ igt_main_args("", long_opts, help_str, opt_handler, &data)
 		}
 	}
 
-	igt_fixture
+	igt_fixture {
 		igt_display_fini(&data.display);
+		close(data.drm_fd);
+	}
 }
diff --git a/tests/kms_cursor_legacy.c b/tests/kms_cursor_legacy.c
index 1b69766781c4..1ad92eaae881 100644
--- a/tests/kms_cursor_legacy.c
+++ b/tests/kms_cursor_legacy.c
@@ -1753,5 +1753,6 @@ igt_main
 		if (intel_psr2_restore)
 			i915_psr2_sel_fetch_restore(display.drm_fd);
 		igt_display_fini(&display);
+		close(display.drm_fd);
 	}
 }
diff --git a/tests/kms_dither.c b/tests/kms_dither.c
index 43a25e203ef4..95be6e136c61 100644
--- a/tests/kms_dither.c
+++ b/tests/kms_dither.c
@@ -247,5 +247,6 @@ igt_main
 
 	igt_fixture {
 		igt_display_fini(&data.display);
+		close(data.drm_fd);
 	}
 }
diff --git a/tests/kms_dp_aux_dev.c b/tests/kms_dp_aux_dev.c
index d3249fa3d68d..ed9dd510cea6 100644
--- a/tests/kms_dp_aux_dev.c
+++ b/tests/kms_dp_aux_dev.c
@@ -134,4 +134,5 @@ igt_simple_main
 	igt_require(valid_connectors);
 
 	drmModeFreeResources(res);
+	close(drm_fd);
 }
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 0567edeaf2ab..5e82f4a2f842 100755
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -1877,4 +1877,7 @@ igt_main_args("e", NULL, help_str, opt_handler, NULL)
 			run_pair(tests[i].duration, tests[i].flags);
 	}
 	igt_stop_signal_helper();
+
+	igt_fixture
+		close(drm_fd);
 }
diff --git a/tests/kms_flip_event_leak.c b/tests/kms_flip_event_leak.c
index ac201293b334..b3d01aeb24e1 100644
--- a/tests/kms_flip_event_leak.c
+++ b/tests/kms_flip_event_leak.c
@@ -109,4 +109,5 @@ igt_simple_main
 	igt_require_f(valid_tests, "no valid crtc/connector combinations found\n");
 
 	igt_display_fini(&data.display);
+	close(data.drm_fd);
 }
diff --git a/tests/kms_force_connector_basic.c b/tests/kms_force_connector_basic.c
index 683d3672056d..6259cec538de 100644
--- a/tests/kms_force_connector_basic.c
+++ b/tests/kms_force_connector_basic.c
@@ -33,9 +33,9 @@ IGT_TEST_DESCRIPTION("Check the debugfs force connector/edid features work"
 
 static void reset_connectors(void)
 {
-	int drm_fd = 0;
 	drmModeRes *res;
 	drmModeConnector *connector = NULL;
+	int drm_fd;
 
 	drm_fd = drm_open_driver_master(DRIVER_ANY);
 	res = drmModeGetResources(drm_fd);
@@ -54,6 +54,8 @@ static void reset_connectors(void)
 	}
 
 	igt_set_module_param_int(drm_fd, "load_detect_test", 0);
+
+	close(drm_fd);
 }
 
 static int opt_handler(int opt, int opt_index, void *data)
@@ -224,6 +226,9 @@ igt_main_args("", long_opts, help_str, opt_handler, NULL)
 
 			drmModeFreePlane(drm_plane);
 		}
+
+		igt_remove_fb(drm_fd, &xrgb_fb);
+		igt_remove_fb(drm_fd, &argb_fb);
 	}
 
 	igt_describe("Test to check the forced connector state.");
diff --git a/tests/kms_hdmi_inject.c b/tests/kms_hdmi_inject.c
index abae0ab44feb..b6418faf0eaf 100644
--- a/tests/kms_hdmi_inject.c
+++ b/tests/kms_hdmi_inject.c
@@ -219,5 +219,6 @@ igt_main
 
 	igt_fixture {
 		drmModeFreeConnector(connector);
+		close(drm_fd);
 	}
 }
diff --git a/tests/kms_hdr.c b/tests/kms_hdr.c
index e2650f51331f..c18acb60f99e 100644
--- a/tests/kms_hdr.c
+++ b/tests/kms_hdr.c
@@ -615,5 +615,6 @@ igt_main
 
 	igt_fixture {
 		igt_display_fini(&data.display);
+		close(data.fd);
 	}
 }
diff --git a/tests/kms_invalid_mode.c b/tests/kms_invalid_mode.c
index 0ae98a31fcc2..f1c38669860d 100644
--- a/tests/kms_invalid_mode.c
+++ b/tests/kms_invalid_mode.c
@@ -306,5 +306,6 @@ igt_main
 	igt_fixture {
 		igt_display_fini(&data.display);
 		igt_reset_connectors();
+		close(data.drm_fd);
 	}
 }
diff --git a/tests/kms_lease.c b/tests/kms_lease.c
index 0bf102a6d8f1..4122b0d19a3c 100644
--- a/tests/kms_lease.c
+++ b/tests/kms_lease.c
@@ -1287,4 +1287,8 @@ igt_main
 	igt_describe("Tests all the uevent cases");
 	igt_subtest("lease-uevent")
 		lease_uevent(&data);
+
+	igt_fixture {
+		close(data.master.fd);
+	}
 }
diff --git a/tests/kms_panel_fitting.c b/tests/kms_panel_fitting.c
index 478c16bd5f37..2d0590da2ec6 100644
--- a/tests/kms_panel_fitting.c
+++ b/tests/kms_panel_fitting.c
@@ -280,6 +280,8 @@ igt_main
 	igt_subtest_with_dynamic("atomic-fastset")
 		test_panel_fitting(&data, TEST_ATOMIC);
 
-	igt_fixture
+	igt_fixture {
 		igt_display_fini(&data.display);
+		close(data.drm_fd);
+	}
 }
diff --git a/tests/kms_pipe_crc_basic.c b/tests/kms_pipe_crc_basic.c
index 2ff40f72e23e..2985de51c33c 100644
--- a/tests/kms_pipe_crc_basic.c
+++ b/tests/kms_pipe_crc_basic.c
@@ -362,5 +362,6 @@ igt_main
 
 	igt_fixture {
 		igt_display_fini(&data.display);
+		close(data.drm_fd);
 	}
 }
diff --git a/tests/kms_plane.c b/tests/kms_plane.c
index 3cf3cfd3a095..eb943e13f408 100644
--- a/tests/kms_plane.c
+++ b/tests/kms_plane.c
@@ -1213,5 +1213,6 @@ igt_main_args("", long_opts, help_str, opt_handler, &data)
 
 	igt_fixture {
 		igt_display_fini(&data.display);
+		close(data.drm_fd);
 	}
 }
diff --git a/tests/kms_plane_alpha_blend.c b/tests/kms_plane_alpha_blend.c
index bd064d1e494b..f8660f14e94d 100644
--- a/tests/kms_plane_alpha_blend.c
+++ b/tests/kms_plane_alpha_blend.c
@@ -586,5 +586,6 @@ igt_main
 				    COMMIT_ATOMIC : COMMIT_LEGACY);
 
 		igt_display_fini(&data.display);
+		close(data.gfx_fd);
 	}
 }
diff --git a/tests/kms_plane_cursor.c b/tests/kms_plane_cursor.c
index 6b7e5cef5662..95925ea20db1 100644
--- a/tests/kms_plane_cursor.c
+++ b/tests/kms_plane_cursor.c
@@ -310,5 +310,6 @@ igt_main
 
 	igt_fixture {
 		igt_display_fini(&data.display);
+		close(data.drm_fd);
 	}
 }
diff --git a/tests/kms_plane_lowres.c b/tests/kms_plane_lowres.c
index f37dbd16ac03..bb6cffac0911 100644
--- a/tests/kms_plane_lowres.c
+++ b/tests/kms_plane_lowres.c
@@ -334,6 +334,8 @@ igt_main
 			run_test(&data, subtests[i].modifier);
 	}
 
-	igt_fixture
+	igt_fixture {
 		igt_display_fini(&data.display);
+		close(data.drm_fd);
+	}
 }
diff --git a/tests/kms_plane_multiple.c b/tests/kms_plane_multiple.c
index b43a4c27bc4b..393cf37a09ba 100644
--- a/tests/kms_plane_multiple.c
+++ b/tests/kms_plane_multiple.c
@@ -468,5 +468,6 @@ igt_main_args("", long_options, help_str, opt_handler, NULL)
 
 	igt_fixture {
 		igt_display_fini(&data.display);
+		close(data.drm_fd);
 	}
 }
diff --git a/tests/kms_plane_scaling.c b/tests/kms_plane_scaling.c
index fc8250b5053c..4c621cce8425 100644
--- a/tests/kms_plane_scaling.c
+++ b/tests/kms_plane_scaling.c
@@ -983,6 +983,8 @@ igt_main_args("", long_opts, help_str, opt_handler, &data)
 	igt_subtest_f("2x-scaler-multi-pipe")
 		test_scaler_with_multi_pipe_plane(&data);
 
-	igt_fixture
+	igt_fixture {
 		igt_display_fini(&data.display);
+		close(data.drm_fd);
+	}
 }
diff --git a/tests/kms_properties.c b/tests/kms_properties.c
index dd5a93aa7a77..2958efaca7ab 100644
--- a/tests/kms_properties.c
+++ b/tests/kms_properties.c
@@ -792,5 +792,6 @@ igt_main
 
 	igt_fixture {
 		igt_display_fini(&display);
+		close(display.drm_fd);
 	}
 }
diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
index 50869a08a275..db53f5d144ea 100644
--- a/tests/kms_rotation_crc.c
+++ b/tests/kms_rotation_crc.c
@@ -1187,5 +1187,6 @@ igt_main_args("", long_opts, help_str, opt_handler, &data)
 
 	igt_fixture {
 		igt_display_fini(&data.display);
+		close(data.gfx_fd);
 	}
 }
diff --git a/tests/kms_scaling_modes.c b/tests/kms_scaling_modes.c
index 8e80189ac6bb..039e4a8d9303 100644
--- a/tests/kms_scaling_modes.c
+++ b/tests/kms_scaling_modes.c
@@ -132,6 +132,8 @@ igt_main
 	igt_subtest_with_dynamic("scaling-mode-none")
 		test_scaling_mode(&data, DRM_MODE_SCALE_NONE);
 
-	igt_fixture
+	igt_fixture {
 		igt_display_fini(&data.display);
+		close(data.drm_fd);
+	}
 }
diff --git a/tests/kms_sequence.c b/tests/kms_sequence.c
index 1655d7d1bc7d..c72857a394c7 100644
--- a/tests/kms_sequence.c
+++ b/tests/kms_sequence.c
@@ -295,4 +295,8 @@ igt_main
 			}
 		}
 	}
+
+	igt_fixture {
+		close(fd);
+	}
 }
diff --git a/tests/kms_universal_plane.c b/tests/kms_universal_plane.c
index 3cb6d704a6ef..e23f0f718cd2 100644
--- a/tests/kms_universal_plane.c
+++ b/tests/kms_universal_plane.c
@@ -817,5 +817,6 @@ igt_main
 
 	igt_fixture {
 		igt_display_fini(&data.display);
+		close(data.drm_fd);
 	}
 }
diff --git a/tests/kms_vblank.c b/tests/kms_vblank.c
index e65e8522a861..5bd3fefe1440 100644
--- a/tests/kms_vblank.c
+++ b/tests/kms_vblank.c
@@ -550,4 +550,8 @@ igt_main
 	for_each_pipe_static(data.pipe)
 		igt_subtest_group
 			run_subtests_for_pipe(&data);
+
+	igt_fixture {
+		close(fd);
+	}
 }
diff --git a/tests/syncobj_basic.c b/tests/syncobj_basic.c
index 1dce45c918ac..6e20c3411a87 100644
--- a/tests/syncobj_basic.c
+++ b/tests/syncobj_basic.c
@@ -231,4 +231,8 @@ igt_main
 	igt_subtest("test-valid-cycle")
 		test_valid_cycle(fd);
 
+	igt_fixture {
+		close(fd);
+	}
+
 }
diff --git a/tests/syncobj_timeline.c b/tests/syncobj_timeline.c
index 20375cdd38dc..7f5ff6f6cad6 100644
--- a/tests/syncobj_timeline.c
+++ b/tests/syncobj_timeline.c
@@ -1536,4 +1536,8 @@ igt_main
 	igt_describe(test_32bits_limit_desc);
 	igt_subtest("32bits-limit")
 		test_32bits_limit(fd);
+
+	igt_fixture {
+		close(fd);
+	}
 }
diff --git a/tests/syncobj_wait.c b/tests/syncobj_wait.c
index 669d0adfc10d..427b6b1192ad 100644
--- a/tests/syncobj_wait.c
+++ b/tests/syncobj_wait.c
@@ -912,4 +912,8 @@ igt_main
 
 	igt_subtest("wait-all-interrupted")
 		test_wait_interrupted(fd, WAIT_ALL);
+
+	igt_fixture {
+		close(fd);
+	}
 }
-- 
2.37.2



More information about the Intel-gfx-trybot mailing list