diff options
author | Sean Anderson <sean.anderson@seco.com> | 2022-12-12 14:12:08 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-12-31 13:35:19 -0500 |
commit | 895999261ca02882813d477f28ba06c8060d9c43 (patch) | |
tree | 17ee727692ca2907acd36e951b3616517902115d /test/py/tests/test_source.py | |
parent | b5fd7b4a31e5098ff024ebc63bccfcb2b4429c82 (diff) |
test: Add test for source command
This adds a basic test for FIT image handling by the source command.
It's a python test becase we need to run mkimage.
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/py/tests/test_source.py')
-rw-r--r-- | test/py/tests/test_source.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/py/tests/test_source.py b/test/py/tests/test_source.py new file mode 100644 index 0000000000..e5ffdfe3fc --- /dev/null +++ b/test/py/tests/test_source.py @@ -0,0 +1,28 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (C) 2022 Sean Anderson <sean.anderson@seco.com> + +import os +import pytest +import u_boot_utils as util + +@pytest.mark.boardspec('sandbox') +@pytest.mark.buildconfigspec('cmd_echo') +@pytest.mark.buildconfigspec('cmd_source') +@pytest.mark.buildconfigspec('fit') +def test_source(u_boot_console): + # Compile our test script image + cons = u_boot_console + mkimage = os.path.join(cons.config.build_dir, 'tools/mkimage') + its = os.path.join(cons.config.source_dir, 'test/py/tests/source.its') + fit = os.path.join(cons.config.build_dir, 'source.itb') + util.run_and_log(cons, (mkimage, '-f', its, fit)) + cons.run_command(f'host load hostfs - $loadaddr {fit}') + + assert '1' in cons.run_command('source') + assert '1' in cons.run_command('source :script-1') + assert '2' in cons.run_command('source :script-2') + assert 'Fail' in cons.run_command('source :not-a-script || echo Fail') + + cons.run_command('fdt addr $loadaddr') + cons.run_command('fdt rm /images default') + assert 'Fail' in cons.run_command('source || echo Fail') |