16 Aug, 2017

1 commit

  • We are now using an env_ prefix for environment functions. Rename these
    two functions for consistency. Also add function comments in common.h.

    Quite a few places use getenv() in a condition context, provoking a
    warning from checkpatch. These are fixed up in this patch also.

    Suggested-by: Wolfgang Denk
    Signed-off-by: Simon Glass

    Simon Glass
     

25 Jun, 2016

1 commit


21 Jan, 2016

3 commits

  • Migrate all most tests from command_ut.c into the Python test system.
    This allows the tests to be run against any U-Boot binary that supports
    the if command (i.e. where hush is enabled) without requiring that
    binary to be permanently bloated with the code from command_ut.

    Some tests in command_ut.c can only be executed from C code, since they
    test internal (more unit-level) features of various U-Boot APIs. The
    migrated tests can all operate directly from the U-Boot console.

    Signed-off-by: Stephen Warren
    Acked-by: Simon Glass

    Stephen Warren
     
  • This tests whether the following features of the U-Boot shell:
    - Execution of a directly entered command.
    - Compound commands (; delimiter).
    - Quoting of arguments containing spaces.
    - Executing commands from environment variables.

    Signed-off-by: Stephen Warren
    Acked-by: Simon Glass

    Stephen Warren
     
  • This tests basic environment variable functionality.

    Signed-off-by: Stephen Warren
    Signed-off-by: Stephen Warren
    Acked-by: Simon Glass

    Stephen Warren
     

08 Nov, 2014

2 commits


27 Oct, 2014

1 commit

  • The run command treats each argument an an environment variable. It gets the
    value of each variable and executes it as a command. If an environment
    variable contains a newline and the hush cli is used, it is supposed to
    execute each line one after the other.

    Normally a newline signals to hush to exit - this is used in normal command
    line entry - after a command is entered we want to return to allow the user
    to enter the next one. But environment variables obviously need to execute
    to completion.

    Add a special case for the execution of environment variables which
    continues when a newline is seen, and add a few tests to check this
    behaviour.

    Note: it's not impossible that this may cause regressions in other areas.
    I can't think of a case but with any change of behaviour with limited test
    coverage there is always a risk. From what I can tell this behaviour has
    been around since at least U-Boot 2011.03, although this pre-dates sandbox
    and I have not tested it on real hardware.

    Reported-by: Wolfgang Denk
    Signed-off-by: Simon Glass

    Simon Glass
     

24 Jun, 2014

1 commit

  • Commit 95fac6ab4589 "sandbox: Use os functions to read host device tree"
    removed the ability for get_device_and_partition() to handle the "host"
    device type, and redirect accesses to it to the host filesystem. This
    broke some unit tests that use this feature. So, revert that change. The
    code added back by this patch is slightly different to pacify checkpatch.

    However, we're then left with "host" being both:
    - A pseudo device that accesses the hosts real filesystem.
    - An emulated block device, which accesses "sectors" inside a file stored
    on the host.

    In order to resolve this discrepancy, rename the pseudo device from host
    to hostfs, and adjust the unit-tests for this change.

    The "help sb" output is modified to reflect this rename, and state where
    the host and hostfs devices should be used.

    Signed-off-by: Stephen Warren
    Tested-by: Josh Wu
    Acked-by: Simon Glass
    Tested-by: Simon Glass

    Stephen Warren
     

06 Jun, 2014

1 commit


07 Mar, 2014

3 commits

  • The unit-test for hush's "test -e" currently relies upon being run in
    the U-Boot build directory, because it tests for the existence of a file
    that exists in that directory.

    Fix this by explicitly creating the file we use for the existence test,
    and deleting it afterwards so that multiple successive unit-test
    invocations succeed. This required adding an os.c function to erase
    files.

    Reported-by: Simon Glass
    Signed-off-by: Stephen Warren

    Stephen Warren
     
  • The following shell command fails:

    if test -z "$x"; then echo "zero"; else echo "non-zero"; fi

    (assuming $x does not exist, it prints "non-zero" rather than "zero").

    ... since "$x" expands to nothing, and the argument is completely
    dropped, causing too few to be passed to -z, causing cmd_test() to
    error out early.

    This is because when variable expansions are processed by make_string(),
    the expanded results are concatenated back into a new string. However,
    no quoting is applied when doing so, so any empty variables simply don't
    generate any parameter when the combined string is parsed again.

    Fix this by explicitly replacing quoting any argument that was originally
    quoted when re-generating a string from the already-parsed argument list.

    This also fixes loss of whitespace in commands such as:

    setenv space " "
    setenv var " 1${space}${space} 2 "
    echo ">>${var}<
    Acked-by: Simon Glass
    Signed-off-by: Stephen Warren

    Stephen Warren
     
  • Delete the temporary variables that are used to save unit-test results
    from the environment after running the test. This prevents polluting
    the environment, or growing it too much.

    Signed-off-by: Stephen Warren
    Acked-by: Simon Glass

    Stephen Warren
     

19 Feb, 2014

2 commits


24 Jul, 2013

1 commit


10 Aug, 2012

1 commit

  • Since run_command() and run_command_list() are important and a little
    confusing, add some basic tests to check that the behaviour is correct.

    Note: I am not sure that this should be committed, nor where it should go
    in the source tree. Comments welcome.

    To run the unit tests use the ut_cmd command available in sandbox:

    make sandbox_config
    make
    ./u-boot -c ut_cmd

    (To test both hush and built-in parsers, you need to manually change
    CONFIG_SYS_HUSH_PARSER in include/configs/sandbox.h and build/run again)

    Signed-off-by: Simon Glass

    Simon Glass