From: Stephen Warren Date: Fri, 18 Dec 2015 11:09:04 -0700 Subject: [U-Boot] [PATCH V2 3/7] test/py: add test of setenv/printenv/echo In-Reply-To: <56740F12.4070101@monstr.eu> References: <1449094708-14784-1-git-send-email-swarren@wwwdotorg.org> <1449094708-14784-3-git-send-email-swarren@wwwdotorg.org> <56740F12.4070101@monstr.eu> Message-ID: <56744BC0.1010002@wwwdotorg.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 12/18/2015 06:50 AM, Michal Simek wrote: > On 2.12.2015 23:18, Stephen Warren wrote: >> This tests basic environment variable functionality. >> >> Signed-off-by: Stephen Warren >> Signed-off-by: Stephen Warren >> --- >> test/py/test_env.py | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 121 insertions(+) >> create mode 100644 test/py/test_env.py >> >> diff --git a/test/py/test_env.py b/test/py/test_env.py >> new file mode 100644 >> index 000000000000..3af0176c4523 >> --- /dev/null >> +++ b/test/py/test_env.py >> @@ -0,0 +1,121 @@ >> +# Copyright (c) 2015 Stephen Warren >> +# Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved. >> +# >> +# SPDX-License-Identifier: GPL-2.0 >> + >> +import pytest >> + >> +# FIXME: This might be useful for other tests; >> +# perhaps refactor it into ConsoleBase or some other state object? >> +class StateTestEnv(object): >> + def __init__(self, uboot_console): >> + self.uboot_console = uboot_console >> + self.get_env() >> + self.set_var = self.get_non_existent_var() >> + >> + def get_env(self): >> + response = self.uboot_console.run_command("printenv") >> + self.env = {} >> + for l in response.splitlines(): >> + if not "=" in l: >> + continue >> + (var, value) = l.strip().split("=") > > Please keep in your mind - I haven't written anything in python. > This is failing on my testing platform. On microblaze I have variable > which is defined like "console=console=ttyUL0,115200\0" and this script > is not able to handle it properly. > I expect it is because of two = on the same line. Ah yes. Try: - (var, value) = l.strip().split("=") + (var, value) = l.strip().split("=", 1)