From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Warren Date: Thu, 7 Jul 2016 11:03:51 -0600 Subject: [U-Boot] [PATCH 09/14] test/py: Provide a way to check that a command fails In-Reply-To: <1467560446-10628-10-git-send-email-sjg@chromium.org> References: <1467560446-10628-1-git-send-email-sjg@chromium.org> <1467560446-10628-10-git-send-email-sjg@chromium.org> Message-ID: <577E8B77.9020605@wwwdotorg.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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?