summaryrefslogtreecommitdiff
path: root/tests/topotests/lib/ltemplate.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/topotests/lib/ltemplate.py')
-rw-r--r--tests/topotests/lib/ltemplate.py27
1 files changed, 20 insertions, 7 deletions
diff --git a/tests/topotests/lib/ltemplate.py b/tests/topotests/lib/ltemplate.py
index d211be8836..c98bfac9ee 100644
--- a/tests/topotests/lib/ltemplate.py
+++ b/tests/topotests/lib/ltemplate.py
@@ -28,8 +28,8 @@ ltemplate.py: LabN template for FRR tests.
import os
import sys
import platform
+
import pytest
-import imp
# pylint: disable=C0413
# Import topogen and topotest helpers
@@ -39,7 +39,6 @@ from lib.topolog import logger
from lib.lutil import *
# Required to instantiate the topology builder class.
-from mininet.topo import Topo
customize = None
@@ -54,21 +53,33 @@ class LTemplate:
iproute2Ver = None
def __init__(self, test, testdir):
+ pathname = os.path.join(testdir, "customize.py")
global customize
- customize = imp.load_source("customize", os.path.join(testdir, "customize.py"))
+ if sys.version_info >= (3, 5):
+ import importlib.util
+
+ spec = importlib.util.spec_from_file_location("customize", pathname)
+ customize = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(customize)
+ else:
+ import imp
+
+ customize = imp.load_source("customize", pathname)
self.test = test
self.testdir = testdir
self.scriptdir = testdir
- self.logdir = "/tmp/topotests/{0}.test_{0}".format(test)
+ self.logdir = ""
logger.info("LTemplate: " + test)
def setup_module(self, mod):
"Sets up the pytest environment"
# This function initiates the topology build with Topogen...
- tgen = Topogen(customize.ThisTestTopo, mod.__name__)
+ tgen = Topogen(customize.build_topo, mod.__name__)
# ... and here it calls Mininet initialization functions.
tgen.start_topology()
+ self.logdir = tgen.logdir
+
logger.info("Topology started")
try:
self.prestarthooksuccess = customize.ltemplatePreRouterStartHook()
@@ -206,6 +217,7 @@ class ltemplateRtrCmd:
self.resetCounts()
def doCmd(self, tgen, rtr, cmd, checkstr=None):
+ logger.info("doCmd: {} {}".format(rtr, cmd))
output = tgen.net[rtr].cmd(cmd).strip()
if len(output):
self.output += 1
@@ -216,9 +228,10 @@ class ltemplateRtrCmd:
else:
self.match += 1
return ret
- logger.info("command: {} {}".format(rtr, cmd))
logger.info("output: " + output)
- self.none += 1
+ else:
+ logger.info("No output")
+ self.none += 1
return None
def resetCounts(self):