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