[U-Boot] [PATCH V2 3/7] test/py: add test of setenv/printenv/echo
Michal Simek
monstr at monstr.eu
Mon Jan 4 09:36:37 CET 2016
On 18.12.2015 19:09, Stephen Warren wrote:
> 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 <swarren at wwwdotorg.org>
>>> Signed-off-by: Stephen Warren <swarren at nvidia.com>
>>> ---
>>> 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)
>
That works for me.
Thanks,
Michal
--
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160104/6cd7e3dc/attachment.sig>
More information about the U-Boot
mailing list