u-boot/test/py/tests/test_source.py
Simon Glass 752c376987 test/py: Shorten u_boot_console
This fixture name is quite long and results in lots of verbose code.
We know this is U-Boot so the 'u_boot_' part is not necessary.

But it is also a bit of a misnomer, since it provides access to all the
information available to tests. It is not just the console.

It would be too confusing to use con as it would be confused with
config and it is probably too short.

So shorten it to 'ubman'.

Signed-off-by: Simon Glass <sjg@chromium.org>
Link: https://lore.kernel.org/u-boot/CAFLszTgPa4aT_J9h9pqeTtLCVn4x2JvLWRcWRD8NaN3uoSAtyA@mail.gmail.com/
2025-03-15 10:38:38 +00:00

37 lines
1.5 KiB
Python

# 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(ubman):
# Compile our test script image
cons = ubman
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')