[igt-dev] [PATCH i-g-t 2/2] tests/debugfs_test: Add subtest guc_log_relay
Piotr Piórkowski
piotr.piorkowski at intel.com
Tue Apr 10 13:52:27 UTC 2018
We doesn't have any tests to verify functionality of i915_guc_log_relay.
I think we should test this component.
Let's add simple subtest to debugfs_test, which will test:
- opening the i915_guc_log_relay and creating a file guc_log0,
- flushing GuC log buffer,
- closing i915_guc_log_relay with removing from debugfs guc_log0.
Signed-off-by: Piotr Piórkowski <piotr.piorkowski at intel.com>
Cc: Sagar Arun Kamble <sagar.a.kamble at intel.com>
Cc: Lukasz Fiedorowicz <lukasz.fiedorowicz at intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko at intel.com>
Cc: Michał Winiarski <michal.winiarski at intel.com>
---
tests/debugfs_test.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 87 insertions(+)
diff --git a/tests/debugfs_test.c b/tests/debugfs_test.c
index 2e87e442..f9a859a4 100644
--- a/tests/debugfs_test.c
+++ b/tests/debugfs_test.c
@@ -87,6 +87,18 @@ static void read_and_discard_sysfs_entries(int path_fd, int indent)
closedir(dir);
}
+static bool is_guc_loaded(int gfx_fd)
+{
+ bool load = false;
+
+ // Look for: "status: fetch SUCCESS, load SUCCESS" in debugfs
+ load = igt_debugfs_search(gfx_fd, "i915_guc_load_status",
+ "\tstatus: fetch SUCCESS, load SUCCESS");
+ igt_debug("GuC %s loaded\n", load ? "is" : "is not");
+
+ return load;
+}
+
igt_main
{
int fd = -1, debugfs;
@@ -173,6 +185,81 @@ igt_main
igt_success();
}
+ igt_subtest("guc_log_relay") {
+
+ #define I915_GUC_LOG_RELAY_FILE "i915_guc_log_relay"
+ #define GUC_LOG_FILE "guc_log0"
+
+ int page_size = getpagesize();
+ int gen;
+ int fd_relay = -1, fd_log = -1;
+ int sysfs_parameters_dir;
+ ssize_t read_size;
+ uint32_t enable_guc_param;
+ uint8_t *buffer = malloc(page_size);
+
+ gen = intel_gen(intel_get_drm_devid(fd));
+ igt_require(gen >= 9);
+
+ /* We check if the guc is enabled in i915 parameters*/
+ sysfs_parameters_dir = igt_sysfs_open_parameters(fd);
+ igt_assert(sysfs_parameters_dir >= 0);
+ enable_guc_param = igt_sysfs_get_u32(sysfs_parameters_dir,
+ "enable_guc");
+ igt_require(enable_guc_param != 0);
+
+ /* GuC should be loaded */
+ igt_assert(is_guc_loaded(fd));
+
+ debugfs = igt_debugfs_dir(fd);
+
+ fd_relay = openat(debugfs, I915_GUC_LOG_RELAY_FILE, O_RDWR);
+ igt_assert(fd_relay > 0);
+
+ /*
+ * The GUC_LOG_FILE should be created
+ * after opening the I915_GUC_LOG_RELAY_FILE file
+ */
+ fd_log = igt_debugfs_open(fd, GUC_LOG_FILE, O_RDONLY);
+ igt_assert(fd_log > 0);
+
+ /*
+ * We want to check flush and read from GUC_LOG_FILE.
+ * First, we read all available bytes from buffer
+ * (if any bytes are ready to be read).
+ */
+
+ do {
+ read_size = read(fd_log, buffer, page_size);
+ igt_debug("Shall attempt to read %d bytes from file %s. \
+ The number of bytes actually read: %li\n",
+ page_size, GUC_LOG_FILE, read_size);
+ } while (read_size != 0);
+
+ /*
+ * When buffer is empty, we trigger a flush
+ * by sending anything to the file I915_GUC_LOG_RELAY_FILE
+ */
+ write(fd_relay, buffer, 1);
+
+ /* We read again and now we should get some bytes */
+ read_size = read(fd_log, buffer, page_size);
+ igt_debug("Shall attempt to read %d bytes from file %s. \
+ The number of bytes actually read: %li\n",
+ page_size, GUC_LOG_FILE, read_size);
+ igt_assert(read_size > 0);
+
+ /*
+ * Now we try close the I915_GUC_LOG_RELAY_FILE file.
+ * This should cause the GUC_LOG_FILE file to be closed
+ * and removed from debugfs
+ */
+ close(fd_relay);
+ igt_assert(!igt_debugfs_is_file_exists(fd, GUC_LOG_FILE));
+
+ igt_success();
+ }
+
igt_fixture {
igt_display_fini(&display);
close(debugfs);
--
2.14.3
More information about the igt-dev
mailing list