]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib: ltemplate simplify start/stop
authorLou Berger <lberger@labn.net>
Sat, 27 Jan 2018 22:00:58 +0000 (17:00 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 28 Nov 2018 01:22:13 +0000 (20:22 -0500)
Signed-off-by: Lou Berger <lberger@labn.net>
tests/topotests/lib/ltemplate.py

index c141ef75850481aa7fd18b97e5e470a186861b86..30ff2cd7f6e70dc8afdf278c2a0e48edd65d7048 100644 (file)
@@ -43,15 +43,18 @@ from mininet.topo import Topo
 customize = None
 
 class LTemplate():
-    scriptdir = None
     test = None
     testdir = None
+    scriptdir = None
+    logdir = None
 
     def __init__(self, test, testdir):
         global customize
         customize = imp.load_source('customize', os.path.join(testdir, 'customize.py'))
         self.test = test
         self.testdir = testdir
+        self.scriptdir = testdir
+        self.logdir = '/tmp/topotests/{0}.test_{0}'.format(test)
         logger.info('LTemplate: '+test)
 
     def setup_module(self, mod):
@@ -95,6 +98,7 @@ class LTemplate():
         except NameError:
             #not defined
             logger.debug("ltemplatePostRouterStartHook() not defined")
+        luStart(baseScriptDir=self.scriptdir, baseLogDir=self.logdir, net=tgen.net)
 
 #initialized by ltemplate_start
 _lt = None
@@ -122,19 +126,16 @@ def setup_module(mod):
     #sys.path.remove(testdir)
 
 def teardown_module(mod):
+    global _lt
     "Teardown the pytest environment"
     tgen = get_topogen()
 
+    if _lt != None and _lt.scriptdir != None:
+        print(luFinish())
+
     # This function tears down the whole topology.
     tgen.stop_topology()
-
-def ltemplate_start(testDir):
-    logger.info('ltemplate start in ' + testDir)
-    test = os.path.basename(testDir)
-    logDir = '/tmp/topotests/{0}.test_{0}'.format(test)
-    tgen = get_topogen()
-    luStart(baseScriptDir=testDir, baseLogDir=logDir, net=tgen.net)
-    _lt.scriptdir = testDir
+    _lt = None
 
 def ltemplateTest(script, SkipIfFailed=True, CallOnFail=None, CheckFuncStr=None):
     tgen = get_topogen()
@@ -173,16 +174,6 @@ def test_memory_leak():
 
     tgen.report_memory_leaks()
 
-#clean up ltemplate
-
-def test_ltemplate_finish():
-    global _lt
-    logger.info('Done with ltemplate tests')
-    if _lt != None and _lt.scriptdir != None:
-        print(luFinish())
-    #done
-    _lt = None
-
 #for testing
 if __name__ == '__main__':
     args = ["-s"] + sys.argv[1:]