1 # Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
3 # SPDX-License-Identifier: GPL-2.0
5 # Test basic shell functionality, such as commands separate by semi-colons.
9 pytestmark = pytest.mark.buildconfigspec('cmd_echo')
11 def test_shell_execute(u_boot_console):
12 """Test any shell command."""
14 response = u_boot_console.run_command('echo hello')
15 assert response.strip() == 'hello'
17 def test_shell_semicolon_two(u_boot_console):
18 """Test two shell commands separate by a semi-colon."""
20 cmd = 'echo hello; echo world'
21 response = u_boot_console.run_command(cmd)
22 # This validation method ignores the exact whitespace between the strings
23 assert response.index('hello') < response.index('world')
25 def test_shell_semicolon_three(u_boot_console):
26 """Test three shell commands separate by a semi-colon, with variable
27 expansion dependencies between them."""
29 cmd = 'setenv list 1; setenv list ${list}2; setenv list ${list}3; ' + \
31 response = u_boot_console.run_command(cmd)
32 assert response.strip() == '123'
33 u_boot_console.run_command('setenv list')
35 def test_shell_run(u_boot_console):
36 """Test the "run" shell command."""
38 u_boot_console.run_command('setenv foo "setenv monty 1; setenv python 2"')
39 u_boot_console.run_command('run foo')
40 response = u_boot_console.run_command('echo $monty')
41 assert response.strip() == '1'
42 response = u_boot_console.run_command('echo $python')
43 assert response.strip() == '2'
44 u_boot_console.run_command('setenv foo')
45 u_boot_console.run_command('setenv monty')
46 u_boot_console.run_command('setenv python')