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 |
Simon Glass | db0e453 | 2025-02-09 09:07:16 -0700 | [diff] [blame] | 6 | import utils |
Sean Anderson | d41db1a | 2022-12-12 14:12:08 -0500 | [diff] [blame] | 7 | |
| 8 | @pytest.mark.boardspec('sandbox') |
| 9 | @pytest.mark.buildconfigspec('cmd_echo') |
| 10 | @pytest.mark.buildconfigspec('cmd_source') |
| 11 | @pytest.mark.buildconfigspec('fit') |
Simon Glass | ddba520 | 2025-02-09 09:07:14 -0700 | [diff] [blame] | 12 | def test_source(ubman): |
Sean Anderson | d41db1a | 2022-12-12 14:12:08 -0500 | [diff] [blame] | 13 | # Compile our test script image |
Simon Glass | 3270111 | 2025-02-09 09:07:17 -0700 | [diff] [blame] | 14 | mkimage = os.path.join(ubman.config.build_dir, 'tools/mkimage') |
| 15 | its = os.path.join(ubman.config.source_dir, 'test/py/tests/source.its') |
| 16 | fit = os.path.join(ubman.config.build_dir, 'source.itb') |
| 17 | utils.run_and_log(ubman, (mkimage, '-f', its, fit)) |
| 18 | ubman.run_command(f'host load hostfs - $loadaddr {fit}') |
Sean Anderson | d41db1a | 2022-12-12 14:12:08 -0500 | [diff] [blame] | 19 | |
Simon Glass | 3270111 | 2025-02-09 09:07:17 -0700 | [diff] [blame] | 20 | assert '2' in ubman.run_command('source') |
| 21 | assert '1' in ubman.run_command('source :') |
| 22 | assert '1' in ubman.run_command('source :script-1') |
| 23 | assert '2' in ubman.run_command('source :script-2') |
| 24 | assert 'Fail' in ubman.run_command('source :not-a-script || echo Fail') |
| 25 | assert '2' in ubman.run_command('source \\#') |
| 26 | assert '1' in ubman.run_command('source \\#conf-1') |
| 27 | assert '2' in ubman.run_command('source \\#conf-2') |
Sean Anderson | d41db1a | 2022-12-12 14:12:08 -0500 | [diff] [blame] | 28 | |
Simon Glass | 3270111 | 2025-02-09 09:07:17 -0700 | [diff] [blame] | 29 | ubman.run_command('fdt addr $loadaddr') |
| 30 | ubman.run_command('fdt rm /configurations default') |
| 31 | assert '1' in ubman.run_command('source') |
| 32 | assert 'Fail' in ubman.run_command('source \\# || echo Fail') |
Sean Anderson | d3e7e20 | 2022-12-12 14:12:11 -0500 | [diff] [blame] | 33 | |
Simon Glass | 3270111 | 2025-02-09 09:07:17 -0700 | [diff] [blame] | 34 | ubman.run_command('fdt rm /images default') |
| 35 | assert 'Fail' in ubman.run_command('source || echo Fail') |
| 36 | assert 'Fail' in ubman.run_command('source \\# || echo Fail') |