Ejemplo n.º 1
0
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"])
Ejemplo n.º 2
0
def executeSpec(lang):
  ok = convert.SetupSpecification(lang, 'cpp')

  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('cpp', lang, 'spec')

  # indicates if any spec test case produced an error.
  anyError = false

  # Initialize coverage file
  #coverageFile = "coverage-cpp-"+lang+"-"+cmdline.StartDate()
  coverageFile = "rtinfo.ast"

  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)
      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, 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",baseName+".res"])
      anyError = anyError or not ok

  # Clean up .vdmde and .vdmtest
  if util.CleanFile(not anyError):
    util.DeleteFiles([".vdmde",".vdmtest"])
Ejemplo n.º 3
0
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