test: env: add test for env info sub-command
Add a pytest for testing the env info sub-command: test_env_info: test command with several option that can be executed on real hardware device without assumption test_env_info_sandbox: test the result on sandbox with a known ENV configuration: ready & default & persistent The quiet option '-q' is used for support in shell test; for example: if env info -p -d -q; then env save; fi Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Acked-by: Stephen Warren <swarren@nvidia.com>
This commit is contained in:
parent
7d813449b8
commit
acbf93b526
@ -336,3 +336,66 @@ def test_env_import_whitelist_delete(state_test_env):
|
||||
unset_var(state_test_env, 'foo2')
|
||||
unset_var(state_test_env, 'foo3')
|
||||
unset_var(state_test_env, 'foo4')
|
||||
|
||||
@pytest.mark.buildconfigspec('cmd_nvedit_info')
|
||||
def test_env_info(state_test_env):
|
||||
|
||||
"""Test 'env info' command with all possible options.
|
||||
"""
|
||||
c = state_test_env.u_boot_console
|
||||
|
||||
response = c.run_command('env info')
|
||||
nb_line = 0
|
||||
for l in response.split('\n'):
|
||||
if 'env_valid = ' in l:
|
||||
assert '= invalid' in l or '= valid' in l or '= redundant' in l
|
||||
nb_line += 1
|
||||
elif 'env_ready =' in l or 'env_use_default =' in l:
|
||||
assert '= true' in l or '= false' in l
|
||||
nb_line += 1
|
||||
else:
|
||||
assert true
|
||||
assert nb_line == 3
|
||||
|
||||
response = c.run_command('env info -p -d')
|
||||
assert 'Default environment is used' in response or "Environment was loaded from persistent storage" in response
|
||||
assert 'Environment can be persisted' in response or "Environment cannot be persisted" in response
|
||||
|
||||
response = c.run_command('env info -p -d -q')
|
||||
assert response == ""
|
||||
|
||||
response = c.run_command('env info -p -q')
|
||||
assert response == ""
|
||||
|
||||
response = c.run_command('env info -d -q')
|
||||
assert response == ""
|
||||
|
||||
@pytest.mark.boardspec('sandbox')
|
||||
@pytest.mark.buildconfigspec('cmd_nvedit_info')
|
||||
@pytest.mark.buildconfigspec('cmd_echo')
|
||||
def test_env_info_sandbox(state_test_env):
|
||||
|
||||
"""Test 'env info' command result with several options on sandbox
|
||||
with a known ENV configuration: ready & default & persistent
|
||||
"""
|
||||
c = state_test_env.u_boot_console
|
||||
|
||||
response = c.run_command('env info')
|
||||
assert 'env_ready = true' in response
|
||||
assert 'env_use_default = true' in response
|
||||
|
||||
response = c.run_command('env info -p -d')
|
||||
assert 'Default environment is used' in response
|
||||
assert 'Environment cannot be persisted' in response
|
||||
|
||||
response = c.run_command('env info -d -q')
|
||||
response = c.run_command('echo $?')
|
||||
assert response == "0"
|
||||
|
||||
response = c.run_command('env info -p -q')
|
||||
response = c.run_command('echo $?')
|
||||
assert response == "1"
|
||||
|
||||
response = c.run_command('env info -d -p -q')
|
||||
response = c.run_command('echo $?')
|
||||
assert response == "1"
|
||||
|
Loading…
Reference in New Issue
Block a user