Re: [PATCH 0/5] firmware: Add support for loading compressed files

From: Kees Cook
Date: Mon May 20 2019 - 17:52:34 EST


On Mon, May 20, 2019 at 08:59:14PM +0200, Takashi Iwai wrote:
> So the problem is obvious: the commit above adjusts the stdout to be
> unbuffered via stdbuf, hence each invocation like
> echo -n abc > /sys/....
>
> would become writes of "a", "b" and "c", instead of "abc".
>
> Although we can work around it in each test unit, I'm afraid that
> enforcing the unbuffered stdio is too fragile for scripts like the
> above case.

Oh this is nasty. Looks like stdbuf overrides all child processes too...
yeah, that's very broken. Let me try to see if I can find an
alternative.

Shuah, in the meantime, if you want a fix to restore test behavior,
but regress output flushing, this will work:

diff --git a/tools/testing/selftests/kselftest/runner.sh b/tools/testing/selftests/kselftest/runner.sh
index eff3ee303d0d..a529c19240fc 100644
--- a/tools/testing/selftests/kselftest/runner.sh
+++ b/tools/testing/selftests/kselftest/runner.sh
@@ -27,11 +27,11 @@ tap_prefix()
# If stdbuf is unavailable, we must fall back to line-at-a-time piping.
tap_unbuffer()
{
- if ! which stdbuf >/dev/null ; then
+ #if ! which asdfstdbuf >/dev/null ; then
"$@"
- else
- stdbuf -i0 -o0 -e0 "$@"
- fi
+ #else
+ # stdbuf -i0 -o0 -e0 "$@"
+ #fi
}

run_one()

Some tests will no longer show their output until they're entirely done,
but at least no test pass/fail results should regress.

I'll keep looking at solutions...

--
Kees Cook