diff options
author | Max Krummenacher <max.krummenacher@toradex.com> | 2022-12-09 13:09:56 +0100 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-01-11 15:02:23 -0500 |
commit | e64289e1ec7c66a2d858aff65c0af501557d538b (patch) | |
tree | c772899fabe8135b55743195fec69b7a2d84429c /test/py | |
parent | 5b333b932495ff4348978f93ef273c73de99b7d2 (diff) | |
download | u-boot-e64289e1ec7c66a2d858aff65c0af501557d538b.tar.gz u-boot-e64289e1ec7c66a2d858aff65c0af501557d538b.tar.bz2 u-boot-e64289e1ec7c66a2d858aff65c0af501557d538b.zip |
test: env: add test for u-boot-initial-env creation
Checks that `make u-boot-initial-env` creates the text file
u-boot-initial-env and checks that it at least contains
`board=<something>`.
Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/py')
-rw-r--r-- | test/py/tests/test_env.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py index 6d08565f0b..00bcccd65f 100644 --- a/test/py/tests/test_env.py +++ b/test/py/tests/test_env.py @@ -8,6 +8,7 @@ Test operation of shell commands relating to environment variables. import os import os.path +import re from subprocess import call, CalledProcessError import tempfile @@ -173,6 +174,29 @@ 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.boardspec('sandbox') +def test_env_initial_env_file(u_boot_console): + """Test that the u-boot-initial-env make target works""" + cons = u_boot_console + builddir = 'O=' + cons.config.build_dir + envfile = cons.config.build_dir + '/u-boot-initial-env' + + # remove if already exists from an older run + try: + os.remove(envfile) + except: + pass + + u_boot_utils.run_and_log(cons, ['make', builddir, 'u-boot-initial-env']) + + assert os.path.exists(envfile) + + # assume that every environment has a board variable, e.g. board=sandbox + with open(envfile, 'r') as file: + env = file.read() + regex = re.compile('board=.+\\n') + assert re.search(regex, env) + def test_env_echo_exists(state_test_env): """Test echoing a variable that exists.""" |