File: test_shell_basics.py

package info (click to toggle)
u-boot 2016.11%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 104,408 kB
  • ctags: 428,706
  • sloc: ansic: 1,260,674; asm: 33,807; python: 10,106; perl: 8,014; makefile: 7,111; sh: 1,975; cpp: 1,829; yacc: 604; lex: 363; tcl: 28; sed: 24; awk: 6
file content (42 lines) | stat: -rw-r--r-- 1,602 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 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):
    """Test any shell command."""

    response = u_boot_console.run_command('echo hello')
    assert response.strip() == 'hello'

def test_shell_semicolon_two(u_boot_console):
    """Test two shell commands separate by a semi-colon."""

    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):
    """Test three shell commands separate by a semi-colon, with variable
    expansion dependencies between them."""

    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):
    """Test the "run" shell command."""

    u_boot_console.run_command('setenv foo "setenv monty 1; setenv python 2"')
    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')