public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: Zorro Lang <zlang@kernel.org>
To: fstests@vger.kernel.org
Subject: [PATCH v2 3/5] generic/591: remove redundant output from golden image
Date: Wed,  1 Jun 2022 14:37:28 +0800	[thread overview]
Message-ID: <20220601063730.1726879-4-zlang@kernel.org> (raw)
In-Reply-To: <20220601063730.1726879-1-zlang@kernel.org>

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:

  10554 execve("/root/git/xfstests/src/splice-test", ["/root/git/xfstests/src/splice-te"..., "-r", "/mnt/test/a"], 0x7ffcabc2c0a8 /* 202 vars */) = 0
  ...
  10554 clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f937f5d5a10) = 10555
  ...
  10555 read(4, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"..., 512) = 512
  10555 write(1, "concurrent reader with O_DIRECT\n", 32) = 32
  10555 exit_group(0)                     = ?
  10555 +++ exited with 0 +++
  10554 <... wait4 resumed>NULL, 0, NULL) = 10555
  10554 --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=10555, si_uid=0, si_status=0, si_utime=0, si_stime=1} ---
  10554 unlink("/mnt/test/a")             = 0
  10554 write(1, "concurrent reader with O_DIRECT\n", 32) = 32
  10554 exit_group(0)                     = ?
  10554 +++ exited with 0 +++

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>
---
 src/splice-test.c     | 2 ++
 tests/generic/591.out | 2 --
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/splice-test.c b/src/splice-test.c
index 2f1ba2ba..dc41b0f5 100644
--- a/src/splice-test.c
+++ b/src/splice-test.c
@@ -140,6 +140,8 @@ int main(int argc, char *argv[])
 		usage(argv[0]);
 	filename = argv[optind];
 
+	/* force below printf line buffered */
+	setlinebuf(stdout);
 	printf("%s reader %s O_DIRECT\n",
 		   do_splice == do_splice1 ? "sequential" : "concurrent",
 		   (open_flags & O_DIRECT) ? "with" : "without");
diff --git a/tests/generic/591.out b/tests/generic/591.out
index d61811ee..e9fffd1d 100644
--- a/tests/generic/591.out
+++ b/tests/generic/591.out
@@ -1,7 +1,5 @@
 QA output created by 591
 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
-- 
2.31.1


  parent reply	other threads:[~2022-06-01  6:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-01  6:37 [PATCH v2 0/5] random fixes for fstests Zorro Lang
2022-06-01  6:37 ` [PATCH v2 1/5] generic/139: require 512 bytes to be the minimum dio size Zorro Lang
2022-06-01 17:32   ` Darrick J. Wong
2022-06-02  5:17     ` [PATCH v3] " Zorro Lang
2022-06-02 16:40       ` Darrick J. Wong
2022-06-02 19:13         ` Zorro Lang
2022-06-01  6:37 ` [PATCH v2 2/5] generic/506: call _require_quota before _qmount Zorro Lang
2022-06-01 17:35   ` Darrick J. Wong
2022-06-01  6:37 ` Zorro Lang [this message]
2022-06-01 17:38   ` [PATCH v2 3/5] generic/591: remove redundant output from golden image Darrick J. Wong
2022-06-01  6:37 ` [PATCH v2 4/5] generic/591: use proper sector size Zorro Lang
2022-06-01 17:41   ` Darrick J. Wong
2022-06-01  6:37 ` [PATCH v2 5/5] gitignore: ignore missed binary files in src Zorro Lang
2022-06-01 17:42   ` Darrick J. Wong
2022-06-02  5:03     ` Zorro Lang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220601063730.1726879-4-zlang@kernel.org \
    --to=zlang@kernel.org \
    --cc=fstests@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox