2

I am wring the unit testcases to validate one C library function by using google test framework. Sample code:

TEST_P(xyzTestCase, xyzfunc)
{
    int a = xyz(2);
    .....
    ......
    EXPECT_GT(a, 1);
}

library function xyz has some print statement, which I cannot remove. Whenever, I am running this test, it is printing those statement as expected.

I have added below piece of code after the function call xyz():

char buff[100000]; 
memset( buff, '\0', sizeof(buff));
setvbuf(stdout, buff, _IOFBF, sizeof(buff)-1);
fflush(stdout);  

After adding these code, output are getting suppressed, except for first run. This is parametrized test and running multiple times. First time, output is displaying after that output are getting suppressed.

Can anyone please suggest me what is the reason for that? Why output are not suppressed first time? Please suggest.

0 Answers0