[Toybox] [PATCH] More line buffering.

enh enh at google.com
Mon Apr 26 15:46:33 PDT 2021


to me this is another argument why unbuffered shouldn't be the default, but
"echo is at least line buffered" is the minimum i need to avoid the xargs
test flake, so that's all i'm going for today :-)

it's guessable from the mention of xargs, echo, and parallelism, but it was
an accident that i forgot to include the specific failure i was seeing, so
for completeness:

FAIL: xargs max-proc=2
echo -ne 'y\ny\ny\n' | xargs -n 1 -P 2
--- expected 2021-04-24 14:46:41.511976909 +0000
+++ actual 2021-04-24 14:46:41.551976908 +0000
@@ -1,3 +1,3 @@
+yy
+
 y
-y
-y


On Mon, Apr 26, 2021 at 3:43 PM enh <enh at google.com> wrote:

> This patch does two things:
>
> 1. Enable line buffering for echo and yes. I found this through test
>    flakiness from the toybox xargs tests running in CI on devices where
>    "echo" is provided by toybox. For `echo y`, GNU echo does one write
>    of "y\n" but toybox echo was doing two writes, which makes it more
>    likely (4% on the heavily-loaded CI machines) for writes from the two
>    processes to be interleaved.
>
> 2. Fix line buffering on glibc if you're calling `toybox foo` rather
>    than `foo`. Otherwise we come through once and switch to unbuffered
>    mode, then again and switch to line buffered mode --- which doesn't
>    seem to actually work in glibc unless you specify a buffer (so
>    passing toybuf and sizeof(toybuf) works, but NULL and 0 doesn't).
>
> I hit the second issue trying to reproduce the first issue on the desktop
> rather than on Android.
>
> (If you're scratching your head wondering "why yes(1) too, not just
> echo(1)?", that represents a blind alley I went down when I mistook
> which tool was in use. It seemed like the same principle should apply,
> and it matches what other implementations do.)
> ---
>  main.c            | 2 +-
>  toys/other/yes.c  | 2 +-
>  toys/posix/echo.c | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20210426/e731aa6c/attachment-0001.htm>


More information about the Toybox mailing list