Nir Soffer has uploaded a new change for review.

Change subject: tests: Fix error handling when checking dependencies
......................................................................

tests: Fix error handling when checking dependencies

We used to hide *all* exceptions and skip the tests with possible bogus
message.

When trying brctl, we skip the test only if we cannot run it, since this
is the only error that can cause by missing bridge-utils. Any other
error should fail the tests.

When trying tc, we show the failure in the error message.

Also removed pointless code opening and closing /dev/null.

Change-Id: I180ba6449009dc986d2df58958039e2324d2191f
Signed-off-by: Nir Soffer <nsof...@redhat.com>
---
M tests/tcTests.py
1 file changed, 9 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/10/44110/1

diff --git a/tests/tcTests.py b/tests/tcTests.py
index c5f35cb..92bf4d7 100644
--- a/tests/tcTests.py
+++ b/tests/tcTests.py
@@ -19,6 +19,7 @@
 # Refer to the README and COPYING files for full details of the license
 #
 
+import errno
 import random
 import time
 import string
@@ -178,18 +179,18 @@
     dev = _Bridge()
     try:
         dev.addDevice()
-    except:
-        raise SkipTest("'brctl' has failed. Do you have bridge-utils "
-                       "installed?")
+    except OSError as e:
+        if e.errno == errno.ENOENT:
+            raise SkipTest("Cannot run %r: %s\nDo you have bridge-utils "
+                           "installed?" % (EXT_BRCTL, e))
+        raise
 
-    null = open("/dev/null", "a")
     try:
         check_call([EXT_TC, 'qdisc', 'add', 'dev', dev.devName, 'ingress'])
-    except:
-        raise SkipTest("'tc' has failed. Do you have Traffic Control kernel "
-                       "modules installed?")
+    except ExecError as e:
+        raise SkipTest("%r has failed: %s\nDo you have Traffic Control kernel "
+                       "modules installed?" % (EXT_TC, e.err))
     finally:
-        null.close()
         dev.delDevice()
 
 


-- 
To view, visit https://gerrit.ovirt.org/44110
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I180ba6449009dc986d2df58958039e2324d2191f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsof...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to