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