Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stdout and stderr outputs could be messed up #13

Open
GoogleCodeExporter opened this issue Dec 8, 2015 · 0 comments
Open

stdout and stderr outputs could be messed up #13

GoogleCodeExporter opened this issue Dec 8, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. compile the standard cmockery example 'assert_macro_test.exe' on Windows
2. execute "assert_macro_test.exe 1>output 2>&1"

What is the expected output? What do you see instead?

The file "output" should contain:

get_status_code_string_test: Starting test
"Connection dropped" != "Connection timed out"
ERROR: ..\src\example\assert_macro_test.c:29 Failure!
get_status_code_string_test: Test failed.
string_to_status_code_test: Starting test
0x2 != 0x1
ERROR: ..\src\example\assert_macro_test.c:35 Failure!
string_to_status_code_test: Test failed.
2 out of 2 tests failed!
    get_status_code_string_test
    string_to_status_code_test

but it contains:

get_status_code_string_test: Starting test
get_status_code_string_test: Test failed.
string_to_status_code_test: Starting test
string_to_status_code_test: Test failed.
"Connection dropped" != "Connection timed out"
ERROR: ..\src\example\assert_macro_test.c:29 Failure!
0x2 != 0x1
ERROR: ..\src\example\assert_macro_test.c:35 Failure!
2 out of 2 tests failed!
    get_status_code_string_test
    string_to_status_code_test

What version of the product are you using? On what operating system?

1. cmockery 0.1.2
2. Windows XP SP3
3. Visual Studio 2008

Please provide any additional information below.

fflush() function should be called after each line printed to the stdout or 
stderr.

The patch below fixes this problem:

--- cmockery.c  Sat Aug 30 02:55:54 2008
+++ cmockery.c  Tue Jul 21 10:24:14 2009
@@ -1449,6 +1449,7 @@
    char buffer[1024];
    vsnprintf(buffer, sizeof(buffer), format, args);
    printf(buffer);
+   fflush(stdout);
 #ifdef _WIN32
    OutputDebugString(buffer);
 #endif // _WIN32
@@ -1459,6 +1460,7 @@
    char buffer[1024];
    vsnprintf(buffer, sizeof(buffer), format, args);
    fprintf(stderr, buffer);
+   fflush(stderr);
 #ifdef _WIN32
    OutputDebugString(buffer);
 #endif // _WIN32

Original issue reported on code.google.com by ade...@gmail.com on 21 Jul 2009 at 10:39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant