def execute(lang, type): global packageMap packageMap = {} expSet = resfile.MakeStdExpansionSet('java', lang, 'impl') expSet = resfile.AppendToExpandsionSet(expSet, '', ['dtcoff', 'dtcon']) resfile.RegisterExpansionSet(expSet) util.SetProfileBaseName("gmon-cpp-" + lang + "-" + type + "-" + cmdline.StartDate()) if (type == 'spec'): executeSpec(lang) else: executeImpl(lang)
def execute(lang, type): for dtc in ['dtcon','dtcoff']: if cmdline.LookUp('IP-Type')[dtc]: report.SetIPType(dtc) report.Progress(1, "Running interpreter with " + dtc) util.SetProfileBaseName("gmon-ip-"+lang+"-"+type+"-"+dtc+"-"+cmdline.StartDate()) RegisterExpansionSet(lang, dtc, type) if (type == 'spec'): executeSpec(lang, dtc) else: executeImpl(lang, dtc)
def execute(lang, type): global srcext, objext, binext expSet = resfile.MakeStdExpansionSet('cpp', lang, 'impl') expSet = resfile.AppendToExpandsionSet(expSet,'',['dtcoff','dtcon']) resfile.RegisterExpansionSet(expSet) util.SetProfileBaseName("gmon-cpp-"+lang+"-"+type+"-"+cmdline.StartDate()) if util.UsesVisualStudio(): srcext = "cpp" objext = "obj" binext = ".exe" else: srcext = 'cc' if (type == 'spec'): executeSpec(lang) else: executeImpl(lang)
def Init(): global errStream, reportStream, startSec ### The different log files dateStr = cmdline.StartDate() errorFile = 'errors-' + dateStr reportFile = 'report-' + dateStr ### Open the log files once and for all errStream = open(errorFile, "w") reportStream = open(reportFile, "w") util.SymLink(errorFile, "errors", true) util.SymLink(reportFile, "report", true) startSec = time.time()
def execute(lang, type): # if lang == 'rt': # report.Progress(3,"Skipping rt for type checker - not applicable") # return for posdef in ['pos', 'def']: if cmdline.LookUp('TC-Type')[posdef]: report.setTypeTestType(posdef) report.Progress(1, "Running " + posdef + " test cases") util.SetProfileBaseName("gmon-tc-" + lang + "-" + type + "-" + posdef + "-" + cmdline.StartDate()) RegisterExpansionSet(lang, type, posdef) if (type == 'spec'): executeSpec(lang, posdef) else: executeImpl(lang, posdef)
def execute(lang, testType): expSet = resfile.MakeStdExpansionSet('api', lang, testType) resfile.RegisterExpansionSet(expSet) util.SetProfileBaseName("gmon-api-" + lang + "-" + testType + "-" + cmdline.StartDate()) if lang == 'sl': vdmServer = os.path.expanduser(cmdline.LookUp('api-sl-server')) else: vdmServer = os.path.expanduser(cmdline.LookUp('api-pp-server')) start_toolbox = cmdline.LookUp('api-run-start-toolbox') server_args = cmdline.LookUp('server-init-args').split(" ") # corba-init-args is used to pass arguments to the orb client_args = cmdline.LookUp('corba-init-args').split() orb = CORBA.ORB_init(client_args, CORBA.ORB_ID) if start_toolbox == 'yes': pid = os.fork() if pid == 0: report.Progress( 3, "Trying to start " + lang + "-toolbox: " + vdmServer) cmd = vdmServer + " " + "".join( server_args) + " > tb_output.tmp 2>&1" os.system(cmd) report.Error("Startup of Toolbox failed!") return false _exit(-1) waittime = 5 print("Waiting " + str(waittime) + " seconds for " + lang + "-server to start up...") time.sleep(waittime) if "VDM_OBJECT_LOCATION" in environ: location = environ["VDM_OBJECT_LOCATION"] else: if "HOME" in environ: location = environ["HOME"] else: location = "~" if lang == 'sl': location = location + '/vdmref.ior' else: location = location + '/vppref.ior' try: stringified_ior = open(os.path.expanduser(location)).read() except IOError: report.Error("Could not find IOR file " + location + "! Please start " + lang + "-Toolbox!") if start_toolbox == 'yes': os.kill(pid, 9) os.system("tset") return false try: vdmApp = orb.string_to_object(stringified_ior) except CORBA.COMM_FAILURE: _, ex, _ = sys.exc_info() print("CORBA.COMM_FAILUR") print(ex) vdmApp = None except CORBA.MARSHAL: _, ex, _ = sys.exc_info() print("CORBA.MARSHAL") print(ex) # vdmApp = None if vdmApp is None: report.Error("Nil object reference!") if start_toolbox == 'yes': os.kill(pid, 9) return false # check if vdmApp has correct type try: if not vdmApp._is_a('IDL:ToolboxAPI/VDMApplication:1.0'): report.Error("This is not a 'VDMApplication'-server!") if start_toolbox == 'yes': os.kill(pid, 9) return false except CORBA.COMM_FAILURE: report.Error("No connection to 'VDMApplication'-object!") if start_toolbox == 'yes': os.kill(pid, 9) return false # narrow vdmApp and get typecode vdmApp = vdmApp._narrow(ToolboxAPI.VDMApplication) tc = CORBA.TypeCode('IDL:ToolboxAPI/VDMApplication:1.0') # check if server is the one we want (SL or PP) try: toolType = vdmApp._get_Tool() if (lang == 'sl' and toolType == ToolboxAPI.PP_TOOLBOX) or \ (lang == 'pp' and toolType == ToolboxAPI.SL_TOOLBOX): report.Error(vdmServer + " is not a " + lang + "-server") if start_toolbox == 'yes': os.kill(pid, 9) return false else: print(vdmServer + " is a " + lang + "-server") clientID = vdmApp.Register() # run the testcases if not RunTestCases(lang, vdmApp, clientID): vdmApp.Unregister(clientID) if start_toolbox == 'yes': os.kill(pid, 9) return false except CORBA.COMM_FAILURE: report.Error("CORBA Communication error") vdmApp.Unregister(clientID) if start_toolbox == 'yes': os.kill(pid, 9) return false # clean up time.sleep(1) vdmApp.Unregister(clientID) if start_toolbox == 'yes': os.kill(pid, 9) os.system("tset") return true
def executeSpec(lang, posdef): ok = convert.SetupSpecification(lang, 'tc') if not ok: report.Error("ABORTING specification test for " + ` lang `) return # counter to indicate progress total = 1 # number of spec. files to run in one vdmde execution jobSize = cmdline.LookUp('spec-job-size') # Initialize the extraction of test cases. gentestcases.StartSearch('tc', lang, 'spec') # indicates if any spec test case produced an error. anyError = false # Initialize coverage file coverageFile = "coverage-tc-" + lang + "-" + posdef + "-" + cmdline.StartDate( ) while (true): testCases = gentestcases.NextTestCases(jobSize) if testCases == []: break startIndex = total endIndex = total + len(testCases) - 1 report.Progress( 2, "Handling test cases " + ` startIndex ` + "..." + ` endIndex `) # Prepare the next test run - the parameter `spec-job-size' tells how # many testcases should be executed in each run. names = [] util.DeleteFiles([".vdmtest"]) for name in testCases: # prepare test cases. ok = PrepareSpecCase(name, lang, posdef) anyError = not ok or anyError if ok: names.append(name) # Get ready for next iteration. total = total + 1 # Run the test cases if names != []: report.Progress( 3, "Running test cases " + ` startIndex ` + "..." + ` endIndex `) report.setTestCaseName("testcase " + ` startIndex ` + "..." + ` endIndex `) okNames = RunSpecTestCases(names, lang, posdef, coverageFile) util.MoveProfile() # Clean Up. for testName in names: ok = (okNames.count(testName) > 0) if util.CleanFile(ok): baseName = util.ExtractName(testName) util.DeleteFiles([ baseName + ".vdm", baseName + ".ast", baseName + ".arg", baseName + ".arg.res", baseName + ".debug", baseName + ".arg.pt", "debug.arg" ]) anyError = anyError and ok # Clean up .vdmde and .vdmtest if util.CleanFile(not anyError): util.DeleteFiles([".vdmde", ".vdmtest"])
def executeSpec(lang): modules = None ok = convert.SetupSpecification(lang, 'java') if not ok: report.Error("ABORTING specification test for '" + lang + "'") return # counter to indicate progress total = 1 # number of spec. files to run in one vdmde execution jobSize = cmdline.LookUp('spec-job-size') # Initialize the extraction of test cases. gentestcases.StartSearch('java', lang, 'spec') # indicates if any spec test case produced an error. anyError = false # Initialize coverage file coverageFile = "coverage-java-" + lang + "-" + cmdline.StartDate() while (true): testCases = gentestcases.NextTestCases(jobSize) if testCases == []: break startIndex = total endIndex = total + len(testCases) - 1 report.Progress( 2, "Handling test cases " + str(startIndex) + "..." + str(endIndex)) # Prepare the next test run - the parameter 'spec-job-size' tells how # many testcases should be executed in each run. names = [] util.DeleteFiles([".vdmtest"]) for name in testCases: # prepare test cases. ok = PrepareSpecCase(name, lang) anyError = not ok or anyError if ok: names.append(name) # Get ready for next iteration. total = total + 1 # Run the test cases if names != []: report.Progress( 3, "Running test cases " + str(startIndex) + "..." + str(endIndex)) report.setTestCaseName("testcase " + str(startIndex) + "..." + str(endIndex)) (okNames, modules) = RunSpecTestCases(names, lang, coverageFile) util.MoveProfile() baseName = util.ExtractName(name) if util.GenTestDir(): util.MakeDir(baseName) files = [ baseName + ".vdm", baseName + ".ast", baseName + ".arg", baseName + ".arg.res", baseName + ".debug", baseName + ".opt", baseName + ".arg.pt", "debug.arg", baseName + ".res" ] for mod in modules: files = files + [ mod + ".java", "external_" + mod + ".java", mod + ".java.bak" ] util.DeleteFiles( [mod + ".class", mod + "$" + mod + "Sentinel.class"]) for file in files: util.CopyFileIfExists(file, baseName + "/" + file) # Clean Up. for testName in names: ok = (okNames.count(testName) > 0) if util.CleanFile(ok): util.DeleteFiles([ baseName + ".vdm", baseName + ".ast", baseName + ".arg", baseName + ".arg.res", baseName + ".debug", baseName + ".opt", baseName + ".arg.pt", "debug.arg", baseName + ".res" ]) anyError = anyError or not ok if util.CleanFile(not anyError): util.DeleteFiles(["TMAIN.java", "TMAIN.class"]) if modules != None: for mod in modules: util.DeleteFiles([ mod + ".java", "external_" + mod + ".java", mod + ".class", mod + "$" + mod + "Sentinel.class", mod + ".java.bak" ]) # Clean up .vdmde and .vdmtest if util.CleanFile(not anyError): util.DeleteFiles([".vdmde", ".vdmtest"])
def execute(lang, testType): expSet = resfile.MakeStdExpansionSet('api', lang, testType) resfile.RegisterExpansionSet(expSet) util.SetProfileBaseName("gmon-api-" + lang + "-" + testType + "-" + cmdline.StartDate()) if lang == 'sl': vdmServer = cmdline.LookUp('api-sl-server') else: vdmServer = cmdline.LookUp('api-pp-server') start_toolbox = cmdline.LookUp('api-run-start-toolbox') server_args = string.split(cmdline.LookUp('server-init-args'), " ") # corba-init-args is used to pass arguments to the orb client_args = string.split(cmdline.LookUp('corba-init-args')) orb = CORBA.ORB_init(client_args, CORBA.ORB_ID) if start_toolbox == 'yes': pid = os.fork() if pid == 0: report.Progress( 3, "Trying to start " + lang + "-toolbox: " + vdmServer) os.system(vdmServer + " " + string.join(server_args) + " > tb_output.tmp 2>&1") #os.execv (vdmServer, args) report.Error("Startup of Toolbox failed!") return false _exit(-1) # print "Waiting 5 seconds for "+lang+"-server to start up..." # time.sleep (5) print "Waiting 2 seconds for " + lang + "-server to start up..." time.sleep(2) if environ.has_key("VDM_OBJECT_LOCATION"): location = environ["VDM_OBJECT_LOCATION"] else: if environ.has_key("HOME"): location = environ["HOME"] else: location = "~" if lang == 'sl': location = location + '/vdmref.ior' else: location = location + '/vppref.ior' try: stringified_ior = open(location).read() except IOError: report.Error("Could not find IOR file " + location + "! Please start " + lang + "-Toolbox!") if start_toolbox == 'yes': os.kill(pid, 9) return false try: vdmApp = orb.string_to_object(stringified_ior) except CORBA.COMM_FAILURE, ex: print "CORBA.COMM_FAILUR" print ex vdmApp = None
def executeSpec(lang): if not util.IsWindowsOS(): ok = convert.SetupSpecification(lang, "java2vdm") if not ok: report.Error("ABORTING specification test for " + lang) # counter to indicate progress total = 1 # jobSize is used to give a low level of outputting jobSize = cmdline.LookUp('spec-job-size') # Initialize the extraction of test cases from javacg-code and java2vdm. StartCollectionOfTests() # indicates if any spec test case produced an error. anyError = false # Initialize coverage file coverageFile = "coverage-java2vdm-" + lang + "-" + cmdline.StartDate() oneTestCase = cmdline.LookUp('java2vdm-test-case') if oneTestCase != "": testCasesDirectories.append(oneTestCase) else: AddTestDirectoriesFromHierarchy(cmdline.GetTestCases('java2vdm'), lang) while (true): cases = NextTestCasesDir(jobSize) if (cases == []): break startIndex = total endIndex = total + len(testCasesDirectories) - 1 report.Progress( 2, "Handling test cases " + str(startIndex) + "..." + str(endIndex)) # Prepare the next test run - the parameter 'spec-job-size' tells how # many testcases should be executed in each run. names = [] util.DeleteFiles([".vdmtest"]) for case in cases: # prepare test cases. ok = PrepareSpecCaseDir(case, lang) anyError = not ok or anyError if ok: names.append(case) # Get ready for next iteration. total = total + 1 # Run the test cases if names != []: report.Progress( 3, "Running test cases " + str(startIndex) + "..." + str(endIndex)) report.setTestCaseName("testcase " + str(startIndex) + "..." + str(endIndex)) (okNames, modules) = RunSpecTestCases(names, lang, coverageFile) # Clean Up. for testName in names: ok = (okNames.count(testName) > 0) baseName = GetTestName(testName) if util.CleanFile(ok): util.DeleteFiles([ baseName + ".vdm", baseName + ".ast", baseName + ".arg", baseName + ".arg.res", baseName + ".debug", baseName + ".opt", baseName + ".res.exp", baseName + ".arg.pt", "debug.arg", baseName + ".res" ]) util.DeleteFiles(["vpp.arg"]) anyError = anyError or not ok #clean directories filesToDelete = [] FID = os.popen("find" + " -type f ") line = FID.readline() while (line != ''): if line[len(line) - 4:].strip() == 'vpp' or line[len(line) - 6:].strip() == 'class': filesToDelete.append(line[:-1]) line = FID.readline() util.DeleteFiles(filesToDelete) for f in os.listdir(os.getcwd()): if os.path.isdir(f): os.system("rmdir " + f) #Clean up .vdmde and .vdmtest if util.CleanFile(not anyError): util.DeleteFiles([".vdmde", ".vdmtest", parseRes, "nuloptions"]) if not util.IsWindowsOS(): util.SymLink(coverageFile, "rtinfo.ast") return