<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<meta content="text/html; charset=UTF-8">
<style type="text/css" style="">
<!--
p
{margin-top:0;
margin-bottom:0}
-->
</style>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Looks good to me.</p>
<p><br>
</p>
<p>Reviewed-by: Neha Bhende<bhenden@vmware.com></p>
<p><br>
</p>
<div id="x_Signature">
<div id="x_divtagdefaultwrapper" style="font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255); font-family:Calibri,Arial,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<p>Regards,</p>
<p>Neha<br>
</p>
</div>
</div>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Brian Paul <brianp@vmware.com><br>
<b>Sent:</b> Wednesday, June 7, 2017 1:17:19 PM<br>
<b>To:</b> piglit@lists.freedesktop.org<br>
<b>Cc:</b> Charmaine Lee; Neha Bhende; Brian Paul<br>
<b>Subject:</b> [PATCH] util: fix Windows stdout/stderr buffering</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">Windows doesn't immediately flush stdout/stderr after printf().<br>
Use setbuf() to disable buffering on Windows.<br>
<br>
Refactor the init code a bit to avoid calling setbuf() from some<br>
arbitrary place otherwise.<br>
---<br>
tests/util/piglit-framework-gl.h | 2 +-<br>
tests/util/piglit-util.c | 24 +++++++++++++++++++++++-<br>
tests/util/piglit-util.h | 2 +-<br>
3 files changed, 25 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/tests/util/piglit-framework-gl.h b/tests/util/piglit-framework-gl.h<br>
index 992f28a..970fd55 100644<br>
--- a/tests/util/piglit-framework-gl.h<br>
+++ b/tests/util/piglit-framework-gl.h<br>
@@ -271,7 +271,7 @@ piglit_gl_test_run(int argc, char *argv[],<br>
{ \<br>
struct piglit_gl_test_config config; \<br>
\<br>
- piglit_disable_error_message_boxes(); \<br>
+ piglit_general_init(); \<br>
\<br>
piglit_gl_test_config_init(&config); \<br>
\<br>
diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c<br>
index 6b34c46..15a178b 100644<br>
--- a/tests/util/piglit-util.c<br>
+++ b/tests/util/piglit-util.c<br>
@@ -317,7 +317,7 @@ piglit_report_subtest_result(enum piglit_result result, const char *format, ...)<br>
}<br>
<br>
<br>
-void<br>
+static void<br>
piglit_disable_error_message_boxes(void)<br>
{<br>
/* When Windows' error message boxes are disabled for this process (as<br>
@@ -354,6 +354,28 @@ piglit_disable_error_message_boxes(void)<br>
}<br>
<br>
<br>
+static void<br>
+piglit_set_line_buffering(void)<br>
+{<br>
+ /* Windows doesn't immediately flush stdout/stderr after printf<br>
+ * calls as we see on Linux. To get immediate flushing, we disable<br>
+ * buffering here.<br>
+ */<br>
+#ifdef _WIN32<br>
+ setbuf(stdout, NULL);<br>
+ setbuf(stderr, NULL);<br>
+#endif<br>
+}<br>
+<br>
+<br>
+void<br>
+piglit_general_init(void)<br>
+{<br>
+ piglit_disable_error_message_boxes();<br>
+ piglit_set_line_buffering();<br>
+}<br>
+<br>
+<br>
void<br>
piglit_set_rlimit(unsigned long lim)<br>
{<br>
diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h<br>
index b30ae07..ad00817 100644<br>
--- a/tests/util/piglit-util.h<br>
+++ b/tests/util/piglit-util.h<br>
@@ -414,7 +414,7 @@ void piglit_set_timeout(double seconds, enum piglit_result timeout_result);<br>
void piglit_report_subtest_result(enum piglit_result result,<br>
const char *format, ...) PRINTFLIKE(2, 3);<br>
<br>
-void piglit_disable_error_message_boxes(void);<br>
+void piglit_general_init(void);<br>
<br>
extern void piglit_set_rlimit(unsigned long lim);<br>
<br>
-- <br>
1.9.1<br>
<br>
</div>
</span></font>
</body>
</html>