示例#1
0
def RunImplTestCase(fullName, lang):
    ok = true
    modules = None

    if ok:
        ok = convert.ConvertLanguage(lang, fullName)

    if ok:
        ok = convert.CreateOptionsFile(fullName)

    if ok:
        # Find the module or class names of the input specification.
        modules = convert.ModulesInSpecification(fullName, lang)
        if modules == None:
            ok = false

    convert.ExtractArgFileInfo(fullName)

    if ok:
        ok = CodeGenerateImpl(fullName, lang, modules)

    if ok:
        ok = CompileRunAndCompare(fullName, lang, 'impl', modules)

    return (ok, modules)
示例#2
0
def PrepareSpecCase(fullName, lang):
  report.Progress(3, "preparing " + fullName)
  report.setTestCaseName(fullName)

  ok = convert.ConvertLanguage(lang, fullName)

  if ok:
    parser = cmdline.LookUpWildCard('cpp', lang, 'spec', 'parser')
    ok = convert.VDM2AST(fullName, parser, true)

  if ok:
    ok = convert.CreateOptionsFile(fullName)

  if ok:
    convert.CreateDebugFile(fullName, "debug-file-cpp", {'<<CGKIND>>' : '<CPP>'} )

  if ok:
    ok = convert.CreateArgFile(fullName, "arg-file-cpp",  {'<<CGKIND>>' : '<CPP>'} )

  if ok:
    ok = convert.AppendToDotVdmtest(fullName)

  # Clean up if test case failed
  if not ok and util.CleanFile(ok):
    baseName = util.ExtractName(fullName)
    util.DeleteFiles([baseName+".vdm", baseName+".ast", baseName+".arg", baseName+".debug", "debug.arg"])
        
  return ok
示例#3
0
def execute(lang, type):
    global ext, binext

    #  ok = convert.SetupSpecification(lang, 'j2vtf')
    #  if not ok:
    #    report.Error("ABORTING specification test for " + `lang`)
    #    return

    #counter to indicate progress
    total = 1

    #setting the coverage file
    coverageFile = "rtinfo.ast"

    #Set expected results
    expSet = resfile.MakeStdExpansionSet('j2vtf', lang, type)
    resfile.RegisterExpansionSet(expSet)

    #jobSize is used to give a low level of outputting
    jobSize = cmdline.LookUp('spec-job-size')

    #initialize the extraction of test cases
    gentestcases.StartSearch('j2vtf', lang, type)
    name = gentestcases.NextTestCase()

    while (name != None):

        #setting report
        report.setTestCaseName(name)

        if (total % jobSize) == 1:
            report.Progress(
                2, "Handling test cases " + ` total ` + "..." +
                ` total + jobSize - 1 `)
        report.Progress(3, "Running " + name)

        ok = convert.ConvertLanguage(lang, name)

        if ok:
            ok = PrepareSpecCase(name, lang)

        if ok:
            ok = RunTestCase(name, lang, type, coverageFile)

        #cleaning up
        if ok:
            if util.CleanFile(ok):
                baseName = util.ExtractName(name)
                util.DeleteFiles([
                    baseName + ".vdm", baseName + ".ast", baseName + ".arg",
                    baseName + ".debug", baseName + ".res",
                    baseName + ".arg.res", baseName + ".arg.pt", "debug.arg"
                ])
        #else:
        #  break

        #generates next test case
        name = gentestcases.NextTestCase()

        total = total + 1
示例#4
0
def RunImplTestCase(fullName, lang, posdef):

    ok = convert.ConvertLanguage(lang, fullName)

    # Remove the files we expect output in to
    if ok:
        util.RemoveTestFiles(fullName, [".arg.res"])

    # Run the test
    if ok:
        interpreter = cmdline.LookUpWildCard('tc', lang, 'impl', 'interpreter',
                                             posdef)
        if posdef == 'pos':
            defFlg = ""
        else:
            defFlg = " -d "
        localName = util.ExtractName(fullName) + ".vdm"
        resName = util.ExtractName(fullName) + ".arg.res"

        cmd = interpreter + defFlg + " -t -f " + localName + " 2>" + resName

        # Now run the interpreter
        (exitCode, stdout, stderr) = util.RunCommand(cmd, None, None, true,
                                                     true)

        # Ensure that the interpreter actually did type check anything.
        # That is in contract to if it stoped due to a syntax error or a core dump.
#    if re.search("Type checking [^\n]* done", stdout) == None:
#      report.Error("text 'type check ... done' not found on stdout while running the type checker",
#                   "This might be due to a core dump, a syntax error or the like\n" +
#                   "This does anyway indicate that the type checking was never done",
#                   stdout, stderr)
#      ok = false

    if ok:
        expResName = resfile.FindResFile(fullName)

        # read the result from the result file, and translate it to a list of numbers
        #    result = TranslateResultImpl(stdout)
        result = TranslateResultImpl(util.ReadFile(resName))
        if result == None:
            ok = false

    if ok:
        if expResName == None:
            print("Not validating result (2)")
            if util.KeepFile(false):
                WriteResult(fullName, result)
            ok = false

    if ok:
        # Validate the result.
        report.Progress(
            4, "Validating result with result file: '" + expResName + "'")
        ok = ValidateResult(fullName, expResName, result, stdout, stderr)

        if util.KeepFile(ok):
            WriteResult(fullName, result)

    return ok
示例#5
0
def PrepareSpecCase(fullName, lang, dtc):
    report.Progress(3, "preparing " + fullName)
    report.setTestCaseName(fullName)

    ok = convert.ConvertLanguage(lang, fullName)

    if ok:
        parser = cmdline.LookUpWildCard('ip', lang, 'spec', 'parser', dtc)
        ok = convert.VDM2AST(fullName, parser, false)

    if ok:
        ok = convert.CreateOptionsFile(fullName)

    argStr = CreateArgumentAst(fullName, lang)
    if argStr == None:
        ok = false

    if dtc == 'dtcon':
        dtcbool = 'true'
    else:
        dtcbool = 'false'

    if ok:
        convert.CreateDebugFile(fullName, "debug-file-ip", {
            '<<ARG>>': argStr,
            '<<DTC>>': dtcbool
        })

    if ok:
        ok = convert.CreateArgFile(fullName, "arg-file-ip", {
            '<<ARG>>': argStr,
            '<<DTC>>': dtcbool
        })

    if ok:
        ok = convert.AppendToDotVdmtest(fullName)

    # Clean up if test case failed
    if not ok and util.CleanFile(ok):
        baseName = util.ExtractName(fullName)
        util.DeleteFiles([
            baseName + ".vdm", baseName + ".ast", baseName + ".arg",
            baseName + ".debug"
        ])

    return ok
示例#6
0
def PrepareSpecCase(name, lang, posdef):
    report.Progress(3, "preparing " + name)
    report.setTestCaseName(name)

    ok = convert.ConvertLanguage(lang, name)

    if ok:
        parser = cmdline.LookUpWildCard('tc', lang, 'spec', 'parser', posdef)
        ok = convert.VDM2AST(name, parser, false)

    if ok:
        ok = convert.CreateOptionsFile(name)

    if posdef == 'pos':
        posdefStr = '<POS>'
    else:
        posdefStr = '<DEF>'

    if ok:
        convert.CreateDebugFile(name, "debug-file-tc",
                                {'<<POSDEF>>': posdefStr})

    if ok:
        ok = convert.CreateArgFile(name, "arg-file-tc",
                                   {'<<POSDEF>>': posdefStr})

    if ok:
        ok = convert.AppendToDotVdmtest(name)

    # Clean up if test case failed
    if not ok and util.CleanFile(ok):
        baseName = util.ExtractName(name)
        util.DeleteFiles([
            baseName + ".vdm", baseName + ".ast", baseName + ".arg",
            baseName + ".debug"
        ])

    return ok
示例#7
0
def PrepareImplCase(fullName, lang):
  ok = convert.ConvertLanguage(lang, fullName)
  return ok