From patchwork Wed Feb 12 12:40:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Delaunay X-Patchwork-Id: 236232 List-Id: U-Boot discussion From: patrick.delaunay at st.com (Patrick Delaunay) Date: Wed, 12 Feb 2020 13:40:00 +0100 Subject: [PATCH v3 7/7] test: env: add test for env info sub-command In-Reply-To: <20200212124001.12788-1-patrick.delaunay@st.com> References: <20200212124001.12788-1-patrick.delaunay@st.com> Message-ID: <20200212124001.12788-6-patrick.delaunay@st.com> Add a pytest for testing the env info sub-command: test_env_info: test command with several option test_env_info_quiet: test the result of the sub-command with quiet option, '-q' as used for support in shell test; for example: if env info -p -d -q; then env save; fi Signed-off-by: Patrick Delaunay --- Changes in v3: - udpate commit message (sub-commandi) - rename test_env_info_test to test_env_info_quiet Changes in v2: - add pytest test_env_info and test_env_info_test (new) test/py/tests/test_env.py | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py index 6ff38f1020..cbdb41031c 100644 --- a/test/py/tests/test_env.py +++ b/test/py/tests/test_env.py @@ -336,3 +336,47 @@ 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') + + at pytest.mark.boardspec('sandbox') + at pytest.mark.buildconfigspec('cmd_nvedit_info') +def test_env_info(state_test_env): + + """Test 'env info' command with several options. + """ + c = state_test_env.u_boot_console + + response = c.run_command('env info') + assert 'env_valid = invalid' in response + 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 -p -d -q') + assert response == "" + + at pytest.mark.boardspec('sandbox') + at pytest.mark.buildconfigspec('cmd_nvedit_info') + at pytest.mark.buildconfigspec('cmd_echo') +def test_env_info_quiet(state_test_env): + + """Test 'env info' quiet command result with several options for test. + """ + c = state_test_env.u_boot_console + + response = c.run_command('env info -d -q') + assert response == "" + response = c.run_command('echo $?') + assert response == "0" + + response = c.run_command('env info -p -q') + assert response == "" + response = c.run_command('echo $?') + assert response == "1" + + response = c.run_command('env info -d -p -q') + assert response == "" + response = c.run_command('echo $?') + assert response == "1"