summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2017-06-07 13:52:59 -0600
committerBrian Paul <brianp@vmware.com>2017-06-12 06:25:03 -0600
commit5aeb0136c14b5b7dbad5eef336d40d352a780515 (patch)
tree515cf6cb5f5947b575e544f411a3f05499517987
parentbc6ef16dfa432c181e3c0e44223a651e3ea50f76 (diff)
util: fix Cygwin stdout/stderr buffering
Using Cywin on Windows, printf() to stdout/stderr aren't immediately flushed. So Piglit messages about failed pixel probes, etc. don't appear until the test exits. This patch calls setbuf() to disable buffering so the output appears right away. Refactor the init code a bit to avoid calling setbuf() from some arbitrary place otherwise. Reviewed-by: Neha Bhende<bhenden@vmware.com> Reviewed-by: José Fonseca <jfonseca@vmware.com>
-rw-r--r--tests/util/piglit-framework-gl.h2
-rw-r--r--tests/util/piglit-util.c24
-rw-r--r--tests/util/piglit-util.h2
3 files changed, 25 insertions, 3 deletions
diff --git a/tests/util/piglit-framework-gl.h b/tests/util/piglit-framework-gl.h
index 992f28a05..970fd5502 100644
--- a/tests/util/piglit-framework-gl.h
+++ b/tests/util/piglit-framework-gl.h
@@ -271,7 +271,7 @@ piglit_gl_test_run(int argc, char *argv[],
{ \
struct piglit_gl_test_config config; \
\
- piglit_disable_error_message_boxes(); \
+ piglit_general_init(); \
\
piglit_gl_test_config_init(&config); \
\
diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
index 6b34c46f8..15a178b08 100644
--- a/tests/util/piglit-util.c
+++ b/tests/util/piglit-util.c
@@ -317,7 +317,7 @@ piglit_report_subtest_result(enum piglit_result result, const char *format, ...)
}
-void
+static void
piglit_disable_error_message_boxes(void)
{
/* When Windows' error message boxes are disabled for this process (as
@@ -354,6 +354,28 @@ piglit_disable_error_message_boxes(void)
}
+static void
+piglit_set_line_buffering(void)
+{
+ /* Windows doesn't immediately flush stdout/stderr after printf
+ * calls as we see on Linux. To get immediate flushing, we disable
+ * buffering here.
+ */
+#ifdef _WIN32
+ setbuf(stdout, NULL);
+ setbuf(stderr, NULL);
+#endif
+}
+
+
+void
+piglit_general_init(void)
+{
+ piglit_disable_error_message_boxes();
+ piglit_set_line_buffering();
+}
+
+
void
piglit_set_rlimit(unsigned long lim)
{
diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h
index b30ae0784..ad00817a1 100644
--- a/tests/util/piglit-util.h
+++ b/tests/util/piglit-util.h
@@ -414,7 +414,7 @@ void piglit_set_timeout(double seconds, enum piglit_result timeout_result);
void piglit_report_subtest_result(enum piglit_result result,
const char *format, ...) PRINTFLIKE(2, 3);
-void piglit_disable_error_message_boxes(void);
+void piglit_general_init(void);
extern void piglit_set_rlimit(unsigned long lim);