diff options
author | Tom Rini <trini@konsulko.com> | 2024-01-19 08:46:47 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2024-01-19 08:46:47 -0500 |
commit | f4d54865061495bdb483f9ddc81183d1940f596c (patch) | |
tree | 203ec612e1a7b41602e5616c5f480d89caf1ff95 /test/py | |
parent | cb493752394adec8db1d6f5e9b8fb3c43e13f10a (diff) | |
parent | 46371f269986976b3e969c0985820169b766ff76 (diff) |
Merge branch '2024-01-18-assorted-fixes'
- A number of OS boot related cleanups, a number of TI platform
fixes/cleanups, SMBIOS fixes, tweak get_maintainers.pl to report me
for more places, fix the "clean the build" pytest and add a bootstage
pytest, fix PKCS11 URI being omitted in some valid cases, make an iommu
problem easier to debug on new platforms, nvme and pci improvements,
refactor image-host code a bit, fix a typo in env setting, add a missing
dependency for CMD_LICENSE, and correct how we call getchar() in some
places.
Diffstat (limited to 'test/py')
-rw-r--r-- | test/py/tests/test_bootstage.py | 67 | ||||
-rw-r--r-- | test/py/tests/test_cleanup_build.py | 5 |
2 files changed, 72 insertions, 0 deletions
diff --git a/test/py/tests/test_bootstage.py b/test/py/tests/test_bootstage.py new file mode 100644 index 00000000000..a9eb9f0b4a1 --- /dev/null +++ b/test/py/tests/test_bootstage.py @@ -0,0 +1,67 @@ +# SPDX-License-Identifier: GPL-2.0 +# (C) Copyright 2023, Advanced Micro Devices, Inc. + +import pytest + +""" +Test the bootstage command. + +It is used for checking the boot progress and timing by printing the bootstage +report, stashes the data into memory and unstashes the data from memory. + +Note: This test relies on boardenv_* containing configuration values to define +the data size, memory address, and bootstage magic address (defined in +common/bootstage.c). Without this, bootstage stash and unstash tests will be +automatically skipped. + +For example: +env__bootstage_cmd_file = { + 'addr': 0x200000, + 'size': 0x1000, + 'bootstage_magic_addr': 0xb00757a3, +} +""" + +@pytest.mark.buildconfigspec('bootstage') +@pytest.mark.buildconfigspec('cmd_bootstage') +def test_bootstage_report(u_boot_console): + output = u_boot_console.run_command('bootstage report') + assert 'Timer summary in microseconds' in output + assert 'Accumulated time:' in output + assert 'dm_r' in output + +@pytest.mark.buildconfigspec('bootstage') +@pytest.mark.buildconfigspec('cmd_bootstage') +@pytest.mark.buildconfigspec('bootstage_stash') +def test_bootstage_stash(u_boot_console): + f = u_boot_console.config.env.get('env__bootstage_cmd_file', None) + if not f: + pytest.skip('No bootstage environment file is defined') + + addr = f.get('addr') + size = f.get('size') + bootstage_magic = f.get('bootstage_magic_addr') + expected_text = 'dm_r' + + u_boot_console.run_command('bootstage stash %x %x' % (addr, size)) + output = u_boot_console.run_command('echo $?') + assert output.endswith('0') + + output = u_boot_console.run_command('md %x 100' % addr) + + # Check BOOTSTAGE_MAGIC address at 4th byte address + assert '0x' + output.split('\n')[0].split()[4] == hex(bootstage_magic) + + # Check expected string in last column of output + output_last_col = ''.join([i.split()[-1] for i in output.split('\n')]) + assert expected_text in output_last_col + return addr, size + +@pytest.mark.buildconfigspec('bootstage') +@pytest.mark.buildconfigspec('cmd_bootstage') +@pytest.mark.buildconfigspec('bootstage_stash') +def test_bootstage_unstash(u_boot_console): + addr, size = test_bootstage_stash(u_boot_console) + u_boot_console.run_command('bootstage unstash %x %x' % (addr, size)) + output = u_boot_console.run_command('echo $?') + assert output.endswith('0') diff --git a/test/py/tests/test_cleanup_build.py b/test/py/tests/test_cleanup_build.py index 5206ff73ec7..aca90cb1107 100644 --- a/test/py/tests/test_cleanup_build.py +++ b/test/py/tests/test_cleanup_build.py @@ -17,6 +17,11 @@ import pytest @pytest.fixture def tmp_copy_of_builddir(u_boot_config, tmp_path): """For each test, provide a temporary copy of the initial build directory.""" + if os.path.realpath(u_boot_config.source_dir) == os.path.realpath( + u_boot_config.build_dir + ): + pytest.skip("Leftover detection requires out of tree build.") + return None shutil.copytree( u_boot_config.build_dir, tmp_path, |