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