#!/usr/bin/python # program to execute steps of a testcase # PARAM: --environment --application --tcdir [ testcase, tctime ] # main functions # + reset_testcase() : comp-config --> system # + load_testcase() : testspec --> tdata --> system.data # + select_testcase() : system.data --> data --> archiv.result # ---------------------------------------------------import os import traceback import basic.program as program #import tools.tdata_tool as tdata_tool import basic.componentHandling import basic.constants as B import tools.file_tool as file_tool import tools.path_tool as path_tool import tools.path_const as P import basic.message as message PROGRAM_NAME = "init_testcase" def startPyJob(job): try: cm = basic.componentHandling.ComponentManager.getInstance(job) cm.initComponents() comps = cm.getComponents(PROGRAM_NAME) job.m.setMsg("# Components initialized with these relevant components " + str(comps)) testdata = "" # tdata_tool.getTestdata(job) print("------------------------------------------------------------") for c in comps: comp = cm.getComponent(c) comp.m.logInfo("------- "+comp.name+" ----------------------------------------") try: if job.hasFunction("reset_TData"): comp.reset_TData(job, B.PAR_TESTCASE) if job.hasFunction("load_TData"): comp.load_TData(job, B.PAR_TESTCASE, testdata) if job.hasFunction("read_TData"): comp.read_TData(job, path_tool.getKeyValue(job, P.KEY_PRECOND), B.PAR_TESTCASE) except Exception as e: txt = traceback.format_exc() job.m.setFatal("Exception "+str(e)+"\n"+txt) print("Exception " + str(e)+"\n"+txt) job.stopJob(0) comp.m.logInfo("------- "+comp.name+" ----------------------------------------") job.m.merge(comp.m) print(str(comp)) comp.conf["function"][PROGRAM_NAME] = comp.m.topmessage except Exception as e: job.m.logDebug("+++++++++++++++++++++++++++++++++++++++++++++") job.m.setFatal(str(e)) job.m.logDebug("+++++++++++++++++++++++++++++++++++++++++++++") job.m.logDebug("execpt "+traceback.format_exc()) job.m.logDebug("+++++++++++++++++++++++++++++++++++++++++++++") # Press the green button in the gutter to run the script. if __name__ == '__main__': print(PROGRAM_NAME) x = program.Job(PROGRAM_NAME) x.startJob() x.m.logDebug(str(vars(x.par)) + "\n" + str(vars(x.conf))) if x.m.isRc("fatal"): x.stopJob() exit(x.m.rc * (-1) + 3) startPyJob(x) x.stopJob() # See PyCharm help at https://www.jetbrains.com/help/pycharm/