tools_test: Clean up and fix sysfs_l3_parity
PATCH 1/2 tools_test: Clean up and fix sysfs_l3_parity
Multiple misunderstandings of the expectations of the test and some missed parts of the shell-to-c conversion caused a couple of issues to remain.
First, we need to actually disable a subbank before we check that a subbank is disabled (invoke the tool with -d).
Second, the original pipe to wc -l was to check that the tool prints only one line, not that it prints "at least" a line. Modify the last check to verify that an "is disabled" text is _not_ printed.
v2: Add a TODO comment
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101650
--- tests/tools_test.c | 87 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 37 deletions(-)
tests/tools_test.c +50 -37
@@ -28,26 +28,31 @@#include <fcntl.h> struct line_check { -bool found; +int found;const char *substr; };/** * Our igt_log_buffer_inspect handler. Checks the output of the -* intel_l3_parity tool and returns line_check::found to true if -* a specific substring is found. +* intel_l3_parity tool and increments line_check::found if a specific +* substring is found. */ -static bool check_cmd_return_value (const char *line,void *data) +static bool check_cmd_output (const char *line,void *data) {struct line_check *check = data; -if (!strstr (line, check->substr)) { - check->found = false; -return false; +if (strstr (line, check->substr)) { + check->found++; } - check->found = true; -return true; +return false; +} + +static void assert_cmd_success (int exec_return) +{ +igt_skip_on_f (exec_return ==IGT_EXIT_SKIP , +"intel_l3_parity not supported\n" ); +igt_assert_eq (exec_return,IGT_EXIT_SUCCESS ); } igt_main
@@ -56,46 +61,54 @@ igt_main igt_subtest("sysfs_l3_parity") {int exec_return; +struct line_check line; +/* Sanity check that l3 parity tool is usable: Enable +* row,bank,subbank 0,0,0. +* +* TODO: Better way to find intel_l3_parity. This path +* is relative to piglit's path, when run through +* piglit. +*/ igt_system_cmd (exec_return,"../tools/intel_l3_parity -r 0 -b 0 " "-s 0 -e" ); -igt_skip_on_f (exec_return ==IGT_EXIT_SKIP , -"intel_l3_parity not supported\n" ); -igt_assert_eq (exec_return,IGT_EXIT_SUCCESS ); +assert_cmd_success (exec_return); +/* Disable row,bank,subbank 0,0,0. */ +igt_system_cmd (exec_return,"../tools/intel_l3_parity -r 0 -b 0 " +"-s 0 -d" ); +assert_cmd_success (exec_return); + +/* Check that disabling was successful */ igt_system_cmd (exec_return,"../tools/intel_l3_parity -l" ); -if (exec_return ==IGT_EXIT_SUCCESS ) { -struct line_check line; - line.substr ="Row 0, Bank 0, Subbank 0 is disabled" ; -igt_log_buffer_inspect (check_cmd_return_value, - &line); -igt_assert_eq (line.found, true); - } +assert_cmd_success (exec_return); + line.substr ="Row 0, Bank 0, Subbank 0 is disabled" ; + line.found =0 ; +igt_log_buffer_inspect (check_cmd_output, + &line); +igt_assert_eq (line.found,1 ); +/* Re-enable row,bank,subbank 0,0,0 */ igt_system_cmd (exec_return,"../tools/intel_l3_parity -r 0 -b 0 " "-s 0 -e" ); -igt_skip_on_f (exec_return ==IGT_EXIT_SKIP , -"intel_l3_parity not supported\n" ); -igt_assert_eq (exec_return,IGT_EXIT_SUCCESS ); +assert_cmd_success (exec_return); -/* Check that we can clear remaps: -* In the original shell script, the output of intel_l3_parity -l -* was piped thru wc -l to check if the tool would at least -* return a line. Just watch for one of the expected output -* string as an alternative. -* ("is disabled" unique only to intel_l3_parity.c:dumpit()) +/* Check that re-enabling was successful: +* intel_l3_parity -l should now not print that Row 0, +* Bank 0, Subbank 0 is disabled. +* +* The previously printed line is already in the log +* buffer so we check for count 1. */ -igt_system_cmd (exec_return, -"../tools/intel_l3_parity -l" ); -if (exec_return ==IGT_EXIT_SUCCESS ) { -struct line_check line; - line.substr ="is disabled" ; -igt_log_buffer_inspect (check_cmd_return_value, - &line); -igt_assert_eq (line.found, true); - } +igt_system_cmd (exec_return,"../tools/intel_l3_parity -l" ); +assert_cmd_success (exec_return); + line.substr ="Row 0, Bank 0, Subbank 0 is disabled" ; + line.found =0 ; +igt_log_buffer_inspect (check_cmd_output, + &line); +igt_assert_eq (line.found,1 ); } igt_subtest("tools_test") {
Signature · 6 lines
2.14.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 igt_core: Rework igt_system()
Instead of redirecting output to pipes and forking, redirect after forking to avoid having to carefully unredirect before logging anything.
igt@tools_test@sysfs_l3_parity had a racy condition where it prints the output of intel_l3_parity prepended by [cmd], but that ended up being printed again prepended by [cmd] because output was redirected, causing outputs to appear multiple times. This patch fixes that.
--- lib/igt_core.c | 115 ++++++++++++++++++++------------------------------------- 1 file changed, 40 insertions(+), 75 deletions(-)
lib/igt_core.c +40 -75
@@ -2237,58 +2237,23 @@ FILE *__igt_fopen_data(const char* igt_srcdir, const char* igt_datadir,return fp; } -struct output_pipe { -int output_fd; -int save_fd; -int read_fd; -int write_fd; -bool redirected; -enum igt_log_level log_level; -}; - -static bool redirect_output (struct output_pipe *p,int output_fd, -enum igt_log_level level) +static void log_output (int *fd,enum igt_log_level level) { -int fds[2 ]; - -if (pipe (fds) ==-1 ) - goto err; - -/* save output */ -if ((p->save_fd =dup (output_fd)) ==-1 ) - goto err; - -/* Redirect output to our buffer */ -if (dup2 (fds[1 ], output_fd) ==-1 ) - goto err; - - p->output_fd = output_fd; - p->read_fd = fds[0 ]; - p->write_fd = fds[1 ]; - p->redirected = true; - p->log_level = level; - -return true; -err: -close (fds[0 ]); -close (fds[1 ]); -close (p->save_fd); +ssize_t len; +char buf[PIPE_BUF ]; -return false; -} +if (*fd <0 ) +return ; -static void unredirect_output (struct output_pipe *p) -{ -if (!p->redirected) +memset (buf,0 ,sizeof (buf)); + len =read (*fd, buf,sizeof (buf)); +if (len <=0 ) { +close (*fd); + *fd =-1 ;return ; + } -/* read_fd is closed separately. We still need to read its -* buffered contents after un-redirecting the stream. -*/ -close (p->write_fd); -dup2 (p->save_fd, p->output_fd); -close (p->save_fd); - p->redirected = false; +igt_log (IGT_LOG_DOMAIN , level,"[cmd] %s" , buf); }/**
@@ -2304,48 +2269,48 @@ static void unredirect_output(struct output_pipe *p)*/ int igt_system (const char *command) { -#define OUT 0 -#define ERR 1 -struct output_pipe op[2 ]; -int i, status; +int outpipe[2 ] = {-1 ,-1 }; +int errpipe[2 ] = {-1 ,-1 }; +int status;struct igt_helper_process process = {}; -char buf[PIPE_BUF ]; -if (!redirect_output (&op[OUT ],STDOUT_FILENO ,IGT_LOG_INFO )) +if (pipe (outpipe) <0 ) goto err; -if (!redirect_output (&op[ERR ],STDERR_FILENO ,IGT_LOG_WARN )) +if (pipe (errpipe) <0 ) goto err; igt_fork_helper(&process) { -igt_assert (execl ("/bin/sh" ,"sh" ,"-c" , command, - (char *)NULL ) !=-1 ); +close (outpipe[0 ]); +close (errpipe[0 ]); + +if (dup2 (outpipe[1 ],STDOUT_FILENO ) <0 ) + goto child_err; +if (dup2 (errpipe[1 ],STDERR_FILENO ) <0 ) + goto child_err; + +execl ("/bin/sh" ,"sh" ,"-c" , command, + (char *)NULL ); + + child_err: +exit (EXIT_FAILURE ); } -for (i =0 ; i <ARRAY_SIZE (op); i++) { -struct output_pipe *current = &op[i]; +close (outpipe[1 ]); +close (errpipe[1 ]); -/* Unredirect so igt_log() works */ -unredirect_output (current); -memset (buf,0 ,sizeof (buf)); -while (read (current->read_fd, buf,sizeof (buf)) >0 ) { -igt_log (IGT_LOG_DOMAIN , current->log_level, -"[cmd] %s" , buf); -memset (buf,0 ,sizeof (buf)); - } -close (current->read_fd); +while (outpipe[0 ] >=0 || errpipe[0 ] >=0 ) { +log_output (&outpipe[0 ],IGT_LOG_INFO ); +log_output (&errpipe[0 ],IGT_LOG_WARN ); } + status =igt_wait_helper (&process);return WEXITSTATUS (status); err: -/* Failed to redirect one or both streams. Roll back changes. */ -for (i =0 ; i <ARRAY_SIZE (op); i++) { -if (!op[i].redirected) -continue ; -close (op[i].read_fd); -unredirect_output (&op[i]); - } - +close (outpipe[0 ]); +close (outpipe[1 ]); +close (errpipe[0 ]); +close (errpipe[1 ]);return -1 ; }
Signature · 6 lines
2.14.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH i-g-t 2/2] igt_core: Rework igt_system()
Quoted 11 lines · Petri Latvala
Instead of redirecting output to pipes and forking, redirect after forking to avoid having to carefully unredirect before logging anything.
igt@tools_test@sysfs_l3_parity had a racy condition where it prints the output of
intel_l3_parityprepended by [cmd], but that ended up being printed again prepended by [cmd] because output was redirected, causing outputs to appear multiple times. This patch fixes that.CC Abdiel Janulgue <[email protected]>Signed-off-by Petri Latvala <[email protected]>
Thanks for fixing this. Series is
Quoted 147 lines
--- lib/igt_core.c | 115 ++++++++++++++++++++------------------------------------- 1 file changed, 40 insertions(+), 75 deletions(-)lib/igt_core.c +36
-72@@ -2237,58 +2237,23 @@ FILE *__igt_fopen_data(const char* igt_srcdir, const char* igt_datadir,return fp; } -struct output_pipe { -int output_fd; -int save_fd; -int read_fd; -int write_fd; -bool redirected; -enum igt_log_level log_level; -}; - -static bool redirect_output (struct output_pipe *p,int output_fd, -enum igt_log_level level) +static void log_output (int *fd,enum igt_log_level level) { -int fds[2 ]; - -if (pipe (fds) ==-1 ) - goto err; - -/* save output */ -if ((p->save_fd =dup (output_fd)) ==-1 ) - goto err; - -/* Redirect output to our buffer */ -if (dup2 (fds[1 ], output_fd) ==-1 ) - goto err; - - p->output_fd = output_fd; - p->read_fd = fds[0 ]; - p->write_fd = fds[1 ]; - p->redirected = true; - p->log_level = level; - -return true; -err: -close (fds[0 ]); -close (fds[1 ]); -close (p->save_fd); +ssize_t len; +char buf[PIPE_BUF ]; -return false; -} +if (*fd <0 ) +return ; -static void unredirect_output (struct output_pipe *p) -{ -if (!p->redirected) +memset (buf,0 ,sizeof (buf)); + len =read (*fd, buf,sizeof (buf)); +if (len <=0 ) { +close (*fd); + *fd =-1 ;return ; + } -/* read_fd is closed separately. We still need to read its -* buffered contents after un-redirecting the stream. -*/ -close (p->write_fd); -dup2 (p->save_fd, p->output_fd); -close (p->save_fd); - p->redirected = false; +igt_log (IGT_LOG_DOMAIN , level,"[cmd] %s" , buf); }/** @@ -2304,48 +2269,48 @@ static void unredirect_output(struct output_pipe *p)*/ int igt_system (const char *command) { -#define OUT 0 -#define ERR 1 -struct output_pipe op[2 ]; -int i, status; +int outpipe[2 ] = {-1 ,-1 }; +int errpipe[2 ] = {-1 ,-1 }; +int status;struct igt_helper_process process = {}; -char buf[PIPE_BUF ]; -if (!redirect_output (&op[OUT ],STDOUT_FILENO ,IGT_LOG_INFO )) +if (pipe (outpipe) <0 ) goto err; -if (!redirect_output (&op[ERR ],STDERR_FILENO ,IGT_LOG_WARN )) +if (pipe (errpipe) <0 ) goto err; igt_fork_helper(&process) { -igt_assert (execl ("/bin/sh" ,"sh" ,"-c" , command, - (char *)NULL ) !=-1 ); +close (outpipe[0 ]); +close (errpipe[0 ]); + +if (dup2 (outpipe[1 ],STDOUT_FILENO ) <0 ) + goto child_err; +if (dup2 (errpipe[1 ],STDERR_FILENO ) <0 ) + goto child_err; + +execl ("/bin/sh" ,"sh" ,"-c" , command, + (char *)NULL ); + + child_err: +exit (EXIT_FAILURE ); } -for (i =0 ; i <ARRAY_SIZE (op); i++) { -struct output_pipe *current = &op[i]; +close (outpipe[1 ]); +close (errpipe[1 ]); -/* Unredirect so igt_log() works */ -unredirect_output (current); -memset (buf,0 ,sizeof (buf)); -while (read (current->read_fd, buf,sizeof (buf)) >0 ) { -igt_log (IGT_LOG_DOMAIN , current->log_level, -"[cmd] %s" , buf); -memset (buf,0 ,sizeof (buf)); - } -close (current->read_fd); +while (outpipe[0 ] >=0 || errpipe[0 ] >=0 ) { +log_output (&outpipe[0 ],IGT_LOG_INFO ); +log_output (&errpipe[0 ],IGT_LOG_WARN ); } + status =igt_wait_helper (&process);return WEXITSTATUS (status); err: -/* Failed to redirect one or both streams. Roll back changes. */ -for (i =0 ; i <ARRAY_SIZE (op); i++) { -if (!op[i].redirected) -continue ; -close (op[i].read_fd);
lib/igt_core.c static void unredirect_output(struct output_pipe *p) · line 2316
Quoted 10 lines
lib/igt_core.c +4
-3-unredirect_output (&op[i]); - } - +close (outpipe[0 ]); +close (outpipe[1 ]); +close (errpipe[0 ]); +close (errpipe[1 ]);return -1 ; }
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH i-g-t 2/2] igt_core: Rework igt_system()
Quoted 12 lines · Abdiel Janulgue
Quoted 9 lines · Petri Latvala
Instead of redirecting output to pipes and forking, redirect after forking to avoid having to carefully unredirect before logging anything.
igt@tools_test@sysfs_l3_parity had a racy condition where it prints the output of
intel_l3_parityprepended by [cmd], but that ended up being printed again prepended by [cmd] because output was redirected, causing outputs to appear multiple times. This patch fixes that.
Quoted 5 lines
Quoted 2 lines
CC Abdiel Janulgue <[email protected]>Signed-off-by Petri Latvala <[email protected]>Thanks for fixing this. Series is
Reviewed-by Abdiel Janulgue <[email protected]>
And pushed, thanks for the review.
The CI results were confirmed known noise.
Signature · 5 lines
Petri Latvala _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for series starting with [1/2] tools_test: Clean up and fix sysfs_l3_parity
In reply to Petri Latvala== Series Details ==
== Series Details ==
Series: series starting with [1/2] tools_test: Clean up and fix sysfs_l3_parity
URL : https://patchwork.freedesktop.org/series/30699/
State : success
== Summary ==
IGT patchset tested on top of latest successful build f86dc17cfc81f53f3bf216009ffda1ac05208bcc igt/prime_vgem: Split out the fine-grain coherency check
with latest DRM-Tip kernel build CI_DRM_311801a2040bb790 drm-tip: 2017y-09m-21d-13h-23m-06s UTC integration manifest
Test gem_exec_suspend:
Subgroup basic-s3:
pass -> INCOMPLETE (fi-kbl-7500u) fdo#102850
Test kms_cursor_legacy:
Subgroup basic-busy-flip-before-cursor-atomic:
fail -> PASS (fi-snb-2600) fdo#100215 +1
Test kms_pipe_crc_basic:
Subgroup read-crc-pipe-b:
dmesg-warn -> INCOMPLETE (fi-cfl-s) fdo#102294
Test drv_module_reload:
Subgroup basic-reload:
pass -> DMESG-WARN (fi-glk-1) fdo#102777fdo#102850 https://bugs.freedesktop.org/show_bug.cgi?id=102850
fdo#100215 https://bugs.freedesktop.org/show_bug.cgi?id=100215
fdo#102294 https://bugs.freedesktop.org/show_bug.cgi?id=102294
fdo#102777 https://bugs.freedesktop.org/show_bug.cgi?id=102777
fi-bdw-5557u total:289 pass:268 dwarn:0 dfail:0 fail:0 skip:21 time:441s fi-bdw-gvtdvm total:289 pass:265 dwarn:0 dfail:0 fail:0 skip:24 time:477s fi-blb-e6850 total:289 pass:224 dwarn:1 dfail:0 fail:0 skip:64 time:420s fi-bsw-n3050 total:289 pass:243 dwarn:0 dfail:0 fail:0 skip:46 time:518s fi-bwr-2160 total:289 pass:184 dwarn:0 dfail:0 fail:0 skip:105 time:277s fi-bxt-j4205 total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:514s fi-byt-j1900 total:289 pass:254 dwarn:1 dfail:0 fail:0 skip:34 time:499s fi-byt-n2820 total:289 pass:250 dwarn:1 dfail:0 fail:0 skip:38 time:503s fi-cfl-s total:241 pass:188 dwarn:24 dfail:0 fail:0 skip:28 fi-elk-e7500 total:289 pass:230 dwarn:0 dfail:0 fail:0 skip:59 time:427s fi-glk-1 total:289 pass:259 dwarn:1 dfail:0 fail:0 skip:29 time:569s fi-hsw-4770 total:289 pass:263 dwarn:0 dfail:0 fail:0 skip:26 time:427s fi-hsw-4770r total:289 pass:263 dwarn:0 dfail:0 fail:0 skip:26 time:411s fi-ilk-650 total:289 pass:229 dwarn:0 dfail:0 fail:0 skip:60 time:439s fi-ivb-3520m total:289 pass:261 dwarn:0 dfail:0 fail:0 skip:28 time:496s fi-ivb-3770 total:289 pass:261 dwarn:0 dfail:0 fail:0 skip:28 time:469s fi-kbl-7500u total:118 pass:100 dwarn:1 dfail:0 fail:0 skip:16 fi-kbl-7560u total:289 pass:270 dwarn:0 dfail:0 fail:0 skip:19 time:575s fi-kbl-r total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:592s fi-pnv-d510 total:289 pass:223 dwarn:1 dfail:0 fail:0 skip:65 time:546s fi-skl-6260u total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:451s fi-skl-6700k total:289 pass:265 dwarn:0 dfail:0 fail:0 skip:24 time:756s fi-skl-6770hq total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:494s fi-skl-gvtdvm total:289 pass:266 dwarn:0 dfail:0 fail:0 skip:23 time:474s fi-snb-2520m total:289 pass:251 dwarn:0 dfail:0 fail:0 skip:38 time:581s fi-snb-2600 total:289 pass:249 dwarn:0 dfail:0 fail:1 skip:39 time:421s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_237/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.IGT: warning for series starting with [1/2] tools_test: Clean up and fix sysfs_l3_parity
In reply to Petri Latvala== Series Details ==
== Series Details ==
Series: series starting with [1/2] tools_test: Clean up and fix sysfs_l3_parity
URL : https://patchwork.freedesktop.org/series/30699/
State : warning
== Summary ==
Test gem_eio:
Subgroup throttle:
pass -> DMESG-WARN (shard-hsw)
Subgroup execbuf:
dmesg-warn -> PASS (shard-hsw)
Subgroup in-flight:
pass -> DMESG-WARN (shard-hsw) fdo#102886
Test tools_test:
Subgroup sysfs_l3_parity:
fail -> PASS (shard-hsw) fdo#101650
Test kms_busy:
Subgroup extended-modeset-hang-oldfb-with-reset-render-A:
pass -> DMESG-WARN (shard-hsw)
Test drv_module_reload:
Subgroup basic-no-display:
dmesg-warn -> PASS (shard-hsw)
Test kms_flip:
Subgroup wf_vblank-vs-modeset-interruptible:
pass -> DMESG-WARN (shard-hsw)
Test perf:
Subgroup polling:
fail -> PASS (shard-hsw) fdo#102252fdo#102886 https://bugs.freedesktop.org/show_bug.cgi?id=102886
fdo#101650 https://bugs.freedesktop.org/show_bug.cgi?id=101650
fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252
shard-hsw total:2429 pass:1332 dwarn:6 dfail:0 fail:8 skip:1083 time:9764s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_237/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx