diff options
author | Maarten Lankhorst <maarten.lankhorst@linux.intel.com> | 2017-11-02 13:20:26 +0100 |
---|---|---|
committer | Arkadiusz Hiler <arkadiusz.hiler@intel.com> | 2017-11-03 09:15:54 +0200 |
commit | c8d1ea24d3bfaf11b223bbe22407aeca196d0d89 (patch) | |
tree | 506159467e3ab7067d3e92a3a1f460513ef52048 /tests/debugfs_test.c | |
parent | 6d16875736b9fb1ebf4bf3dc5a941f9e431d58e0 (diff) |
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 <maarten.lankhorst@linux.intel.com>
Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Diffstat (limited to 'tests/debugfs_test.c')
-rw-r--r-- | tests/debugfs_test.c | 25 |
1 files changed, 18 insertions, 7 deletions
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 <sys/types.h> #include <dirent.h> -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") { |