def loadPython(self): glb = {"__builtins__": __builtins__, # External / Standard libraries "parser": pyparsing, "os": os, "regex": re, "math": math, "itertools": itertools, "struct": struct, "collections": collections, "fractions": fractions, # nightmare specific things "Test": Test, "Suite": TestSuite, "Mode": TestSuiteMode, "State": TestState, "Expectation": Expectation, "ExpectFile": ExpectFile, "Stringifier": Stringifier, "StringifiedFile": StringifiedFile, "CompareFiles": CompareFiles, # Helping functions "readFile": lambda fname: open(fname).read().rstrip() if os.path.exists(fname) else "File not found", } ctx = {self.options['suite']: None, "DUT": None} execfile(self.options['bench'], glb, ctx) if (self.options['suite'] in ctx): suite = None if 'DUT' in ctx and ctx['DUT'] is not None and self.options['dut'] is None: self.setDUT(ctx['DUT']) if (ctx[self.options['suite']] != None): if ctx[self.options['suite']].__class__ == TestSuite: suite = ctx[self.options['suite']] if suite.DUT is None: suite.setDUT(self.options['dut']) if self.options['mode'] is None: self.options['mode'] = suite.mode elif suite.mode is None: suite.mode = self.options['mode'] else: suite = TestSuite(*ctx[self.options['suite']], **{'DUT': self.options['dut'], 'mode': self.options['mode']}) else: logger.log("Sorry, but I can't find any tests inside the suite '{}'".format(self.options['suite'])) else: logger.log("Sorry, but there was no test-suite in the file") return suite
def loadArnold(self): if syntax is not None: logger.log("\t...using Arnold-Mode") syn = syntax() fileHnd = open(self.options['bench']) content = [] for line in fileHnd: if not line.startswith("#") and not line.strip() == "": content.append(line.replace("ä", "ae").replace("Ä", "Ae").replace("ö", "oe").replace("Ö", "Oe").replace("ü", "ue").replace("Ü", "Ue").replace("ß", "ss")) s = "".join(content) ast = syn.parseString(s) testList = buildTestList(ast) suite = TestSuite(*testList) suite.setDUT(self.options['dut']) else: logger.log("\t ... could not init arnold mode due to missing pyparsing package") suite = None return suite
def getSuite(self): """Returns the suite. If none is loaded a new one will be created""" if self.runsuite is None: self.runsuite = TestSuite(DUT=self.options['dut'], mode=self.options['mode']) return self.runsuite