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