[U-Boot] [PATCH 09/14] test/py: Provide a way to check that a command fails

Stephen Warren swarren at wwwdotorg.org
Thu Jul 7 19:03:51 CEST 2016


On 07/03/2016 09:40 AM, Simon Glass wrote:
> Sometimes we want to run a command and check that it fails. Add a function
> to handle this. It can check the return code and also make sure that the
> output contains a given error message.

> diff --git a/test/py/u_boot_utils.py b/test/py/u_boot_utils.py

> +def run_and_log_expect_exception(u_boot_console, cmd, retcode, msg):
> +    """Run a command which is expected to fail.
> +
> +    This runs a command and checks that it fails with the expected return code
> +    and exception method. If not, an exception is raised.
> +
> +    Args:
> +        u_boot_console: A console connection to U-Boot.
> +        cmd: The command to run, as an array of argv[].
> +        retcode: Expected non-zero return code from the command.
> +        msg: String which should be contained within the command's output.
> +    """

retcode isn't used anywhere. Do we care what the return code is, so long 
as it's something non-zero, and the desired exception message appears?


More information about the U-Boot mailing list