]> git.ipfire.org Git - people/ms/u-boot.git/blame - test/py/tests/test_shell_basics.py
test/py: use " for docstrings
[people/ms/u-boot.git] / test / py / tests / test_shell_basics.py
CommitLineData
8b86c609
SW
1# Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
2#
3# SPDX-License-Identifier: GPL-2.0
4
5# Test basic shell functionality, such as commands separate by semi-colons.
6
7def test_shell_execute(u_boot_console):
e8debf39 8 """Test any shell command."""
8b86c609
SW
9
10 response = u_boot_console.run_command('echo hello')
11 assert response.strip() == 'hello'
12
13def test_shell_semicolon_two(u_boot_console):
e8debf39 14 """Test two shell commands separate by a semi-colon."""
8b86c609
SW
15
16 cmd = 'echo hello; echo world'
17 response = u_boot_console.run_command(cmd)
18 # This validation method ignores the exact whitespace between the strings
19 assert response.index('hello') < response.index('world')
20
21def test_shell_semicolon_three(u_boot_console):
e8debf39
SW
22 """Test three shell commands separate by a semi-colon, with variable
23 expansion dependencies between them."""
8b86c609
SW
24
25 cmd = 'setenv list 1; setenv list ${list}2; setenv list ${list}3; ' + \
26 'echo ${list}'
27 response = u_boot_console.run_command(cmd)
28 assert response.strip() == '123'
29 u_boot_console.run_command('setenv list')
30
31def test_shell_run(u_boot_console):
e8debf39 32 """Test the "run" shell command."""
8b86c609
SW
33
34 u_boot_console.run_command('setenv foo \"setenv monty 1; setenv python 2\"')
35 u_boot_console.run_command('run foo')
36 response = u_boot_console.run_command('echo $monty')
37 assert response.strip() == '1'
38 response = u_boot_console.run_command('echo $python')
39 assert response.strip() == '2'
40 u_boot_console.run_command('setenv foo')
41 u_boot_console.run_command('setenv monty')
42 u_boot_console.run_command('setenv python')