From af01532c458062a14f24b91f5a7c380ef0380ee2 Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Thu, 9 Aug 2018 10:52:48 -0400 Subject: [PATCH] lib: speedup test exit when startup fails Signed-off-by: Lou Berger --- tests/topotests/lib/ltemplate.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/topotests/lib/ltemplate.py b/tests/topotests/lib/ltemplate.py index 5843b4096a..31eaec7009 100644 --- a/tests/topotests/lib/ltemplate.py +++ b/tests/topotests/lib/ltemplate.py @@ -74,6 +74,9 @@ class LTemplate(): except AttributeError: #not defined logger.debug("ltemplatePreRouterStartHook() not defined") + if self.prestarthooksuccess != True: + logger.info('ltemplatePreRouterStartHook() failed, skipping test') + return # This is a sample of configuration loading. router_list = tgen.routers() @@ -137,7 +140,7 @@ def teardown_module(mod): "Teardown the pytest environment" tgen = get_topogen() - if _lt != None and _lt.scriptdir != None: + if _lt != None and _lt.scriptdir != None and _lt.prestarthooksuccess == True: print(luFinish()) # This function tears down the whole topology. @@ -145,6 +148,10 @@ def teardown_module(mod): _lt = None def ltemplateTest(script, SkipIfFailed=True, CallOnFail=None, CheckFuncStr=None, KeepGoing=False): + global _lt + if _lt == None or _lt.prestarthooksuccess != True: + return + tgen = get_topogen() if not os.path.isfile(script): if not os.path.isfile(os.path.join(_lt.scriptdir, script)): -- 2.39.5