From 94324e3f46bf7673e9892f2ad82eae1666af93b4 Mon Sep 17 00:00:00 2001
From: Bob Lantz <rlantz@cs.stanford.edu>
Date: Mon, 26 Aug 2013 15:08:11 -0700
Subject: [PATCH] Skip IVS and UserSwitch tests if they are not installed

---
 mininet/test/test_hifi.py | 4 ++++
 mininet/test/test_nets.py | 5 +++++
 2 files changed, 9 insertions(+)

diff --git a/mininet/test/test_hifi.py b/mininet/test/test_hifi.py
index e881f3aa..542e0099 100755
--- a/mininet/test/test_hifi.py
+++ b/mininet/test/test_hifi.py
@@ -11,6 +11,7 @@
 from mininet.link import TCLink
 from mininet.topo import Topo
 from mininet.log import setLogLevel
+from mininet.util import quietRun
 
 # Number of hosts for each test
 N = 2
@@ -125,10 +126,13 @@ class testOptionsTopoOVSKernel( testOptionsTopoCommon, unittest.TestCase ):
     "Verify ability to create networks with host and link options (OVS kernel switch)."
     switchClass = OVSKernelSwitch
 
+@unittest.skipUnless( quietRun( 'which ivs-ctl' ), 'IVS is not installed' )
 class testOptionsTopoIVS( testOptionsTopoCommon, unittest.TestCase ):
     "Verify ability to create networks with host and link options (IVS switch)."
     switchClass = IVSSwitch
 
+@unittest.skipUnless( quietRun( 'which ofprotocol' ),
+                     'Reference user switch is not installed' )
 class testOptionsTopoUserspace( testOptionsTopoCommon, unittest.TestCase ):
     "Verify ability to create networks with host and link options (Userspace switch)."
     switchClass = UserSwitch
diff --git a/mininet/test/test_nets.py b/mininet/test/test_nets.py
index 027bdd49..45fc3eb2 100755
--- a/mininet/test/test_nets.py
+++ b/mininet/test/test_nets.py
@@ -10,6 +10,7 @@
 from mininet.node import UserSwitch, OVSKernelSwitch, IVSSwitch
 from mininet.topo import SingleSwitchTopo, LinearTopo
 from mininet.log import setLogLevel
+from mininet.util import quietRun
 
 
 class testSingleSwitchCommon( object ):
@@ -53,14 +54,18 @@ def testLinear5( self ):
         dropped = mn.run( mn.ping )
         self.assertEqual( dropped, 0 )
 
+
 class testLinearOVSKernel( testLinearCommon, unittest.TestCase ):
     "Test all-pairs ping with LinearNet (OVS kernel switch)."
     switchClass = OVSKernelSwitch
 
+@unittest.skipUnless( quietRun( 'which ivs-ctl' ), 'IVS is not installed' )
 class testLinearIVS( testLinearCommon, unittest.TestCase ):
     "Test all-pairs ping with LinearNet (IVS switch)."
     switchClass = IVSSwitch
 
+@unittest.skipUnless( quietRun( 'which ofprotocol' ),
+                      'Reference user switch is not installed' )
 class testLinearUserspace( testLinearCommon, unittest.TestCase ):
     "Test all-pairs ping with LinearNet (Userspace switch)."
     switchClass = UserSwitch
-- 
GitLab