[U-Boot] [PATCH V2 5/7] test/py: add test of basic shell functionality
Stephen Warren
swarren at wwwdotorg.org
Wed Dec 2 23:18:26 CET 2015
From: Stephen Warren <swarren at nvidia.com>
This tests whether the following features of the U-Boot shell:
- Execution of a directly entered command.
- Compound commands (; delimiter).
- Quoting of arguments containing spaces.
- Executing commands from environment variables.
Signed-off-by: Stephen Warren <swarren at nvidia.com>
---
test/py/test_shell_basics.py | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
create mode 100644 test/py/test_shell_basics.py
diff --git a/test/py/test_shell_basics.py b/test/py/test_shell_basics.py
new file mode 100644
index 000000000000..f47f840432e0
--- /dev/null
+++ b/test/py/test_shell_basics.py
@@ -0,0 +1,35 @@
+# Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0
+
+def test_shell_execute(uboot_console):
+ """Test any shell command"""
+ response = uboot_console.run_command("echo hello")
+ assert response.strip() == "hello"
+
+def test_shell_semicolon_two(uboot_console):
+ """Test two shell commands separate by a semi-colon"""
+ cmd = "echo hello; echo world"
+ response = uboot_console.run_command(cmd)
+ # This validation method ignores the exact whitespace between the strings
+ assert response.index("hello") < response.index("world")
+
+def test_shell_semicolon_three(uboot_console):
+ """Test three shell commands separate by a semi-colon"""
+ cmd = "setenv list 1; setenv list ${list}2; setenv list ${list}3; " + \
+ "echo ${list}"
+ response = uboot_console.run_command(cmd)
+ assert response.strip() == "123"
+ uboot_console.run_command("setenv list")
+
+def test_shell_run(uboot_console):
+ """Test the 'run' shell command"""
+ uboot_console.run_command("setenv foo 'setenv monty 1; setenv python 2'")
+ uboot_console.run_command("run foo")
+ response = uboot_console.run_command("echo $monty")
+ assert response.strip() == "1"
+ response = uboot_console.run_command("echo $python")
+ assert response.strip() == "2"
+ uboot_console.run_command("setenv foo")
+ uboot_console.run_command("setenv monty")
+ uboot_console.run_command("setenv python")
--
2.6.3
More information about the U-Boot
mailing list