xref: /OK3568_Linux_fs/u-boot/test/py/tests/test_md.py (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun# Copyright (c) 2015 Stephen Warren
2*4882a593Smuzhiyun# Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
3*4882a593Smuzhiyun#
4*4882a593Smuzhiyun# SPDX-License-Identifier: GPL-2.0
5*4882a593Smuzhiyun
6*4882a593Smuzhiyunimport pytest
7*4882a593Smuzhiyunimport u_boot_utils
8*4882a593Smuzhiyun
9*4882a593Smuzhiyun@pytest.mark.buildconfigspec('cmd_memory')
10*4882a593Smuzhiyundef test_md(u_boot_console):
11*4882a593Smuzhiyun    """Test that md reads memory as expected, and that memory can be modified
12*4882a593Smuzhiyun    using the mw command."""
13*4882a593Smuzhiyun
14*4882a593Smuzhiyun    ram_base = u_boot_utils.find_ram_base(u_boot_console)
15*4882a593Smuzhiyun    addr = '%08x' % ram_base
16*4882a593Smuzhiyun    val = 'a5f09876'
17*4882a593Smuzhiyun    expected_response = addr + ': ' + val
18*4882a593Smuzhiyun    u_boot_console.run_command('mw ' + addr + ' 0 10')
19*4882a593Smuzhiyun    response = u_boot_console.run_command('md ' + addr + ' 10')
20*4882a593Smuzhiyun    assert(not (expected_response in response))
21*4882a593Smuzhiyun    u_boot_console.run_command('mw ' + addr + ' ' + val)
22*4882a593Smuzhiyun    response = u_boot_console.run_command('md ' + addr + ' 10')
23*4882a593Smuzhiyun    assert(expected_response in response)
24*4882a593Smuzhiyun
25*4882a593Smuzhiyun@pytest.mark.buildconfigspec('cmd_memory')
26*4882a593Smuzhiyundef test_md_repeat(u_boot_console):
27*4882a593Smuzhiyun    """Test command repeat (via executing an empty command) operates correctly
28*4882a593Smuzhiyun    for "md"; the command must repeat and dump an incrementing address."""
29*4882a593Smuzhiyun
30*4882a593Smuzhiyun    ram_base = u_boot_utils.find_ram_base(u_boot_console)
31*4882a593Smuzhiyun    addr_base = '%08x' % ram_base
32*4882a593Smuzhiyun    words = 0x10
33*4882a593Smuzhiyun    addr_repeat = '%08x' % (ram_base + (words * 4))
34*4882a593Smuzhiyun    u_boot_console.run_command('md %s %x' % (addr_base, words))
35*4882a593Smuzhiyun    response = u_boot_console.run_command('')
36*4882a593Smuzhiyun    expected_response = addr_repeat + ': '
37*4882a593Smuzhiyun    assert(expected_response in response)
38