make test: Fix too wide subprocess exceptions 59/16159/2
authorPaul Vinciguerra <pvinci@vinciconsulting.com>
Sun, 25 Nov 2018 05:19:38 +0000 (21:19 -0800)
committerOle Trøan <otroan@employees.org>
Sun, 25 Nov 2018 18:33:50 +0000 (18:33 +0000)
When a command fails, CalledProcessError is raised. testing with except: masks other failures.

Change-Id: I7e3a6739411cb6a4c13e96dd123aff9159213fea
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
test/framework.py
test/test_jvpp.py
test/test_vcl.py

index 3c4aacb..c29346b 100644 (file)
@@ -348,7 +348,7 @@ class VppTestCase(unittest.TestCase):
                                        stdout=subprocess.PIPE,
                                        stderr=subprocess.PIPE,
                                        bufsize=1)
-        except Exception as e:
+        except subprocess.CalledProcessError as e:
             cls.logger.critical("Couldn't start vpp: %s" % e)
             raise
 
index 36dbdb2..6151ebd 100644 (file)
@@ -135,7 +135,7 @@ class TestJVpp(VppTestCase):
         self.logger.info("Process output : {0}{1}".format(os.linesep, out))
 
         if self.process.returncode != 0:
-            raise Exception(
+            raise subprocess.CalledProcessError(
                 "Command {0} failed with return code: {1}.{2}"
                 "Process error output: {2}{3}"
                 .format(command, self.process.returncode, os.linesep, err))
index fb358b7..6027ba7 100644 (file)
@@ -251,7 +251,7 @@ class VCLCutThruTestCase(VCLTestCase):
 
         try:
             subprocess.check_output(['iperf3', '-v'])
-        except:
+        except subprocess.CalledProcessError:
             self.logger.error("WARNING: 'iperf3' is not installed,")
             self.logger.error("         'test_ldp_cut_thru_iperf3' not run!")
             return
@@ -496,7 +496,7 @@ class VCLThruHostStackIperfTestCase(VCLTestCase):
 
         try:
             subprocess.check_output(['iperf3', '-v'])
-        except:
+        except subprocess.CalledProcessError:
             self.logger.error("WARNING: 'iperf3' is not installed,")
             self.logger.error(
                 "         'test_ldp_thru_host_stack_iperf3' not run!")
@@ -811,7 +811,7 @@ class VCLIpv6ThruHostStackIperfTestCase(VCLTestCase):
 
         try:
             subprocess.check_output(['iperf3', '-v'])
-        except:
+        except subprocess.CalledProcessError:
             self.logger.error("WARNING: 'iperf3' is not installed,")
             self.logger.error(
                 "         'test_ldp_thru_host_stack_iperf3' not run!")