def createConfigFile(filepath): platformInstance = platformhandler.getInstance() platformInstance.clearScreen() returnPath = os.getcwd() languages = sorted(os.listdir('languages'), reverse=True) os.chdir('languages') language = selectLanguage(languages) if language is None: return False os.chdir(language) errors, toLookFor = selectErrorsToLookFor() os.chdir(returnPath) if toLookFor is None: return False platformInstance.clearScreen() if not checkConfiguration(language, errors, toLookFor): createConfigFile(filepath) else: option = raw_input("Do you want to add penalties for errors? [Y/n] ") if len(option) is not 0 and option is "N" or option is "n": penalty = False else: penalty = True toLookFor = penaltyhandler.penaltyConfig(toLookFor) writeConfigurationFile(filepath, language, toLookFor, penalty) print "\nRobocheck was succefully configured!" return True
def setUpClass (cls): cls.platform = platformhandler.getInstance() cls.exe = ['test01'] cls.srcsPath = os.path.abspath('./unit-tests/sources') cls.test = 'ValgrindTest01' cls.tool = cls.importTool() cls.sources = 'testValgrind01.c' cls.exesPath = os.path.join (cls.srcsPath, cls.test,'exes')
def setUpClass(cls): global platformName cls.returnPath = os.getcwd() cls.toolInstance = cls.importTool('drmemory') cls.platformInstance = platformhandler.getInstance() cls.platformName = cls.platformInstance.__class__.__name__ cls.sourceFolder = os.path.abspath('./unit-tests/sources') if cls.toolInstance.toolIsInstalled(cls.platformInstance) is False: print "Nothing to test! (tool not installed)" sys.exit(0)
def setUpClass(cls): cls.returnPath = os.getcwd() cls.toolInstance = cls.importTool('drmemory') cls.platformInstance = platformhandler.getInstance() cls.platformInstance.getArchitecture() cls.sourceFolder = os.path.abspath('./unit-tests/sources') cls.tests = ['drmemoryTest01'] # add test folders here cls.currentPath = None cls.currentTest = 0 cls.exitCode = 0
def main(): callerPath = os.getcwd() init(sys.argv[0]) sys.path.insert(0, "platforms") sys.path.insert(0, os.getcwd()) returnPath = os.getcwd() platformInstance = platformhandler.getInstance() if platformInstance is None: print "ERROR: Your OS is not supported by Robocheck" return if len(sys.argv) != 2 or "--help" in sys.argv: helpMessage() exit() configFilePath = os.path.abspath('config.json') if "--config" in sys.argv: configuration.createConfigFile(configFilePath) return cleanUp(platformInstance) couldRead = configuration.readConfigFile(configFilePath) if couldRead is False: return language = configuration.getLanguage() errorsToLookFor = configuration.getErrorsToLookFor() tools = modulehandler.getCompatibleModules(language, errorsToLookFor, platformInstance) os.mkdir(platformInstance.getTempPath() + "current-robocheck-test") os.chdir(callerPath) try: platformInstance.zipExtractAll(sys.argv[1]) except Exception: print "ERROR: Archive was not Zip format or it was corrupted!" exit() platformInstance.cdToTemp() errorJsonList = [] os.chdir("current-robocheck-test") try: sources = os.listdir('src') exes = os.listdir('bins') except Exception: print "ERROR: Archive did not have the expected folders!" cleanUp(platformInstance) exit() exesPath = "bins" srcsPath = 'src' errorList = [] for tool in tools: errors = tool.runToolGetErrors(platformInstance, exes, sources, exesPath, srcsPath, errorsToLookFor) errorsToLookFor = getRemainingErrors(errorsToLookFor, errors) for err in errors: if err not in errorList: errorList.append(err) errorJsonList = configuration.getJson(errorList) errorJsonList = dict([("ErrorsFound",errorJsonList)]) print json.dumps(errorJsonList, indent=2) os.chdir(callerPath) jsonOutput = open('robocheck-output.json', 'w') jsonOutput.write(json.dumps(errorJsonList, indent=2)) jsonOutput.close() cleanUp(platformInstance)