Esempio n. 1
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
Esempio n. 2
0
def PrepareSpecCase(name, lang):

    report.Progress(3, "Preparing " + name)
    report.setTestCaseName(name)

    parser = cmdline.LookUpWildCard('j2vtf', lang, 'spec', 'parser')
    ok = convert.VDM2AST(name, parser, false)

    if ok:
        ok = convert.CreateOptionsFile(name)

    if ok:
        extra = GetIdSet()
        ok = convert.CreateDebugFile(name, "debug-file-j2vtf", extra)

    if ok:
        ok = convert.CreateArgFile(name, "arg-file-j2vtf", extra)

    util.DeleteFiles([".vdmtest"])

    if ok:
        ok = convert.AppendToDotVdmtest(name)

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

    return ok
Esempio n. 3
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
Esempio n. 4
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
Esempio n. 5
0
def PrepareSpecCaseDir(dirName, lang):
    global runJavacBeforeParser

    testName = GetTestName(dirName)

    fullName = os.getcwd()

    #
    #  Produce a list of java files in dirName
    #  and put it testCases
    #
    AddTestsFromHierarchy(dirName, lang)

    util.DeleteFiles([parseRes])
    util.RemoveTestFiles(testName, [
        ".arg.pt", ".arg.res", ".arg.err", ".res.arg", ".arg.msg", "vpp.arg",
        ".res", ".debug", ".ast"
    ])

    ok = convert.CreateOptionsFile(fullName)

    if runJavacBeforeParser == "yes":
        ok = CompileJavaFiles(dirName)
        if not ok:
            return false

    javafiles = " "
    javafiles = javafiles + setup.BaseDir + "/../j2v-test/Object.java "
    javafiles = javafiles + setup.BaseDir + "/../j2v-test/Exception.java "
    javafiles = javafiles + setup.BaseDir + "/../j2v-test/String.java "
    javafiles = javafiles + setup.BaseDir + "/../j2v-test/Character.java "

    #
    # Iterate over the list of java files in the dirName (except MAIN.java)
    # and runs javamain
    #
    mainJava = dirName + "/" + "MAIN.java"

    while ok and (testCases != []):
        test = GetNextTest()
        if os.path.abspath(test) != os.path.abspath(mainJava):
            javafiles = javafiles + test + " "

#  javafiles = javafiles + setup.BaseDir+"/../j2v-test/Object.java "
#  javafiles = javafiles + setup.BaseDir+"/../j2v-test/Exception.java "
#  javafiles = javafiles + setup.BaseDir+"/../j2v-test/String.java "

#
#   Run java parser to get CPP`Files
#
    if not ParseJavaFile(javafiles, lang):
        ok = false

    if ok:
        ast = util.ReadFile(parseRes)

    if ok:
        ok = util.WriteFile(testName + ".ast", ast)

    if ok:
        convert.CreateDebugFile(dirName, "debug-file-java2vdm", {})

    if ok:
        ok = convert.CreateArgFile(dirName, "arg-file-java2vdm", {})

    if ok:
        ok = convert.AppendToDotVdmtest(dirName)

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

    return ok