Skip to content

Commit

Permalink
test_env: don't strip() printenv results
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
nvswarren authored and trini committed Jan 2, 2020
1 parent e852b30 commit fc1a3bf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion test/py/tests/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def get_env(self):
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):
Expand Down

0 comments on commit fc1a3bf

Please sign in to comment.