[Intel-gfx] [PATCH i-g-t 1/2] tests/debugfs_test: Fix testcases to pass

Maarten Lankhorst maarten.lankhorst at linux.intel.com
Thu Jul 20 14:27:54 UTC 2017


emon_crash should skip if the debugfs file could not be opened the first
time, and debugfs_test.read_all_entries should skip files that could not
be opened, instead of returning an error.

This is because in a typical IGT run there may be more debugfs files
registered than can be opened.

This is an example on f2-pnv-d510:
$ grep -r . /sys/kernel/debug/dri/0 >/dev/null
grep: /sys/kernel/debug/dri/0/i915_sseu_status: No such device
grep: /sys/kernel/debug/dri/0/i915_energy_uJ: No such device
grep: /sys/kernel/debug/dri/0/i915_sink_crc_eDP1: No such device
grep: /sys/kernel/debug/dri/0/i915_emon_status: No such device
grep: /sys/kernel/debug/dri/0/i915_guc_log_control: Invalid argument
grep: /sys/kernel/debug/dri/0/i915_fbc_false_color: No such device
grep: /sys/kernel/debug/dri/0/i915_cur_wm_latency: No such device
grep: /sys/kernel/debug/dri/0/i915_spr_wm_latency: No such device
grep: /sys/kernel/debug/dri/0/i915_pri_wm_latency: No such device
grep: /sys/kernel/debug/dri/0/i915_next_seqno: Permission denied
grep: /sys/kernel/debug/dri/0/i915_cache_sharing: No such device
grep: /sys/kernel/debug/dri/0/i915_min_freq: No such device
grep: /sys/kernel/debug/dri/0/i915_max_freq: No such device
grep: /sys/kernel/debug/dri/0/i915_pipe_C_crc: No such device
grep: /sys/kernel/debug/dri/0/i915_forcewake_user: Invalid argument
grep: /sys/kernel/debug/dri/0/crtc-1/crc/data: Input/output error

Signed-off-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
Cc: Abdiel Janulgue <abdiel.janulgue at linux.intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler at intel.com>
---
 tests/debugfs_test.c | 38 ++++++++++++++++++++++++--------------
 1 file changed, 24 insertions(+), 14 deletions(-)

diff --git a/tests/debugfs_test.c b/tests/debugfs_test.c
index 122f7dc8bff6..1663fd41eab8 100644
--- a/tests/debugfs_test.c
+++ b/tests/debugfs_test.c
@@ -29,7 +29,7 @@
 #include <sys/types.h>
 #include <dirent.h>
 
-static void read_and_discard_sysfs_entries(int path_fd, bool is_crc)
+static void read_and_discard_sysfs_entries(int path_fd)
 {
 	struct dirent *dirent;
 	DIR *dir;
@@ -47,24 +47,31 @@ static void read_and_discard_sysfs_entries(int path_fd, bool is_crc)
 			igt_assert((sub_fd =
 				    openat(path_fd, dirent->d_name, O_RDONLY |
 					   O_DIRECTORY)) > 0);
-			read_and_discard_sysfs_entries(sub_fd, !strcmp(dirent->d_name, "crc"));
+			read_and_discard_sysfs_entries(sub_fd);
 			close(sub_fd);
 		} else {
-			char *buf;
+			char buf[512];
+			int sub_fd;
+			ssize_t ret;
 
 			igt_set_timeout(5, "reading sysfs entry");
-			buf = igt_sysfs_get(path_fd, dirent->d_name);
-			igt_reset_timeout();
-			/*
-			 * /crtc-XX/crc/data may fail with -EIO if the CRTC
-			 * is not active.
-			 */
-			if (!buf && is_crc && errno == EIO &&
-			    !strcmp(dirent->d_name, "data"))
+			igt_debug("Reading file \"%s\"\n", dirent->d_name);
+
+			sub_fd = openat(path_fd, dirent->d_name, O_RDONLY);
+			if (sub_fd == -1) {
+				igt_debug("Could not open file \"%s\" with error: %m\n", dirent->d_name);
 				continue;
+			}
 
-			igt_assert(buf);
-			free(buf);
+			do {
+				ret = read(sub_fd, buf, sizeof(buf));
+			} while (ret == sizeof(buf));
+
+			if (ret == -1)
+				igt_debug("Could not read file \"%s\" with error: %m\n", dirent->d_name);
+
+			igt_reset_timeout();
+			close(sub_fd);
 		}
 	}
 	closedir(dir);
@@ -82,7 +89,7 @@ igt_main
 	}
 
 	igt_subtest("read_all_entries") {
-		read_and_discard_sysfs_entries(debugfs, false);
+		read_and_discard_sysfs_entries(debugfs);
 	}
 
 	igt_subtest("emon_crash") {
@@ -95,6 +102,9 @@ igt_main
 		for (i = 0; i < 1000; i++) {
 			char *buf = igt_sysfs_get(debugfs,
 						  "i915_emon_status");
+
+			igt_skip_on_f(!buf && !i, "i915_emon_status could not be read\n");
+
 			igt_assert(buf);
 			free(buf);
 		}
-- 
2.11.0



More information about the Intel-gfx mailing list