Disable stdout buffering for LOG() when running tests

Normally the test runners run in 'forking mode'. When a lot of
messages are logged to stdout, the child process can still be writing
data when the parent writes 'ok' or 'not ok'. This can confuse
the tap-driver.sh process.
This commit is contained in:
matt335672 2023-01-09 12:58:38 +00:00
parent 1fbcdffff1
commit 57bd1be5b1
5 changed files with 19 additions and 0 deletions

View File

@ -3,6 +3,7 @@
#include "config_ac.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include "log.h"
@ -58,6 +59,9 @@ int main (void)
struct log_config *lc = log_config_init_for_console(LOG_LEVEL_INFO, NULL);
log_start_from_param(lc);
log_config_free(lc);
/* Disable stdout buffering, as this can confuse the error
* reporting when running in libcheck fork mode */
setvbuf(stdout, NULL, _IONBF, 0);
/* Initialise the ssl module */
ssl_init();

View File

@ -3,6 +3,7 @@
#include "config_ac.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include "log.h"
@ -177,6 +178,9 @@ int main (void)
struct log_config *lc = log_config_init_for_console(LOG_LEVEL_INFO, NULL);
log_start_from_param(lc);
log_config_free(lc);
/* Disable stdout buffering, as this can confuse the error
* reporting when running in libcheck fork mode */
setvbuf(stdout, NULL, _IONBF, 0);
/* Initialise modules */
suite_test_libipm_calls_start();

View File

@ -2,6 +2,7 @@
#include "config_ac.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <check.h>
#include "log.h"
@ -22,6 +23,9 @@ int main (void)
struct log_config *lc = log_config_init_for_console(LOG_LEVEL_INFO, NULL);
log_start_from_param(lc);
log_config_free(lc);
/* Disable stdout buffering, as this can confuse the error
* reporting when running in libcheck fork mode */
setvbuf(stdout, NULL, _IONBF, 0);
srunner_run_all (sr, CK_ENV);
number_failed = srunner_ntests_failed(sr);

View File

@ -26,6 +26,9 @@ int main(int argc, char **argv)
config = log_config_init_for_console(LOG_LEVEL_DEBUG, NULL);
log_start_from_param(config);
log_config_free(config);
/* Disable stdout buffering, as this can confuse the error
* reporting when running in libcheck fork mode */
setvbuf(stdout, NULL, _IONBF, 0);
srand(time(0));
obj = libmem_init(0x80000000, 64 * 1024 * 1024);

View File

@ -33,6 +33,7 @@
#include "log.h"
#include "os_calls.h"
#include <stdio.h>
#include <stdlib.h>
#include "test_xrdp.h"
@ -49,6 +50,9 @@ int main (void)
g_getenv("TEST_LOG_LEVEL"));
log_start_from_param(logging);
log_config_free(logging);
/* Disable stdout buffering, as this can confuse the error
* reporting when running in libcheck fork mode */
setvbuf(stdout, NULL, _IONBF, 0);
sr = srunner_create (make_suite_test_bitmap_load());
srunner_add_suite(sr, make_suite_egfx_base_functions());