diff mbox

[U-Boot,v1,02/12] tests: py: disable main_signon check for printenv cmd

Message ID 1463581128-22188-3-git-send-email-hs@denx.de
State Accepted
Commit da37f006e7c58860d03946b6387394b1ab9c13a4
Headers show

Commit Message

Heiko Schocher May 18, 2016, 2:18 p.m. UTC
if CONFIG_VERSION_VARIABLE is set, the U-Boot environment
contains a "vers" variable with the current U-Boot version
string. If now "printenv" is called, test/py fails as it
detects the main_sign string, which is in this case correct.

So check only the main_sign as an error, if CONFIG_VERSION_VARIABLE
is not set.

Signed-off-by: Heiko Schocher <hs@denx.de>
---

 test/py/tests/test_env.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Stephen Warren May 18, 2016, 4:37 p.m. UTC | #1
On 05/18/2016 08:18 AM, Heiko Schocher wrote:
> if CONFIG_VERSION_VARIABLE is set, the U-Boot environment
> contains a "vers" variable with the current U-Boot version
> string. If now "printenv" is called, test/py fails as it
> detects the main_sign string, which is in this case correct.
>
> So check only the main_sign as an error, if CONFIG_VERSION_VARIABLE
> is not set.

Interesting. I wonder if it would be possible to instead adjust the 
regex so it didn't match the printenv output; that way if printenv 
crashed and the system rebooted, the test would still catch it. Still, 
the current patch is probably simpler and the window for issues small 
enough that I think this is fine.

> diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py

> +        if self.u_boot_console.config.buildconfig['config_version_variable'] == 'y':

I think that should instead be:

> if self.u_boot_console.config.buildconfig.get('config_version_variable', 'n') == 'y':

That way, if there's no value for CONFIG_VERSION_VARIABLE at all, the 
code will still work, rather than raising an exception when the lookup 
fails.

With that change,
Acked-by: Stephen Warren <swarren@nvidia.com>
Stephen Warren June 16, 2016, 5:09 p.m. UTC | #2
On 05/18/2016 10:37 AM, Stephen Warren wrote:
> On 05/18/2016 08:18 AM, Heiko Schocher wrote:
>> if CONFIG_VERSION_VARIABLE is set, the U-Boot environment
>> contains a "vers" variable with the current U-Boot version
>> string. If now "printenv" is called, test/py fails as it
>> detects the main_sign string, which is in this case correct.
>>
>> So check only the main_sign as an error, if CONFIG_VERSION_VARIABLE
>> is not set.
>
> Interesting. I wonder if it would be possible to instead adjust the
> regex so it didn't match the printenv output; that way if printenv
> crashed and the system rebooted, the test would still catch it. Still,
> the current patch is probably simpler and the window for issues small
> enough that I think this is fine.
>
>> diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py
>
>> +        if
>> self.u_boot_console.config.buildconfig['config_version_variable'] == 'y':
>
> I think that should instead be:
>
>> if
>> self.u_boot_console.config.buildconfig.get('config_version_variable',
>> 'n') == 'y':
>
> That way, if there's no value for CONFIG_VERSION_VARIABLE at all, the
> code will still work, rather than raising an exception when the lookup
> fails.
>
> With that change,
> Acked-by: Stephen Warren <swarren@nvidia.com>

Unfortunately, this patch got applied in the original form, which causes 
a lot of breakage, since CONFIG_VERSION_VARIABLE doesn't exist in many 
cases. I'll send a fixup patch.
diff mbox

Patch

diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py
index c41aa5a..22a22d1 100644
--- a/test/py/tests/test_env.py
+++ b/test/py/tests/test_env.py
@@ -39,7 +39,11 @@  class StateTestEnv(object):
             Nothing.
         """
 
-        response = self.u_boot_console.run_command('printenv')
+        if self.u_boot_console.config.buildconfig['config_version_variable'] == 'y':
+            with self.u_boot_console.disable_check('main_signon'):
+                response = self.u_boot_console.run_command('printenv')
+        else:
+            response = self.u_boot_console.run_command('printenv')
         self.env = {}
         for l in response.splitlines():
             if not '=' in l: