From 29e110a2cfb4bb240b32ddac6e62aa2318e10b5c Mon Sep 17 00:00:00 2001 From: Niklas Hambuechen Date: Wed, 8 Oct 2014 14:15:00 +0200 Subject: [PATCH] qa_utils: Allow passing fail=None to AssertCommand This is for cases where we don't care about the exit code. Signed-off-by: Niklas Hambuechen Reviewed-by: Klaus Aehlig Cherry-picked-from: 226455df57247d52b8f26bf9e2562644f6e18892 Signed-off-by: Hrvoje Ribicic Reviewed-by: Klaus Aehlig --- qa/qa_utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/qa/qa_utils.py b/qa/qa_utils.py index 102832e55..5ed9ebab3 100644 --- a/qa/qa_utils.py +++ b/qa/qa_utils.py @@ -155,8 +155,9 @@ def AssertCommand(cmd, fail=False, node=None, log_cmd=True, max_seconds=None): @param cmd: either a string (the command to execute) or a list (to be converted using L{utils.ShellQuoteArgs} into a string) - @type fail: boolean - @param fail: if the command is expected to fail instead of succeeding + @type fail: boolean or None + @param fail: if the command is expected to fail instead of succeeding, + or None if we don't care @param node: if passed, it should be the node on which the command should be executed, instead of the master node (can be either a dict or a string) @@ -185,7 +186,8 @@ def AssertCommand(cmd, fail=False, node=None, log_cmd=True, max_seconds=None): stdout, stderr = popen.communicate() rcode = popen.returncode duration_seconds = TimedeltaToTotalSeconds(datetime.datetime.now() - start) - _AssertRetCode(rcode, fail, cmdstr, nodename) + if fail is not None: + _AssertRetCode(rcode, fail, cmdstr, nodename) if max_seconds is not None: if duration_seconds > max_seconds: -- GitLab