All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] test_env: don't strip() printenv results
@ 2019-12-18 18:37 Stephen Warren
  2020-01-02 23:11 ` Tom Rini
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Warren @ 2019-12-18 18:37 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

get_env() was originally written to strip() the output of printenv to
isolate the test from any whitespace changes in printenv's output.
However, this throws away any whitespace in the variable value, which can
cause issues when test code expects to see that whitespace. In fact,
printenv never adds any whitespace at all, so there's no need to strip.

The strip causes a practical problem for test_env_echo_exists() if
state_test_env.get_existent_var() happens to choose a U-Boot variable that
contains trailing whitespace. This is true for variable boot_targets.

With Python 2, get_existent_var() never returned boot_targets so this
issue never caused a practical problem.

With Python 3, get_existent_var does sometimes return boot_targets, no
doubt due to Python 3's different dict hash key order implementation,
about 0.5-2% of the time, so this test appears intermittent. With the
strip removed, this intermittency is solved, since the test passes for all
possible U-Boot variables.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 test/py/tests/test_env.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py
index 9bdaef9373fd..6ff38f1020b5 100644
--- a/test/py/tests/test_env.py
+++ b/test/py/tests/test_env.py
@@ -49,7 +49,7 @@ class StateTestEnv(object):
         for l in response.splitlines():
             if not '=' in l:
                 continue
-            (var, value) = l.strip().split('=', 1)
+            (var, value) = l.split('=', 1)
             self.env[var] = value
 
     def get_existent_var(self):
-- 
2.24.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] test_env: don't strip() printenv results
  2019-12-18 18:37 [PATCH] test_env: don't strip() printenv results Stephen Warren
@ 2020-01-02 23:11 ` Tom Rini
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2020-01-02 23:11 UTC (permalink / raw)
  To: u-boot

On Wed, Dec 18, 2019 at 11:37:21AM -0700, Stephen Warren wrote:

> From: Stephen Warren <swarren@nvidia.com>
> 
> get_env() was originally written to strip() the output of printenv to
> isolate the test from any whitespace changes in printenv's output.
> However, this throws away any whitespace in the variable value, which can
> cause issues when test code expects to see that whitespace. In fact,
> printenv never adds any whitespace at all, so there's no need to strip.
> 
> The strip causes a practical problem for test_env_echo_exists() if
> state_test_env.get_existent_var() happens to choose a U-Boot variable that
> contains trailing whitespace. This is true for variable boot_targets.
> 
> With Python 2, get_existent_var() never returned boot_targets so this
> issue never caused a practical problem.
> 
> With Python 3, get_existent_var does sometimes return boot_targets, no
> doubt due to Python 3's different dict hash key order implementation,
> about 0.5-2% of the time, so this test appears intermittent. With the
> strip removed, this intermittency is solved, since the test passes for all
> possible U-Boot variables.
> 
> Signed-off-by: Stephen Warren <swarren@nvidia.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200102/84f3669c/attachment.sig>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-01-02 23:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-18 18:37 [PATCH] test_env: don't strip() printenv results Stephen Warren
2020-01-02 23:11 ` Tom Rini

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.