From c8d1ea24d3bfaf11b223bbe22407aeca196d0d89 Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Thu, 2 Nov 2017 13:20:26 +0100 Subject: tests/debugfs_test: Pretty print subdirectories Instead of: (debugfs_test:1499) DEBUG: Reading file "data" (debugfs_test:1499) DEBUG: Could not open file "data" with error: Input/output error Print: (debugfs_test:1360) DEBUG: Entering subdir crtc-2 (debugfs_test:1360) DEBUG: Entering subdir crc (debugfs_test:1360) DEBUG: Reading file "data" (debugfs_test:1360) DEBUG: Could not open file "data" with error: Input/output error (debugfs_test:1360) DEBUG: Reading file "control" Signed-off-by: Maarten Lankhorst Reviewed-by: Arkadiusz Hiler --- tests/debugfs_test.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'tests/debugfs_test.c') diff --git a/tests/debugfs_test.c b/tests/debugfs_test.c index ae38ba07..268d6e78 100644 --- a/tests/debugfs_test.c +++ b/tests/debugfs_test.c @@ -27,10 +27,18 @@ #include #include -static void read_and_discard_sysfs_entries(int path_fd) +static void read_and_discard_sysfs_entries(int path_fd, int indent) { struct dirent *dirent; DIR *dir; + char tabs[8]; + int i; + + igt_assert(indent < sizeof(tabs) - 1); + + for (i = 0; i < indent; i++) + tabs[i] = '\t'; + tabs[i] = '\0'; dir = fdopendir(path_fd); if (!dir) @@ -45,7 +53,8 @@ static void read_and_discard_sysfs_entries(int path_fd) igt_assert((sub_fd = openat(path_fd, dirent->d_name, O_RDONLY | O_DIRECTORY)) > 0); - read_and_discard_sysfs_entries(sub_fd); + igt_debug("%sEntering subdir %s\n", tabs, dirent->d_name); + read_and_discard_sysfs_entries(sub_fd, indent + 1); close(sub_fd); } else { char buf[512]; @@ -53,11 +62,12 @@ static void read_and_discard_sysfs_entries(int path_fd) ssize_t ret; igt_set_timeout(5, "reading sysfs entry"); - igt_debug("Reading file \"%s\"\n", dirent->d_name); + igt_debug("%sReading file \"%s\"\n", tabs, 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); + igt_debug("%sCould not open file \"%s\" with error: %m\n", + tabs, dirent->d_name); continue; } @@ -66,7 +76,8 @@ static void read_and_discard_sysfs_entries(int path_fd) } while (ret == sizeof(buf)); if (ret == -1) - igt_debug("Could not read file \"%s\" with error: %m\n", dirent->d_name); + igt_debug("%sCould not read file \"%s\" with error: %m\n", + tabs, dirent->d_name); igt_reset_timeout(); close(sub_fd); @@ -121,7 +132,7 @@ igt_main igt_display_commit2(&display, display.is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); - read_and_discard_sysfs_entries(debugfs); + read_and_discard_sysfs_entries(debugfs, 0); } igt_subtest("read_all_entries_display_off") { @@ -137,7 +148,7 @@ igt_main igt_display_commit2(&display, display.is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); - read_and_discard_sysfs_entries(debugfs); + read_and_discard_sysfs_entries(debugfs, 0); } igt_subtest("emon_crash") { -- cgit v1.2.3