From: Alexander Kanavin <alex.kanavin@gmail.com>
To: yocto@yoctoproject.org, anibal.limon@linaro.org
Subject: [ptest-runner] Run ptests via stdbuf configured to line-buffering
Date: Thu, 4 Apr 2019 18:00:15 +0200 [thread overview]
Message-ID: <20190404160015.39306-1-alex.kanavin@gmail.com> (raw)
As ptest-runner communicates with child processes via pipe2(),
the corresponding channels are not attached to a pty. In that
situation stdio facilities like printf() or fwrite() are fully
buffered. If a ptest would use them, without bothering
to fflush() the output, ptest-runner will only receive what
was written by the child ptest process after a buffer gets filled.
If the unit tests are proceeding slowly, this may mean that
ptest-runner will erroneously timeout due to an apparent lack of
'signs of life' from the child process.
stdbuf utility from coreutils adjusts the buffering to a line-buffered
one, and so ptest-runner will get the lines as soon as they are
written.
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
---
utils.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/utils.c b/utils.c
index 504df0b..1376e39 100644
--- a/utils.c
+++ b/utils.c
@@ -243,16 +243,13 @@ filter_ptests(struct ptest_list *head, char **ptests, int ptest_num)
static inline void
run_child(char *run_ptest, int fd_stdout, int fd_stderr)
{
- char **argv = malloc(sizeof(char) * 2);
+ char* argv[] = {"stdbuf", "-oL", "-eL", "./run-ptest", NULL};
chdir(dirname(strdup(run_ptest)));
- argv[0] = run_ptest;
- argv[1] = NULL;
-
dup2(fd_stdout, STDOUT_FILENO);
// XXX: Redirect stderr to stdout to avoid buffer ordering problems.
dup2(fd_stdout, STDERR_FILENO);
- execv(run_ptest, argv);
+ execvp(argv[0], argv);
exit(1);
}
--
2.17.1
next reply other threads:[~2019-04-04 16:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-04 16:00 Alexander Kanavin [this message]
2019-04-04 17:31 ` [ptest-runner] Run ptests via stdbuf configured to line-buffering Joshua Watt
2019-04-04 21:48 ` Richard Purdie
2019-04-05 6:16 ` Mikko.Rapeli
2019-04-05 6:46 ` richard.purdie
2019-04-05 6:54 ` Mikko.Rapeli
2019-04-05 6:59 ` richard.purdie
2019-04-05 7:04 ` Mikko.Rapeli
-- strict thread matches above, loose matches on Subject: below --
2019-04-04 15:34 Alexander Kanavin
2019-04-04 15:41 ` Alexander Kanavin
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=20190404160015.39306-1-alex.kanavin@gmail.com \
--to=alex.kanavin@gmail.com \
--cc=anibal.limon@linaro.org \
--cc=yocto@yoctoproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.