xref: /openbmc/u-boot/test/py/tests/test_md.py (revision e8f80a5a)
1*83d290c5STom Rini# SPDX-License-Identifier: GPL-2.0
298cee89bSStephen Warren# Copyright (c) 2015 Stephen Warren
398cee89bSStephen Warren# Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
498cee89bSStephen Warren
598cee89bSStephen Warrenimport pytest
605266103SStephen Warrenimport u_boot_utils
798cee89bSStephen Warren
898cee89bSStephen Warren@pytest.mark.buildconfigspec('cmd_memory')
998cee89bSStephen Warrendef test_md(u_boot_console):
10e8debf39SStephen Warren    """Test that md reads memory as expected, and that memory can be modified
11e8debf39SStephen Warren    using the mw command."""
1298cee89bSStephen Warren
1305266103SStephen Warren    ram_base = u_boot_utils.find_ram_base(u_boot_console)
1498cee89bSStephen Warren    addr = '%08x' % ram_base
1598cee89bSStephen Warren    val = 'a5f09876'
1698cee89bSStephen Warren    expected_response = addr + ': ' + val
1798cee89bSStephen Warren    u_boot_console.run_command('mw ' + addr + ' 0 10')
1898cee89bSStephen Warren    response = u_boot_console.run_command('md ' + addr + ' 10')
1998cee89bSStephen Warren    assert(not (expected_response in response))
2098cee89bSStephen Warren    u_boot_console.run_command('mw ' + addr + ' ' + val)
2198cee89bSStephen Warren    response = u_boot_console.run_command('md ' + addr + ' 10')
2298cee89bSStephen Warren    assert(expected_response in response)
2398cee89bSStephen Warren
2498cee89bSStephen Warren@pytest.mark.buildconfigspec('cmd_memory')
2598cee89bSStephen Warrendef test_md_repeat(u_boot_console):
26e8debf39SStephen Warren    """Test command repeat (via executing an empty command) operates correctly
27e8debf39SStephen Warren    for "md"; the command must repeat and dump an incrementing address."""
2898cee89bSStephen Warren
2905266103SStephen Warren    ram_base = u_boot_utils.find_ram_base(u_boot_console)
3098cee89bSStephen Warren    addr_base = '%08x' % ram_base
3198cee89bSStephen Warren    words = 0x10
3298cee89bSStephen Warren    addr_repeat = '%08x' % (ram_base + (words * 4))
3398cee89bSStephen Warren    u_boot_console.run_command('md %s %x' % (addr_base, words))
3498cee89bSStephen Warren    response = u_boot_console.run_command('')
3598cee89bSStephen Warren    expected_response = addr_repeat + ': '
3698cee89bSStephen Warren    assert(expected_response in response)
37