diff options
author | Tom Rini <trini@konsulko.com> | 2022-12-31 16:30:31 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-12-31 16:30:31 -0500 |
commit | 3aa14d76182dbbaf9fed4deeaf362f083b9d2f5b (patch) | |
tree | 9a4c733db8ec3b99444a5ff9177aeb709459ad07 /test/py | |
parent | 3e4cbe184a0f6537abb457d6afa61224396c4e46 (diff) | |
parent | bcc85b96b5ffbbce19a89747138feb873d918915 (diff) |
Merge branch '2022-12-31-cmd-source-support-specifying-config-name' into next
To quote the author:
This series adds support for using configs with the source command.
And to paraphrase the rest, see the patch commit messages for more
details.
Diffstat (limited to 'test/py')
-rw-r--r-- | test/py/tests/source.its | 43 | ||||
-rw-r--r-- | test/py/tests/test_source.py | 37 |
2 files changed, 80 insertions, 0 deletions
diff --git a/test/py/tests/source.its b/test/py/tests/source.its new file mode 100644 index 00000000000..3c62f777f17 --- /dev/null +++ b/test/py/tests/source.its @@ -0,0 +1,43 @@ +/dts-v1/; + +/ { + description = "FIT image to test the source command"; + #address-cells = <1>; + + images { + default = "script-1"; + + script-1 { + data = "echo 1"; + type = "script"; + arch = "sandbox"; + compression = "none"; + }; + + script-2 { + data = "echo 2"; + type = "script"; + arch = "sandbox"; + compression = "none"; + }; + + not-a-script { + data = "echo 3"; + type = "kernel"; + arch = "sandbox"; + compression = "none"; + }; + }; + + configurations { + default = "conf-2"; + + conf-1 { + script = "script-1"; + }; + + conf-2 { + script = "script-2"; + }; + }; +}; diff --git a/test/py/tests/test_source.py b/test/py/tests/test_source.py new file mode 100644 index 00000000000..bbc311df6d1 --- /dev/null +++ b/test/py/tests/test_source.py @@ -0,0 +1,37 @@ +# 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 '2' in cons.run_command('source') + 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') + assert '2' in cons.run_command('source \\#') + assert '1' in cons.run_command('source \\#conf-1') + assert '2' in cons.run_command('source \\#conf-2') + + cons.run_command('fdt addr $loadaddr') + cons.run_command('fdt rm /configurations default') + assert '1' in cons.run_command('source') + assert 'Fail' in cons.run_command('source \\# || echo Fail') + + cons.run_command('fdt rm /images default') + assert 'Fail' in cons.run_command('source || echo Fail') + assert 'Fail' in cons.run_command('source \\# || echo Fail') |