[U-Boot] [PATCH V4 4/8] test/py: test the md/mw commands

Stephen Warren swarren at wwwdotorg.org
Fri Jan 15 19:15:27 CET 2016


This tests whether md/mw work, and affect each-other.

Command repeat is also tested.

test/cmd_repeat.sh is removed, since the new Python-based test does
everything it used to.

Signed-off-by: Stephen Warren <swarren at wwwdotorg.org>
Signed-off-by: Stephen Warren <swarren at nvidia.com>
Acked-by: Simon Glass <sjg at chromium.org>
---
v4:
- No changes.

v3:
- Add extra mw during md test to account for the possibility that the
  test's write data may already be present in RAM.
  Suggested by Michal Simek.
- Move test scripts into a sub-directory.
  Suggested by Michal Simek.
- s/uboot/u[-_]boot/g. Suggested by Simon Glass.
- s/"/'/g. Suggested by Simon Glass.
- Add more documentation. Suggested by Simon Glass.
---
 test/cmd_repeat.sh       | 29 -----------------------------
 test/py/tests/test_md.py | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 29 deletions(-)
 delete mode 100755 test/cmd_repeat.sh
 create mode 100644 test/py/tests/test_md.py

diff --git a/test/cmd_repeat.sh b/test/cmd_repeat.sh
deleted file mode 100755
index 990e79900f47..000000000000
--- a/test/cmd_repeat.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/sh
-
-# Test for U-Boot cli including command repeat
-
-BASE="$(dirname $0)"
-. $BASE/common.sh
-
-run_test() {
-	./${OUTPUT_DIR}/u-boot <<END
-setenv ctrlc_ignore y
-md 0
-
-reset
-END
-}
-check_results() {
-	echo "Check results"
-
-	grep -q 00000100 ${tmp} || fail "Command did not repeat"
-}
-
-echo "Test CLI repeat"
-echo
-tmp="$(tempfile)"
-build_uboot
-run_test >${tmp}
-check_results ${tmp}
-rm ${tmp}
-echo "Test passed"
diff --git a/test/py/tests/test_md.py b/test/py/tests/test_md.py
new file mode 100644
index 000000000000..94603c7df609
--- /dev/null
+++ b/test/py/tests/test_md.py
@@ -0,0 +1,36 @@
+# Copyright (c) 2015 Stephen Warren
+# Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0
+
+import pytest
+
+ at pytest.mark.buildconfigspec('cmd_memory')
+def test_md(u_boot_console):
+    '''Test that md reads memory as expected, and that memory can be modified
+    using the mw command.'''
+
+    ram_base = u_boot_console.find_ram_base()
+    addr = '%08x' % ram_base
+    val = 'a5f09876'
+    expected_response = addr + ': ' + val
+    u_boot_console.run_command('mw ' + addr + ' 0 10')
+    response = u_boot_console.run_command('md ' + addr + ' 10')
+    assert(not (expected_response in response))
+    u_boot_console.run_command('mw ' + addr + ' ' + val)
+    response = u_boot_console.run_command('md ' + addr + ' 10')
+    assert(expected_response in response)
+
+ at pytest.mark.buildconfigspec('cmd_memory')
+def test_md_repeat(u_boot_console):
+    '''Test command repeat (via executing an empty command) operates correctly
+    for "md"; the command must repeat and dump an incrementing address.'''
+
+    ram_base = u_boot_console.find_ram_base()
+    addr_base = '%08x' % ram_base
+    words = 0x10
+    addr_repeat = '%08x' % (ram_base + (words * 4))
+    u_boot_console.run_command('md %s %x' % (addr_base, words))
+    response = u_boot_console.run_command('')
+    expected_response = addr_repeat + ': '
+    assert(expected_response in response)
-- 
2.7.0



More information about the U-Boot mailing list