On 03/01/2013 04:05 PM, liyang wrote:
Signed-off-by: Li Yang <[email protected]>
---
libvirt/tests/virsh_net_name.py | 35
+++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
create mode 100644 libvirt/tests/virsh_net_name.py
diff --git a/libvirt/tests/virsh_net_name.py
b/libvirt/tests/virsh_net_name.py
new file mode 100644
index 0000000..1c7b065
--- /dev/null
+++ b/libvirt/tests/virsh_net_name.py
@@ -0,0 +1,35 @@
+from autotest.client.shared import error
+from virttest import virsh
+
+def run_virsh_net_name(test, params, env):
+ """
+ Test command: virsh net-name.
+
+ The command can convert a network UUID to network name.
+ 1.Get all parameters from config file.
+ 2.Perform virsh net-uuid operation.
+ 3.Confirm the test result.`
+ """
+ vm_ref = params.get("net_name_vm_ref")
'vm_ref' isn't a good name for virtual network.
+ net_name = params.get("net_name_network", "default")
+ extra = params.get("net_name_extra", "")
+ status_error = params.get("status_error")
+
+ net_uuid = virsh.net_uuid(net_name)
+ if vm_ref == "uuid":
+ vm_ref = net_uuid
+ elif vm_ref == "name":
Is it necessary for testing? I think the "default" is just a string type
like "xyz".
In addition, I have ever mentioned a test case of the domain uuid from
libvirt upstream, it's a better reference to you:
http://libvirt.org/git/?p=libvirt.git;a=blob;f=python/tests/uuid.py;h=db48e808152391ef606d22a788c9b514c27ec995;hb=HEAD
+ vm_ref = net_name
+
+ result = virsh.net_name(vm_ref, extra, ignore_status=True)
+ status = result.exit_status
+ output = result.stdout.strip()
+ err = result.stderr.strip()
+
+ #check status_error
+ if status_error == "yes":
+ if status == 0 or err == "":
+ raise error.TestFail("Run successfully with wrong command!")
Also need a 'else' branch to write successful message into log file,
because it's
an important steps, we should record it in the log file, for example,
you may
write it like before "It's an expected error".
+ elif status_error == "no":
+ if status != 0 or output == "":
+ raise error.TestFail("Run failed with right command")
Save as above.
In addition, a strict condition structure is if..elif..else, or if..else
for a simple structure, the if..elif structure will miss other condition
branches, for example:
if status_error == "yes":
xxxx
elif status_error == "no":
xxxx
else:
logging.error("The status must be 'yes' or 'no'")
or
if status_error == "yes":
xxxx
else:
xxxx
--
1.7.1
_______________________________________________
Virt-test-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virt-test-devel