blob: 5fe25826b3f436f4fb76bb0dc5dbd1bac3bdf362 [file] [log] [blame]
Stephen Warren98cee892016-01-15 11:15:27 -07001# Copyright (c) 2015 Stephen Warren
2# Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
3#
4# SPDX-License-Identifier: GPL-2.0
5
6import pytest
Stephen Warren05266102016-01-21 16:05:30 -07007import u_boot_utils
Stephen Warren98cee892016-01-15 11:15:27 -07008
9@pytest.mark.buildconfigspec('cmd_memory')
10def test_md(u_boot_console):
Stephen Warrene8debf32016-01-26 13:41:30 -070011 """Test that md reads memory as expected, and that memory can be modified
12 using the mw command."""
Stephen Warren98cee892016-01-15 11:15:27 -070013
Stephen Warren05266102016-01-21 16:05:30 -070014 ram_base = u_boot_utils.find_ram_base(u_boot_console)
Stephen Warren98cee892016-01-15 11:15:27 -070015 addr = '%08x' % ram_base
16 val = 'a5f09876'
17 expected_response = addr + ': ' + val
18 u_boot_console.run_command('mw ' + addr + ' 0 10')
19 response = u_boot_console.run_command('md ' + addr + ' 10')
20 assert(not (expected_response in response))
21 u_boot_console.run_command('mw ' + addr + ' ' + val)
22 response = u_boot_console.run_command('md ' + addr + ' 10')
23 assert(expected_response in response)
24
25@pytest.mark.buildconfigspec('cmd_memory')
26def test_md_repeat(u_boot_console):
Stephen Warrene8debf32016-01-26 13:41:30 -070027 """Test command repeat (via executing an empty command) operates correctly
28 for "md"; the command must repeat and dump an incrementing address."""
Stephen Warren98cee892016-01-15 11:15:27 -070029
Stephen Warren05266102016-01-21 16:05:30 -070030 ram_base = u_boot_utils.find_ram_base(u_boot_console)
Stephen Warren98cee892016-01-15 11:15:27 -070031 addr_base = '%08x' % ram_base
32 words = 0x10
33 addr_repeat = '%08x' % (ram_base + (words * 4))
34 u_boot_console.run_command('md %s %x' % (addr_base, words))
35 response = u_boot_console.run_command('')
36 expected_response = addr_repeat + ': '
37 assert(expected_response in response)