blob: 970d8c79869e78a41e6c0bf6c0756fdb79d3cd75 [file] [log] [blame]
Sean Andersond41db1a2022-12-12 14:12:08 -05001# SPDX-License-Identifier: GPL-2.0+
2# Copyright (C) 2022 Sean Anderson <sean.anderson@seco.com>
3
4import os
5import pytest
Simon Glassdb0e4532025-02-09 09:07:16 -07006import utils
Sean Andersond41db1a2022-12-12 14:12:08 -05007
8@pytest.mark.boardspec('sandbox')
9@pytest.mark.buildconfigspec('cmd_echo')
10@pytest.mark.buildconfigspec('cmd_source')
11@pytest.mark.buildconfigspec('fit')
Simon Glassddba5202025-02-09 09:07:14 -070012def test_source(ubman):
Sean Andersond41db1a2022-12-12 14:12:08 -050013 # Compile our test script image
Simon Glass32701112025-02-09 09:07:17 -070014 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 Andersond41db1a2022-12-12 14:12:08 -050019
Simon Glass32701112025-02-09 09:07:17 -070020 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 Andersond41db1a2022-12-12 14:12:08 -050028
Simon Glass32701112025-02-09 09:07:17 -070029 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 Andersond3e7e202022-12-12 14:12:11 -050033
Simon Glass32701112025-02-09 09:07:17 -070034 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')