Skip to content

Commit

Permalink
libvirt.virsh_uri: Fixes to the virsh_uri libvirt test
Browse files Browse the repository at this point in the history
Signed-off-by: Lucas Meneghel Rodrigues <[email protected]>
  • Loading branch information
lmr committed Mar 3, 2012
1 parent a499ca9 commit 1c3b9f9
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions libvirt/tests/virsh_uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def run_virsh_uri(test, params, env):

def virsh_uri(cmd):
cmd_result = utils.run(cmd, ignore_status=True)
logging.debug("Output: %s", cmd_result.stdout.strip())
logging.debug("Error: %s", cmd_result.stderr.strip())
logging.debug("Status: %d", cmd_result.exit_status)
logging.info("Output: %s", cmd_result.stdout.strip())
logging.error("Error: %s", cmd_result.stderr.strip())
logging.info("Status: %d", cmd_result.exit_status)
return cmd_result.exit_status, cmd_result.stdout.strip()

# Prepare libvirtd service
Expand All @@ -31,10 +31,12 @@ def virsh_uri(cmd):
check_target_uri = params.has_key("target_uri")
if check_target_uri:
target_uri = params.get("target_uri")
logging.info("The target_uri: %s", target_uri)
cmd = "virsh -c %s uri" % target_uri
else:
cmd = "virsh uri %s" % option

logging.info("The command: %s", cmd)
status, uri_test = virsh_uri(cmd)

# Recover libvirtd service start
Expand All @@ -45,11 +47,13 @@ def virsh_uri(cmd):
status_error = params.get("status_error")
if status_error == "yes":
if status == 0:
raise error.TestFail("Command 'virsh uri %s' succeeded "
"(incorrect command)" % option)
raise error.TestFail("Command: %s succeeded "
"(incorrect command)" % cmd)
else:
logging.info("command: %s is a expected error", cmd)
elif status_error == "no":
if cmp(target_uri, uri_test) != 0:
raise error.TestFail("Virsh cmd gives wrong uri.")
if status != 0:
raise error.TestFail("Command 'virsh uri %s' failed "
"(correct command)" % option)
raise error.TestFail("Command: %s failed "
"(correct command)" % cmd)

0 comments on commit 1c3b9f9

Please sign in to comment.