from datetime import datetime import basic.program import basic.program as program import utils.tdata_tool import init_testcase import init_testsuite import execute_testcase import finish_testsuite PROGRAM_NAME = "test_executer" myjob = None testcases = [] testinstances = {} def getTime(): time = datetime.now().strftime("%Y-%m-%d_%H-%M-%S") return time def start(myjob): myjob.m.setMsg("# # # # # start executer # # # # # ") tdata = utils.tdata_tool.getTestdata() job = basic.program.Job("unit") testcases = getattr(myjob.par, "testcases") if not hasattr(myjob.par, "step"): raise Exception("Parameter step is missing") for step in tdata["_steps"]: if int(step["_nr"]) != int(getattr(myjob.par, "step")): continue for arg in step["args"]: if arg == "start": if "testsuite" in step["args"][arg]: jobargs = {"application": myjob.par.application, "environment": myjob.par.environment, "usecase": myjob.par.usecase, "tstime": utils.date_tool.getActdate(utils.date_tool.F_DIR)} job.popInstance() job = basic.program.Job("unit") job.par.setParameterArgs(jobargs) job.setProgram(step["args"][arg]) print("Job initialisiert "+job.program+" in Verzeichnis "+getattr(job.par, "tsdir")) myjob.m.logInfo("Job initialisiert "+job.program+" in Verzeichnis "+getattr(job.par, "tsdir")) dirname = getattr(job.par, "tsdir") job.stopJob(1) job.popInstance() basic.program.Job.pushInstance(myjob) print("ende") job = myjob if "testcase" in step["args"][arg]: if step["comp"] in testcases: jobargs = {"application": myjob.par.application, "environment": myjob.par.environment, "tcdir": testcases[step["comp"]] } else: jobargs = {"application": myjob.par.application, "environment": myjob.par.environment, "testcase": step["comp"], "tctime": utils.date_tool.getActdate(utils.date_tool.F_DIR)} job.popInstance() job = basic.program.Job("unit") job.par.setParameterArgs(jobargs) job.setProgram(step["args"][arg]) print("Job initialisiert "+job.program+" in Verzeichnis "+getattr(job.par, "tcdir")) myjob.m.logInfo("Job initialisiert "+job.program+" in Verzeichnis "+getattr(job.par, "tcdir")) dirname = getattr(job.par, "tcdir") testcases[step["comp"]] = dirname job.stopJob(1) job.popInstance() basic.program.Job.pushInstance(myjob) print("ende") job = myjob if arg == "report": # testsuite basic.program.Job.pushInstance(myjob) pass basic.program.Job.pushInstance(myjob) setattr(myjob.par, "testcases", testcases) # myjob.stopJob(1) if __name__ == '__main__': print(PROGRAM_NAME) x = program.Job(PROGRAM_NAME) #m = message.Message(3) #m.closeMessage() x.startJob() x.m.logInfo("hier eine LogInfo") x.m.logDebug("hier eine DbugMeldung") 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) start(x) x.stopJob()