Blob Blame History Raw
commit 5c0202af4b3d588c04bcec7baf05706b21cd7416
Author: Florian Weimer <fweimer@redhat.com>
Date:   Tue Jun 26 12:05:21 2018 +0200

    support: Add TEST_NO_SETVBUF
    
    This is sometimes needed for testing stdio streams, where the
    setvbuf call in the test driver could interfere with the test.

diff --git a/support/support_test_main.c b/support/support_test_main.c
index 396385729b6809ad..23429779aca85613 100644
--- a/support/support_test_main.c
+++ b/support/support_test_main.c
@@ -270,7 +270,8 @@ support_test_main (int argc, char **argv, const struct test_config *config)
     timeout =  DEFAULT_TIMEOUT;
 
   /* Make sure we see all message, even those on stdout.  */
-  setvbuf (stdout, NULL, _IONBF, 0);
+  if (!config->no_setvbuf)
+    setvbuf (stdout, NULL, _IONBF, 0);
 
   /* Make sure temporary files are deleted.  */
   if (support_delete_temp_files != NULL)
diff --git a/support/test-driver.c b/support/test-driver.c
index 09c8783e4f54d809..9798f16227b9d467 100644
--- a/support/test-driver.c
+++ b/support/test-driver.c
@@ -140,6 +140,10 @@ main (int argc, char **argv)
   test_config.no_mallopt = 1;
 #endif
 
+#ifdef TEST_NO_SETVBUF
+  test_config.no_setvbuf = 1;
+#endif
+
 #ifdef TIMEOUT
   test_config.timeout = TIMEOUT;
 #endif
diff --git a/support/test-driver.h b/support/test-driver.h
index 1708d68d608ee4a4..549179b254946390 100644
--- a/support/test-driver.h
+++ b/support/test-driver.h
@@ -35,6 +35,7 @@ struct test_config
   int expected_status;   /* Expected exit status.  */
   int expected_signal;   /* If non-zero, expect termination by signal.  */
   char no_mallopt;       /* Boolean flag to disable mallopt.  */
+  char no_setvbuf;       /* Boolean flag to disable setvbuf.  */
   const char *optstring; /* Short command line options.  */
 };