Sean Anderson | d41db1a | 2022-12-12 14:12:08 -0500 | [diff] [blame^] | 1 | # SPDX-License-Identifier: GPL-2.0+ |
| 2 | # Copyright (C) 2022 Sean Anderson <sean.anderson@seco.com> |
| 3 | |
| 4 | import os |
| 5 | import pytest |
| 6 | import u_boot_utils as util |
| 7 | |
| 8 | @pytest.mark.boardspec('sandbox') |
| 9 | @pytest.mark.buildconfigspec('cmd_echo') |
| 10 | @pytest.mark.buildconfigspec('cmd_source') |
| 11 | @pytest.mark.buildconfigspec('fit') |
| 12 | def test_source(u_boot_console): |
| 13 | # Compile our test script image |
| 14 | cons = u_boot_console |
| 15 | mkimage = os.path.join(cons.config.build_dir, 'tools/mkimage') |
| 16 | its = os.path.join(cons.config.source_dir, 'test/py/tests/source.its') |
| 17 | fit = os.path.join(cons.config.build_dir, 'source.itb') |
| 18 | util.run_and_log(cons, (mkimage, '-f', its, fit)) |
| 19 | cons.run_command(f'host load hostfs - $loadaddr {fit}') |
| 20 | |
| 21 | assert '1' in cons.run_command('source') |
| 22 | assert '1' in cons.run_command('source :script-1') |
| 23 | assert '2' in cons.run_command('source :script-2') |
| 24 | assert 'Fail' in cons.run_command('source :not-a-script || echo Fail') |
| 25 | |
| 26 | cons.run_command('fdt addr $loadaddr') |
| 27 | cons.run_command('fdt rm /images default') |
| 28 | assert 'Fail' in cons.run_command('source || echo Fail') |