2016-01-15 18:15:28 +00:00
|
|
|
# Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
|
|
|
# Test basic shell functionality, such as commands separate by semi-colons.
|
|
|
|
|
|
|
|
def test_shell_execute(u_boot_console):
|
2016-01-26 20:41:30 +00:00
|
|
|
"""Test any shell command."""
|
2016-01-15 18:15:28 +00:00
|
|
|
|
|
|
|
response = u_boot_console.run_command('echo hello')
|
|
|
|
assert response.strip() == 'hello'
|
|
|
|
|
|
|
|
def test_shell_semicolon_two(u_boot_console):
|
2016-01-26 20:41:30 +00:00
|
|
|
"""Test two shell commands separate by a semi-colon."""
|
2016-01-15 18:15:28 +00:00
|
|
|
|
|
|
|
cmd = 'echo hello; echo world'
|
|
|
|
response = u_boot_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(u_boot_console):
|
2016-01-26 20:41:30 +00:00
|
|
|
"""Test three shell commands separate by a semi-colon, with variable
|
|
|
|
expansion dependencies between them."""
|
2016-01-15 18:15:28 +00:00
|
|
|
|
|
|
|
cmd = 'setenv list 1; setenv list ${list}2; setenv list ${list}3; ' + \
|
|
|
|
'echo ${list}'
|
|
|
|
response = u_boot_console.run_command(cmd)
|
|
|
|
assert response.strip() == '123'
|
|
|
|
u_boot_console.run_command('setenv list')
|
|
|
|
|
|
|
|
def test_shell_run(u_boot_console):
|
2016-01-26 20:41:30 +00:00
|
|
|
"""Test the "run" shell command."""
|
2016-01-15 18:15:28 +00:00
|
|
|
|
2016-01-26 20:41:31 +00:00
|
|
|
u_boot_console.run_command('setenv foo "setenv monty 1; setenv python 2"')
|
2016-01-15 18:15:28 +00:00
|
|
|
u_boot_console.run_command('run foo')
|
|
|
|
response = u_boot_console.run_command('echo $monty')
|
|
|
|
assert response.strip() == '1'
|
|
|
|
response = u_boot_console.run_command('echo $python')
|
|
|
|
assert response.strip() == '2'
|
|
|
|
u_boot_console.run_command('setenv foo')
|
|
|
|
u_boot_console.run_command('setenv monty')
|
|
|
|
u_boot_console.run_command('setenv python')
|