blob: 1bead69b5073e7e6ca7294db97f38e662fba8673 [file] [log] [blame]
Heinrich Schuchardt393fcf72023-07-31 22:01:21 +02001# SPDX-License-Identifier: GPL-2.0+
2
3""" Unit test for semihosting
4"""
5
6import pytest
7
8@pytest.mark.buildconfigspec('semihosting')
Simon Glassddba5202025-02-09 09:07:14 -07009def test_semihosting_hostfs(ubman, semihosting_data):
Heinrich Schuchardt393fcf72023-07-31 22:01:21 +020010 """ Unit test for semihosting
11
12 Args:
Simon Glassddba5202025-02-09 09:07:14 -070013 ubman -- U-Boot console
Heinrich Schuchardt393fcf72023-07-31 22:01:21 +020014 semihosting_data -- Path to the disk image used for testing.
15 """
Simon Glassddba5202025-02-09 09:07:14 -070016 response = ubman.run_command(
Heinrich Schuchardt393fcf72023-07-31 22:01:21 +020017 f'load hostfs - $loadaddr {semihosting_data}')
18 assert '11 bytes read' in response
19
Simon Glassddba5202025-02-09 09:07:14 -070020 response = ubman.run_command(
Heinrich Schuchardt393fcf72023-07-31 22:01:21 +020021 'crc32 $loadaddr $filesize')
22 assert '==> 60cfccfc' in response
23
Simon Glassddba5202025-02-09 09:07:14 -070024 ubman.run_command(
Heinrich Schuchardt393fcf72023-07-31 22:01:21 +020025 f'save hostfs - $loadaddr {semihosting_data} 11 11')
26
Simon Glassddba5202025-02-09 09:07:14 -070027 response = ubman.run_command(
Heinrich Schuchardt393fcf72023-07-31 22:01:21 +020028 f'load hostfs - $loadaddr {semihosting_data} 4 13')
29 assert '4 bytes read' in response
30
Simon Glassddba5202025-02-09 09:07:14 -070031 response = ubman.run_command(
Heinrich Schuchardt393fcf72023-07-31 22:01:21 +020032 'crc32 $loadaddr $filesize')
33 assert '==> e29063ea' in response