generic/591: remove redundant output from golden image
In generic/591.out expects below output:
concurrent reader with O_DIRECT
concurrent reader with O_DIRECT <=== ???
concurrent reader without O_DIRECT
concurrent reader without O_DIRECT <=== ???
sequential reader with O_DIRECT
sequential reader without O_DIRECT
The lines marked "???" are unbelievable, due to the src/splice-test.c
only calls printf to output that message once in main function. So
Why splice-test prints that message twice sometimes? It seems related
with the "-r" option, due to the test lines without "-r" option only
print one line each time running.
A stanger thing is this "double output" issue only can be triggered by
running g/591, can't reproduce it by running splice-test manually.
By checking the code of splice-test.c, I found a "fork()" in it, and
it'll be called if the '-r' option is specified. So I suspect the
redundant output come from the child process. By the help of strace
tool, I got:
We can see the "concurrent reader with O_DIRECT\n" be printed by
parent process 10554 and child process 10555 separately.
Due to the stdout redirection that fstests does cause the stream
doesn't refer to a tty anymore, then the stdout become block
buffered, so the '\n' doesn't help to flush that printf message,
and the child print it again.
So use setlinebuf(stdout) to force it line buffered, to avoid the
confused output to be golden image. Then correct the generic/591.out
Signed-off-by: Zorro Lang <zlang@kernel.org> Reviewed-by: Darrick J. Wong <djwong@kernel.org>