[U-Boot] [PATCH] test: py: Add cmd_echo dependency

There is missing dependency on echo command. Mark tests which requires echo.
Signed-off-by: Michal Simek michal.simek@xilinx.com ---
test/py/tests/test_env.py | 8 ++++++++ test/py/tests/test_shell_basics.py | 4 ++++ 2 files changed, 12 insertions(+)
diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py index 035dbf5cac4c..b7a76b31c304 100644 --- a/test/py/tests/test_env.py +++ b/test/py/tests/test_env.py @@ -157,6 +157,7 @@ def validate_set(state_test_env, var, value): response = state_test_env.u_boot_console.run_command('printenv %s' % var) assert response == ('%s=%s' % (var, value))
+@pytest.mark.buildconfigspec('cmd_echo') def test_env_echo_exists(state_test_env): """Test echoing a variable that exists."""
@@ -164,12 +165,14 @@ def test_env_echo_exists(state_test_env): value = state_test_env.env[var] validate_set(state_test_env, var, value)
+@pytest.mark.buildconfigspec('cmd_echo') def test_env_echo_non_existent(state_test_env): """Test echoing a variable that doesn't exist."""
var = state_test_env.set_var validate_empty(state_test_env, var)
+@pytest.mark.buildconfigspec('cmd_echo') def test_env_printenv_non_existent(state_test_env): """Test printenv error message for non-existant variables."""
@@ -179,6 +182,7 @@ def test_env_printenv_non_existent(state_test_env): response = c.run_command('printenv %s' % var) assert(response == '## Error: "%s" not defined' % var)
+@pytest.mark.buildconfigspec('cmd_echo') def test_env_unset_non_existent(state_test_env): """Test unsetting a nonexistent variable."""
@@ -186,6 +190,7 @@ def test_env_unset_non_existent(state_test_env): unset_var(state_test_env, var) validate_empty(state_test_env, var)
+@pytest.mark.buildconfigspec('cmd_echo') def test_env_set_non_existent(state_test_env): """Test set a non-existant variable."""
@@ -194,6 +199,7 @@ def test_env_set_non_existent(state_test_env): set_var(state_test_env, var, value) validate_set(state_test_env, var, value)
+@pytest.mark.buildconfigspec('cmd_echo') def test_env_set_existing(state_test_env): """Test setting an existant variable."""
@@ -202,6 +208,7 @@ def test_env_set_existing(state_test_env): set_var(state_test_env, var, value) validate_set(state_test_env, var, value)
+@pytest.mark.buildconfigspec('cmd_echo') def test_env_unset_existing(state_test_env): """Test unsetting a variable."""
@@ -209,6 +216,7 @@ def test_env_unset_existing(state_test_env): unset_var(state_test_env, var) validate_empty(state_test_env, var)
+@pytest.mark.buildconfigspec('cmd_echo') def test_env_expansion_spaces(state_test_env): """Test expanding a variable that contains a space in its value."""
diff --git a/test/py/tests/test_shell_basics.py b/test/py/tests/test_shell_basics.py index 702e5e27e002..f0def2759020 100644 --- a/test/py/tests/test_shell_basics.py +++ b/test/py/tests/test_shell_basics.py @@ -3,13 +3,16 @@ # SPDX-License-Identifier: GPL-2.0
# Test basic shell functionality, such as commands separate by semi-colons. +import pytest
+@pytest.mark.buildconfigspec('cmd_echo') def test_shell_execute(u_boot_console): """Test any shell command."""
response = u_boot_console.run_command('echo hello') assert response.strip() == 'hello'
+@pytest.mark.buildconfigspec('cmd_echo') def test_shell_semicolon_two(u_boot_console): """Test two shell commands separate by a semi-colon."""
@@ -28,6 +31,7 @@ def test_shell_semicolon_three(u_boot_console): assert response.strip() == '123' u_boot_console.run_command('setenv list')
+@pytest.mark.buildconfigspec('cmd_echo') def test_shell_run(u_boot_console): """Test the "run" shell command."""

On 05/12/2017 01:31 AM, Michal Simek wrote:
There is missing dependency on echo command. Mark tests which requires echo.
test/py/tests/test_env.py | 8 ++++++++ test/py/tests/test_shell_basics.py | 4 ++++ 2 files changed, 12 insertions(+)
test_hush_if_test.py also needs fixing for this. Perhaps you didn't notice this because those tests are already dependant on CONFIG_HUSH_PARSER which I assume you don't have enabled.
diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py
+@pytest.mark.buildconfigspec('cmd_echo') def test_env_echo_exists(state_test_env): """Test echoing a variable that exists."""
I don't believe this one actually depends on CONFIG_CMD_ECHO; it uses printenv rather than the echo command.
+@pytest.mark.buildconfigspec('cmd_echo') def test_env_printenv_non_existent(state_test_env):
Same here.
+@pytest.mark.buildconfigspec('cmd_echo') def test_env_set_non_existent(state_test_env):
Same here.
+@pytest.mark.buildconfigspec('cmd_echo') def test_env_set_existing(state_test_env):
Same here.
+@pytest.mark.buildconfigspec('cmd_echo') def test_env_expansion_spaces(state_test_env):
Same here.
However, the other functions in the patch do need this mark.
diff --git a/test/py/tests/test_shell_basics.py b/test/py/tests/test_shell_basics.py
# Test basic shell functionality, such as commands separate by semi-colons. +import pytest
Nit: There's a blank line between the file comment and import statements in other files.
+@pytest.mark.buildconfigspec('cmd_echo') def test_shell_execute(u_boot_console): """Test any shell command."""
Rather than marking each individual test in this file (and test_hush_if_test.py), perhaps apply the mark on a file/module level?
https://docs.pytest.org/en/latest/example/markers.html says to do this in global scope:
pytestmark = pytest.mark.buildconfigspec('cmd_echo')

On 12.5.2017 18:20, Stephen Warren wrote:
On 05/12/2017 01:31 AM, Michal Simek wrote:
There is missing dependency on echo command. Mark tests which requires echo.
test/py/tests/test_env.py | 8 ++++++++ test/py/tests/test_shell_basics.py | 4 ++++ 2 files changed, 12 insertions(+)
test_hush_if_test.py also needs fixing for this. Perhaps you didn't notice this because those tests are already dependant on CONFIG_HUSH_PARSER which I assume you don't have enabled.
yep - in my configuration hush is disabled that's why I didn't find it out. For hush only these two tests pass when echo is disable.
test_hush_if_test_setup test_hush_if_test_teardown
Also when you disable HUSH more tests failed.
diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py
+@pytest.mark.buildconfigspec('cmd_echo') def test_env_echo_exists(state_test_env): """Test echoing a variable that exists."""
I don't believe this one actually depends on CONFIG_CMD_ECHO; it uses printenv rather than the echo command.
removed
+@pytest.mark.buildconfigspec('cmd_echo') def test_env_printenv_non_existent(state_test_env):
Same here.
removed
+@pytest.mark.buildconfigspec('cmd_echo') def test_env_set_non_existent(state_test_env):
Same here.
removed
+@pytest.mark.buildconfigspec('cmd_echo') def test_env_set_existing(state_test_env):
Same here.
removed
+@pytest.mark.buildconfigspec('cmd_echo') def test_env_expansion_spaces(state_test_env):
Same here.
You are right with that above. It was failing for me that's why I have added this but the reason for failure is different.
printenv is in cmd/nvedit.c which is enabled all the time obj-y += nvedit.o
That's why I will remove this completely.
Just a note there is
However, the other functions in the patch do need this mark.
diff --git a/test/py/tests/test_shell_basics.py b/test/py/tests/test_shell_basics.py
# Test basic shell functionality, such as commands separate by semi-colons. +import pytest
Nit: There's a blank line between the file comment and import statements in other files.
fixed.
+@pytest.mark.buildconfigspec('cmd_echo') def test_shell_execute(u_boot_console): """Test any shell command."""
Rather than marking each individual test in this file (and test_hush_if_test.py), perhaps apply the mark on a file/module level?
https://docs.pytest.org/en/latest/example/markers.html says to do this in global scope:
pytestmark = pytest.mark.buildconfigspec('cmd_echo')
yep that works too but I was checking setup_buildconfigspec and we don't have an option to mark whole file depends on cmd_echo but some tests in that file don't need to require it.
This is the same for env and dependency on hush. Where based on my tests only test_env_echo_exists and test_env_printenv_non_existent don't require hush.
Thanks, Michal
participants (2)
-
Michal Simek
-
Stephen Warren