From f7ee9f3d362a05cc3f7e04d0ceb373c2aea80de6 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 31 Jul 2023 22:01:21 +0200 Subject: test: unit test for semihosting Provide a unit test for semihosting testing reading and writing a file. Signed-off-by: Heinrich Schuchardt Reviewed-by: Sean Anderson --- test/py/tests/test_semihosting/test_hostfs.py | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/py/tests/test_semihosting/test_hostfs.py (limited to 'test/py/tests/test_semihosting/test_hostfs.py') diff --git a/test/py/tests/test_semihosting/test_hostfs.py b/test/py/tests/test_semihosting/test_hostfs.py new file mode 100644 index 00000000000..51f6fa7702c --- /dev/null +++ b/test/py/tests/test_semihosting/test_hostfs.py @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: GPL-2.0+ + +""" Unit test for semihosting +""" + +import pytest + +@pytest.mark.buildconfigspec('semihosting') +def test_semihosting_hostfs(u_boot_console, semihosting_data): + """ Unit test for semihosting + + Args: + u_boot_console -- U-Boot console + semihosting_data -- Path to the disk image used for testing. + """ + response = u_boot_console.run_command( + f'load hostfs - $loadaddr {semihosting_data}') + assert '11 bytes read' in response + + response = u_boot_console.run_command( + 'crc32 $loadaddr $filesize') + assert '==> 60cfccfc' in response + + u_boot_console.run_command( + f'save hostfs - $loadaddr {semihosting_data} 11 11') + + response = u_boot_console.run_command( + f'load hostfs - $loadaddr {semihosting_data} 4 13') + assert '4 bytes read' in response + + response = u_boot_console.run_command( + 'crc32 $loadaddr $filesize') + assert '==> e29063ea' in response -- cgit v1.2.3