On 2013-3-1 17:20, Alex Jia wrote:
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.
Thanks for reminding me, I will change it to "net_ref"
+ 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".
Oh, yes, I got a wrong idea..:-( Thank you for pointing it out..
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
I will consider the view of the test case above...Thanks..
+ 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".
Good idea, I will change it to what you said..
+ 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
Indeed, I will fix it..
--
1.7.1
--
Regards,
--------------------------------------------------
Li Yang
No. 6 Wenzhu Road, Nanjing, 210012, China
TEL:+86+25-86630566-8526
FUJITSU INTERNAL:7998-8526
FAX:+86+25-83317685
EMail:[email protected]
--------------------------------------------------
This communication is for use by the intended recipient(s) only and may contain
information that is privileged, confidential and exempt from disclosure under
applicable law. If you are not an intended recipient of this communication, you
are hereby notified that any dissemination, distribution or copying hereof is
strictly prohibited. If you have received this communication in error, please
notify me by reply e-mail, permanently delete this communication from your
system, and destroy any hard copies you may have printed
_______________________________________________
Virt-test-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virt-test-devel