Re: [Intel-gfx] [PATCH i-g-t] tests/debugfs_test: Pretty print subdirectories

2017-11-03 Thread Arkadiusz Hiler
On Thu, Nov 02, 2017 at 01:20:26PM +0100, Maarten Lankhorst wrote:
> 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 

and pushed, since the test results are clean on this binary.

Thanks!

-- 
Cheers,
Arek
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] tests/debugfs_test: Pretty print subdirectories

2017-11-02 Thread Maarten Lankhorst
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 
---
 tests/debugfs_test.c | 25 ++---
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/tests/debugfs_test.c b/tests/debugfs_test.c
index ae38ba077df6..268d6e78fdc1 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.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.is_atomic ? COMMIT_ATOMIC 
: COMMIT_LEGACY);
 
-   read_and_discard_sysfs_entries(debugfs);
+   read_and_discard_sysfs_entries(debugfs, 0);
}
 
igt_subtest("emon_crash") {
-- 
2.14.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx