Overall this LGTM, I made one optional suggestions and one observation (re: err == "") below. Nice and simple test, I like it.

On 02/28/2013 03:02 AM, liyang wrote:
diff --git a/libvirt/tests/virsh_net_dumpxml.py
> ...
+    net_status_current = "active"
+    if virsh.net_list("--inactive"):
+        net_status_current = "inactive"
+
+    if net_status == "inactive" and net_status_current == "active":
+        virsh.net_destroy(net_name, ignore_status=True)

Not sure if it's a problem (I didn't try running code yet), but if the network being tested is transient (i.e. came from net-create instead of net-define), then stopping it won't make it "inactive" it will make it *poof* dissapear (i.e. b/c it's not permanent).

Since no exit_status is verified (above) if this happens, then next command is guaranteed to fail. If status_error="yes" then test will pass under false-conditions (i.e. net_dumpxml failed for uncontrolled reason).

Option/suggestion: Consider check & verify the net_destroy() was successful, and to be extra-safe, maybe also check:

virsh.net_state_dict()[net_name]['persistent'] == True

Not critical though because this is probably a corner-case given a controlled testing environment.

+
+    result = virsh.net_dumpxml(vm_ref, extra, ignore_status=True)
+    status = result.exit_status
+    output = result.stdout.strip()
+    err = result.stderr.strip()

IIRC, virsh never uses stderr, always stdout.

+    if extra.find("--") != -1:
+        options = extra.split("--")
+        for option in options:
+            if option.strip() == "":
+                continue
+            if not virsh.has_command_help_match("net-dumpxml",
option.strip()):
+                status_error = "yes"
+                break
+
+    if net_status == "inactive" and net_status_current == "active":
+        virsh.net_start(net_name, ignore_status=True)
+
+    #check status_error
+    if status_error == "yes":
+        if status == 0 or err == "":

I think err will almost always == "" (see comment above). See this in action: virsh.VirshSession.ERROR_REGEX_LIST and cmd_status_output(). Maybe we should make this a generally available function in virsh module so tests can use it to check stdout for error messages? I'll take a look at this more closely after the freeze and fix it as necessary.

+            raise error.TestFail("Run successfully with wrong command!")
+    elif status_error == "no":
+        if status != 0 or output == "":
+            raise error.TestFail("Run failed with right command")

--
Chris Evich, RHCA, RHCE, RHCDS, RHCSS
Quality Assurance Engineer
e-mail: cevich + `@' + redhat.com o: 1-888-RED-HAT1 x44214

_______________________________________________
Virt-test-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virt-test-devel

Reply via email to