xref: /openbmc/u-boot/test/py/tests/test_md.py (revision 72719d2f)
1# 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
7import u_boot_utils
8
9@pytest.mark.buildconfigspec('cmd_memory')
10def test_md(u_boot_console):
11    """Test that md reads memory as expected, and that memory can be modified
12    using the mw command."""
13
14    ram_base = u_boot_utils.find_ram_base(u_boot_console)
15    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):
27    """Test command repeat (via executing an empty command) operates correctly
28    for "md"; the command must repeat and dump an incrementing address."""
29
30    ram_base = u_boot_utils.find_ram_base(u_boot_console)
31    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)
38