Esempio n. 1
0
def runtest():
    """check cross-generated output against native reference files"""

    # object code
    for infile, opts, reffile in [
            ("gaops.gpl", [], "GAOPS-Q"),
            ("gainst.gpl", [], "GAINST-Q"),
            ("gabranch.gpl", [], "GABRANCH-Q", ),
            ("gamove.gpl", [], "GAMOVE-Q"),
            ("gafmt.gpl", ["-s", "rag"], "GAFMT-Q"),
            ("gadirs.gpl", [], "GADIRS-Q"),
            ("gacopy.gpl", [], "GACOPY-Q"),
            ("gaexts.gpl", [], "GAEXTS-Q"),
            ("gapass.gpl", [], "GAPASS-Q")
            ]:
        source = os.path.join(Dirs.gplsources, infile)
        xdm(Disks.gplsrcs, "-e", reffile, "-o", Files.reference)
        xga(*[source] + opts + ["-o", Files.output])
        checkGbcFilesEq(infile, Files.output, Files.reference)

    # cart generation
    for name in ["gacart", "gahello"]:
        source = os.path.join(Dirs.gplsources, name + ".gpl")
        ref = os.path.join(Dirs.refs, name + ".rpk")
        xga(source, "-c", "-o", Files.output)
        checkFilesEq("GPL cart", Files.output, ref, "P",
                     mask=((0x8, 0x1e), (0x188, 0xfff)))

    # extensions
    source = os.path.join(Dirs.gplsources, "gaxprep.gpl")
    xga(source, "-D", "isdef=2", "-o", Files.output)
    xdm(Disks.gplsrcs, "-e", "GAXPREP-Q", "-o", Files.reference)
    checkGbcFilesEq(source, Files.output, Files.reference)

    # error messages
    for s in ["gaerrs0.gpl", "gaerrs1.gpl"]:
        source = os.path.join(Dirs.gplsources, s)
        with open(source, "r") as fin:
            expect = [lino + 1 for lino, line in enumerate(fin)
                      if "* ERROR" in line]
        with open(Files.error, "w") as ferr:
            xga(source, "-o", Files.output, stderr=ferr, rc=1)
        with open(Files.error, "r") as fin:
            try:
                found = [int(line[:4]) for line in fin if line[0] != "*"]
            except ValueError:
                error("Error messages", "Unexpected error message")
        if found != expect:
            error("Error messages",
                  "Error mismatch, extra: " +
                  str([x for x in found if x not in expect]) +
                  " missing: " +
                  str([x for x in expect if x not in found]))

    # cleanup
    os.remove(Files.output)
    os.remove(Files.reference)
    os.remove(Files.error)
Esempio n. 2
0
def runtest():
    """extract INT record files generated by WRITEINT.bas"""

    # setup
    shutil.copyfile(Disks.recsint, Disks.work)

    # read full-size records
    for reclen in [2, 64, 127, 128, 254, 255]:
        xdm(Disks.work, "-e", "IF" + str(reclen), "-o", Files.output)
        checkRecordsByChecksum(Files.output, reclen, True)
        xdm(Disks.work, "-e", "IV" + str(reclen), "-o", Files.output)
        checkRecordsByChecksum(Files.output, reclen, False)

    # read partially filled records
    for fn in ["intfix32v", "intvar32v", "intfix128v", "intvar128v"]:
        xdm(Disks.work, "-e", fn.upper(), "-o", Files.output)
        ref = os.path.join(Dirs.refs, fn)
        checkFilesEq("INT Records", Files.output, ref, "P")

    # re-write extracted records and check
    for reclen in [2, 64, 127, 128, 254, 255]:
        xdm(Disks.work, "-e", "IF" + str(reclen), "-o", Files.reference)
        xdm(Disks.work, "-a", Files.reference, "-n", "CF" + str(reclen),
            "-f", "INT/FIX" + str(reclen))
        xdm(Disks.work, "-e", "CF" + str(reclen), "-o", Files.output)
        checkFilesEq("Write INT", Files.output, Files.reference,
                     "INT/FIX" + str(reclen))
        xdm(Disks.work, "-e", "IV" + str(reclen), "-o", Files.reference)
        xdm(Disks.work, "-a", Files.reference, "-n", "CV" + str(reclen),
            "-f", "INT/VAR" + str(reclen))
        xdm(Disks.work, "-e", "CV" + str(reclen), "-o", Files.output)
        checkFilesEq("Write INT", Files.output, Files.reference,
                     "INT/VAR" + str(reclen))

    # re-write partially filled records
    for fn, fmt in [
            ("intfix32v", "IF32"), ("intvar32v", "IV32"),
            ("intfix128v", "IF128"), ("intvar128v", "IV128")
            ]:
        ref = os.path.join(Dirs.refs, fn)
        xdm(Disks.work, "-a", ref, "-n", "TEST", "-f", fmt)
        xdm(Disks.work, "-e", "TEST", "-o", Files.output)
        checkFilesEq("Write INT", Files.output, ref, "P")

    # cleanup
    os.remove(Files.output)
    os.remove(Files.reference)
    os.remove(Disks.work)
Esempio n. 3
0
def runtest():
    """extract VAR record files generated by DMWRVAR.xb"""

    # setup
    shutil.copyfile(Disks.recsdis, Disks.work)

    # read full-size records
    for reclen in [16, 127, 128, 129, 254, 255]:
        xdm(Disks.work, "-e", "F" + str(reclen), "-o", Files.output)
        checkRecordsByChecksum(Files.output)
    for reclen in [16, 126, 127, 128, 254, 255]:
        xdm(Disks.work, "-e", "V" + str(reclen), "-o", Files.output)
        checkRecordsByChecksum(Files.output)

    # read partially filled records
    for reclen in [64]:
        xdm(Disks.work, "-e", "F" + str(reclen) + "V", "-o", Files.output)
        checkRecordsByLen(Files.output, fixed=reclen)
    for recid in [
            "64V", "255V1", "255V2", "255V3", "255V4", "255V4", "255V5"
            ]:
        xdm(Disks.work, "-e", "V" + recid, "-o", Files.output)
        checkRecordsByLen(Files.output)

    # read special records
    xdm(Disks.work, "-e", "F10R", "-o", Files.output)
    checkFilesEq("VAR Records", Files.output,
                 os.path.join(Dirs.refs, "f10r.txt"), "DIS/FIX10")
    xdm(Disks.work, "-e", "V10R", "-o", Files.output)
    checkFilesEq("VAR Records", Files.output,
                 os.path.join(Dirs.refs, "v10r.txt"), "DIS/VAR10")

    # re-write extracted records and check
    for fn in [
            "V1", "V16", "V126", "V127", "V128", "V254", "V64V", "V255V1",
            "V255V2", "V255V3", "V255V4", "V255V5", "V10R", "F10R",
            "F1", "F16", "F127", "F128", "F129", "F254", "F255", "F64V"
            ]:
        rectype = "DIS/VAR" if fn[0] == "V" else "DIS/FIX"
        reclen = re.search("\d+", fn).group(0)
        fmt = rectype + reclen
        xdm(Disks.work, "-e", fn, "-o", Files.reference)
        xdm(Disks.work, "-a", Files.reference, "-n", "COPY", "-f", fmt)
        xdm(Disks.work, "-e", "COPY", "-o", Files.output)
        checkFilesEq("VAR Records", Files.output, Files.reference, fmt)

    # cleanup
    os.remove(Files.output)
    os.remove(Files.reference)
    os.remove(Disks.work)
Esempio n. 4
0
def runtest():
    """check cross-generated output against native reference files"""

    # object code
    for infile, opts, reffile, cprfile in [
        ("asdirs.asm", [], "ASDIRS-O", "ASDIRS-C"),
        ("asorgs.asm", [], "ASORGS-O", "ASORGS-C"),
        ("asopcs.asm", [], "ASOPCS-O", "ASOPCS-C"),
        ("asexprs.asm", [], "ASEXPRS-O", "ASEXPRS-C"),
        ("asbss.asm", [], "ASBSS-O", "ASBSS-C"),
        ("asregs.asm", ["-R"], "ASREGS-O", "ASREGS-C"),
        ("ashello.asm", ["-R"], "ASHELLO-O", "ASHELLO-C"),
        ("ascopy.asm", [], "ASCOPY-O", None),
        ("ascopyn.asm", [], "ASCOPYN-O", None),
        ("assize1.asm", [], "ASSIZE1-O", "ASSIZE1-C"),
        ("assize2.asm", [], "ASSIZE2-O", None),
        ("assize3.asm", [], "ASSIZE3-O", None),
        ("assize4.asm", [], "ASSIZE4-O", None),
        ("astisym.asm", [], "ASTISYM-O", "ASTISYM-C"),
        ("asimg1.asm", [], "ASIMG1-O", "ASIMG1-C"),
        ("asimg2.asm", [], "ASIMG2-O", None),
        ("asimg3.asm", [], "ASIMG3-OX", None),
            #("asreloc.asm", [], "ASRELOC-O", None),
        ("asxorg.asm", [], "ASXORG-O", None),
        ("ascart.asm", ["-R"], "ASCART-O", "ASCART-C")
    ]:
        source = os.path.join(Dirs.sources, infile)
        xdm(Disks.asmsrcs, "-e", reffile, "-o", Files.reference)
        xas(*[source] + opts + ["-o", Files.output])
        checkObjCodeEq(Files.output, Files.reference)
        xas(*[source] + opts + ["--strict", "-o", Files.output])
        checkObjCodeEq(Files.output, Files.reference)
        if cprfile:
            # compressed object code
            xas(*[source] + opts + ["-C", "-o", Files.output])
            xdm(Disks.asmsrcs, "-e", cprfile, "-o", Files.reference)
            checkObjCodeEq(Files.output, Files.reference)

    # image files
    for infile, opts, reffile in [("ashello.asm", ["-R"], "ASHELLO-I"),
                                  ("astisym.asm", [], "ASTISYM-I"),
                                  ("asimg1.asm", [], "ASIMG1-I"),
                                  ("asimg2.asm", [], "ASIMG2-I")
                                  #("asimg3.asm", [], "ASIMG3-I")
                                  ]:
        source = os.path.join(Dirs.sources, infile)
        xas(*[source] + opts + ["-i", "-o", Files.output])
        xdm(Disks.asmsrcs, "-e", reffile, "-o", Files.reference)
        checkImageFilesEq(Files.output, Files.reference)

    for infile, reffiles in [
        ("aslimg.asm", ["ASLIMG-I", "ASLIMG-J", "ASLIMG-K"]),
        ("assimg.asm", ["ASSIMG-I", "ASSIMG-J", "ASSIMG-K", "ASSIMG-L"]),
        ("asreloc.asm", ["ASRELOC-I"])
    ]:
        source = os.path.join(Dirs.sources, infile)
        xas(source, "-R", "-i", "-o", Files.output)
        for i, reffile in enumerate(reffiles):
            xdm(Disks.asmimgs, "-e", reffile, "-o", Files.reference)
            checkFilesEq("Image file",
                         Files.outputff[i],
                         Files.reference,
                         fmt="P")

    # cleanup
    for i in xrange(4):
        os.remove(Files.outputff[i])
    os.remove(Files.reference)
Esempio n. 5
0
def runtest():
    """check cross-generated output against native reference files"""

    # object code
    for infile, opts, reffile, cprfile in [
            ("asdirs.asm", [], "ASDIRS-O", "ASDIRS-C"),
            ("asorgs.asm", [], "ASORGS-O", "ASORGS-C"),
            ("asopcs.asm", [], "ASOPCS-O", "ASOPCS-C"),
            ("asexprs.asm", [], "ASEXPRS-O", "ASEXPRS-C"),
            ("asbss.asm", [], "ASBSS-O", "ASBSS-C"),
            ("asregs.asm", ["-R"], "ASREGS-O", "ASREGS-C"),
            ("ashello.asm", ["-R"], "ASHELLO-O", "ASHELLO-C"),
            ("ascopy.asm", [], "ASCOPY-O", None),
            ("ascopyn.asm", [], "ASCOPYN-O", None),
            ("assize1.asm", [], "ASSIZE1-O", "ASSIZE1-C"),
            ("assize2.asm", [], "ASSIZE2-O", None),
            ("assize3.asm", [], "ASSIZE3-O", None),
            ("assize4.asm", [], "ASSIZE4-O", None),
            ("astisym.asm", [], "ASTISYM-O", "ASTISYM-C"),
            ("asimg1.asm", [], "ASIMG1-O", "ASIMG1-C"),
            ("asimg2.asm", [], "ASIMG2-O", None),
            ("asimg3.asm", [], "ASIMG3-OX", None),
            #("asreloc.asm", [], "ASRELOC-O", None),
            ("asxorg.asm", [], "ASXORG-O", None),
            ("ascart.asm", ["-R"], "ASCART-O", "ASCART-C")
            ]:
        source = os.path.join(Dirs.sources, infile)
        xdm(Disks.asmsrcs, "-e", reffile, "-o", Files.reference)
        xas(*[source] + opts + ["-o", Files.output])
        checkObjCodeEq(Files.output, Files.reference)
        xas(*[source] + opts + ["--strict", "-o", Files.output])
        checkObjCodeEq(Files.output, Files.reference)
        if cprfile:
            # compressed object code
            xas(*[source] + opts + ["-C", "-o", Files.output])
            xdm(Disks.asmsrcs, "-e", cprfile, "-o", Files.reference)
            checkObjCodeEq(Files.output, Files.reference)

    # image files
    for infile, opts, reffile in [
            ("ashello.asm", ["-R"], "ASHELLO-I"),
            ("astisym.asm", [], "ASTISYM-I"),
            ("asimg1.asm", [], "ASIMG1-I"),
            ("asimg2.asm", [], "ASIMG2-I")
            #("asimg3.asm", [], "ASIMG3-I")
            ]:
        source = os.path.join(Dirs.sources, infile)
        xas(*[source] + opts + ["-i", "-o", Files.output])
        xdm(Disks.asmsrcs, "-e", reffile, "-o", Files.reference)
        checkImageFilesEq(Files.output, Files.reference)

    for infile, reffiles in [
            ("aslimg.asm", ["ASLIMG-I", "ASLIMG-J", "ASLIMG-K"]),
            ("assimg.asm", ["ASSIMG-I", "ASSIMG-J", "ASSIMG-K", "ASSIMG-L"]),
            ("asreloc.asm", ["ASRELOC-I"])
            ]:
        source = os.path.join(Dirs.sources, infile)
        xas(source, "-R", "-i", "-o", Files.output)
        for i, reffile in enumerate(reffiles):
            xdm(Disks.asmimgs, "-e", reffile, "-o", Files.reference)
            checkFilesEq("Image file",
                         Files.outputff[i], Files.reference, fmt="P")

    # cleanup
    for i in xrange(4):
        os.remove(Files.outputff[i])
    os.remove(Files.reference)
Esempio n. 6
0
def runtest():
    """compare extracted files to reference files"""

    # compare with reference files generated by TI Image Tool
    shutil.copyfile(Disks.recsdis, Disks.work)
    for fn in [
            "V1",
            "V16",
            "V126",
            "V127",
            "V128",
            "V254",
            "V10R",
            "V64V",
            "V255V1",
            "V255V2",
            "V255V3",
            "V255V4",
            "V255V5",
            # NOTE: F1.tfi has incorrect record count
            "F16",
            "F127",
            "F128",
            "F129",
            "F254",
            "F255",
            "F64V",
            "F10R"
    ]:
        xdm(Disks.work, "-e", fn, "-t", "-o", Files.output)
        checkFilesEq("TIFiles", Files.output,
                     os.path.join(Dirs.refs, fn + ".tfi"), "PROGRAM",
                     Masks.TIFile)

    # compare with reference files generated by Classic99
    for fn in ["V16", "V127", "V64V", "V10R", "F129", "F64V", "F10R"]:
        xdm(Disks.work, "-e", fn, "-9", "-o", Files.output)
        checkFilesEq("v9t9", Files.output,
                     os.path.join(Dirs.refs,
                                  fn + ".v9t9"), "PROGRAM", Masks.v9t9)
        xdm("-F", Files.output, "-9", "-o", Files.output)
        xdm(Disks.work, "-e", fn, "-o", Files.reference)
        checkFilesEq("v9t9", Files.output, Files.reference, "DV")

    # compare files extracted from fragmented image
    shutil.copyfile(Disks.frag, Disks.work)
    for fn in ["F1", "F6"]:
        xdm(Disks.work, "-e", fn, "-o", Files.output)
        checkFilesEq("Frag Disk", Files.output,
                     os.path.join(Dirs.refs, "FRAG" + fn), "DIS/VAR127")
    xdm(Disks.work, "-d", "F1")
    xdm(Disks.work, "-e", "F6", "-o", Files.output)
    checkFilesEq("Frag Disk", Files.output, os.path.join(Dirs.refs, "FRAGF6"),
                 "DIS/VAR127")
    shutil.copyfile(Disks.frag, Disks.work)
    xdm(Disks.work, "-a", Files.output, "-n", "COPY", "-f", "DIS/VAR127")
    xdm(Disks.work, "-e", "F1", "-o", Files.output)
    checkFilesEq("Frag Disk", Files.output, os.path.join(Dirs.refs, "FRAGF1"),
                 "DIS/VAR127")

    # compare short and long TIFiles
    rfile = os.path.join(Dirs.refs, "V64V")
    shutil.copyfile(rfile, Files.reference)
    with open(Files.output, "w") as f:
        xdm(Disks.work, "-I", Files.reference, stdout=f)
    checkFileMatches(Files.output, [
        (0, "^%-10s" % tiname(Files.reference) +
         r"\s+4  DIS/VAR 64\s+575 B\s+9 recs\s+" + str(datetime.date.today()))
    ])
    xdm(Disks.work, "-X", "sssd", "-t", "-a", rfile)
    xdm(Disks.work, "-e", "V64V", "-o", Files.output)
    xdm("-F", rfile, "-o", Files.reference)
    checkFilesEq("Short TIFiles", Files.output, Files.reference, "DIS/VAR64")

    # cleanup
    os.remove(Files.output)
    os.remove(Disks.work)
Esempio n. 7
0
def runtest():
    """check command line interface"""

    # conversion HFE <-> disk pseudo-disks
    for n in ["rsssd", "rdssd", "rssdd", "rdsdd",
              "rsssd80t", "rdssd80t", "tiit80t"]:
        refdsk = os.path.join(Dirs.hfe, n + ".dsk")
        refhfe = os.path.join(Dirs.hfe, n + "_dsk.hfe.gz")
        with gzip.open(refhfe, "rb") as fin, open(Files.reference, "wb") as fout:
            fout.write(fin.read())
        xhm("-T", refdsk, "-o", Files.input)
        checkFilesEq("HFE", Files.input, Files.reference, "PROGRAM")
        xhm("-F", Files.input, "-o", Files.output)
        checkFilesEq("HFE", Files.output, refdsk, "PROGRAM")

    # xdm99 delegation
    with gzip.open(Disks.hfe, "rb") as fin, open(Disks.work, "wb") as fout:
        fout.write(fin.read())
    with open(Files.output, "w") as fout:
        xhm(Disks.work, stdout=fout)
    checkFileContains(Files.output, "HFEDISK.*1S/1D.*40")
    checkFileContains(Files.output, "HFEFILE")

    # image manipulation
    ref = os.path.join(Dirs.refs, "ti-text")
    xhm(Disks.work, "-a", ref, "-n", "TESTFILE", "-f", "DV60")
    xhm(Disks.work, "-e", "TESTFILE", "-o", Files.output)
    xhm("-o", Files.output, Disks.work, "-e", "TESTFILE")
    checkFilesEq("HFE", Files.output, ref, "PRORGAM")
    with open(Files.output, "wb") as fout:
        xhm(Disks.work, "-p", "TESTFILE", stdout=fout)
    checkFilesEq("HFE", Files.output, ref, "PRORGAM")

    ref = os.path.join(Dirs.refs, "V10R.tfi")
    shutil.copyfile(ref, Files.reference)    
    xhm(Disks.work, "-a", Files.reference, "-t")
    xhm(Disks.work, "-e", "V10R", "-o", Files.output)
    xhm("-o", Files.output, Disks.work, "-e", "V10R")
    ref = os.path.join(Dirs.refs, "v10r.txt")
    checkFilesEq("HFE", Files.output, ref, "PRORGAM")

    # image resize
    with open(Files.output, "w") as fout:
        xhm("--hfe-info", Disks.work, stdout=fout)
    checkFileContains(Files.output, "Tracks: 40")
    checkFileContains(Files.output, "Sides: 1")
    checkFileContains(Files.output, "Encoding: 2")  # SD
    xhm(Disks.work, "-Z", "dsdd")
    with open(Files.output, "w") as fout:
        xhm("--hfe-info", Disks.work, stdout=fout)
    checkFileContains(Files.output, "Tracks: 40")
    checkFileContains(Files.output, "Sides: 2")
    checkFileContains(Files.output, "Encoding: 0")  # DD

    # image creation
    xhm(Disks.work, "-X", "dssd80t", "-a", ref, "-n", "WALDO")
    with open(Files.output, "w") as fout:
        xhm(Disks.work, "-i", stdout=fout)
    checkFileContains(Files.output, "2S/1D\s+80")
    checkFileContains(Files.output, "WALDO.*PROGRAM")
    with open(Files.output, "w") as fout:
        xhm("--hfe-info", Disks.work, stdout=fout)
    checkFileContains(Files.output, "Tracks: 80")
    checkFileContains(Files.output, "Sides: 2")
    checkFileContains(Files.output, "Encoding: 2")  # SD

    # messy stuff
    xdm(Disks.work, "-X", "sssd")
    xdm(Disks.work, "--set-geometry", "dssd")  # image too short now!
    xhm("-T", Disks.work, "-o", Files.input)
    with open(Files.output, "w") as fout:
        xhm("--hfe-info", Files.input, stdout=fout)
    checkFileContains(Files.output, "Tracks: 40")
    checkFileContains(Files.output, "Sides: 2")  # DS
    checkFileContains(Files.output, "Encoding: 2")  # SD
    with open(Files.error, "w") as ferr:  # quelch error msg
        xhm(Files.input, stderr=ferr, rc=1)  # invalid track count

    # cleanup
    os.remove(Files.input)
    os.remove(Files.output)
    os.remove(Files.reference)
    os.remove(Files.error)
    os.remove(Disks.work)
Esempio n. 8
0
def runtest():
    """compare extracted files to reference files"""

    # compare with reference files generated by TI Image Tool
    shutil.copyfile(Disks.recsdis, Disks.work)
    for fn in [
            "V1", "V16", "V126", "V127", "V128", "V254", "V10R",
            "V64V", "V255V1", "V255V2", "V255V3", "V255V4", "V255V5",
            # NOTE: F1.tfi has incorrect record count
            "F16", "F127", "F128", "F129", "F254", "F255", "F64V", "F10R"
            ]:
        xdm(Disks.work, "-e", fn, "-t", "-o", Files.output)
        checkFilesEq("TIFiles", Files.output,
                     os.path.join(Dirs.refs, fn + ".tfi"), "PROGRAM",
                     Masks.TIFile)

    # compare with reference files generated by Classic99
    for fn in [
            "V16", "V127", "V64V", "V10R", "F129", "F64V", "F10R"
            ]:
        xdm(Disks.work, "-e", fn, "-9", "-o", Files.output)
        checkFilesEq("v9t9", Files.output,
                     os.path.join(Dirs.refs, fn + ".v9t9"), "PROGRAM",
                     Masks.v9t9)
        xdm("-F", Files.output, "-9", "-o", Files.output)
        xdm(Disks.work, "-e", fn, "-o", Files.reference)
        checkFilesEq("v9t9", Files.output, Files.reference, "DV")

    # compare files extracted from fragmented image
    shutil.copyfile(Disks.frag, Disks.work)
    for fn in ["F1", "F6"]:
        xdm(Disks.work, "-e", fn, "-o", Files.output)
        checkFilesEq("Frag Disk", Files.output,
                     os.path.join(Dirs.refs, "FRAG" + fn), "DIS/VAR127")
    xdm(Disks.work, "-d", "F1")
    xdm(Disks.work, "-e", "F6", "-o", Files.output)
    checkFilesEq("Frag Disk", Files.output, os.path.join(Dirs.refs, "FRAGF6"),
                 "DIS/VAR127")
    shutil.copyfile(Disks.frag, Disks.work)
    xdm(Disks.work, "-a", Files.output, "-n", "COPY", "-f", "DIS/VAR127")
    xdm(Disks.work, "-e", "F1", "-o", Files.output)
    checkFilesEq("Frag Disk", Files.output, os.path.join(Dirs.refs, "FRAGF1"),
                 "DIS/VAR127")

    # cleanup
    os.remove(Files.output)
    os.remove(Disks.work)
Esempio n. 9
0
def runtest():
    """compare xbas99 generation to TI references"""

    for fn in [
            "KEYWORDS", "STATMNTS", "NUMBERS", "COMMENTS", "LOWRCASE",
            "GIBBRISH"
    ]:
        # compare generated xbas99 listing with TI BASIC reference
        xdm(Disks.basic1, "-e", fn, "-o", Files.input)
        xdm(Disks.basic1, "-e", fn + "-L", "-o", Files.reference)
        xbas(Files.input, "-d", "-o", Files.output)
        checkListingEq(Files.output, Files.reference)

        # ditto with MERGE format
        xdm(Disks.basic1, "-e", fn + "-M", "-o", Files.input)
        xbas(Files.input, "-d", "--merge", "-o", Files.output)
        if os.name != "nt":
            checkListingEq(Files.output, Files.reference)

        # compare generated xbas99 basic program with TI BASIC reference
        xdm(Disks.basic1, "-e", fn + "-L", "-o", Files.input)
        xdm(Disks.basic1, "-e", fn, "-o", Files.reference)
        xbas(Files.input, "-c", "-j", "3", "-o", Files.output)
        checkFilesEq("Tokenization", Files.output, Files.reference, "P")

        # ditto with non-canonically formatted original source
        rawlist = os.path.join(Dirs.basic, fn.lower() + ".txt")
        genListing(rawlist, Files.input)
        xbas(Files.input, "-c", "-o", Files.output)
        checkFilesEq("Tokenization", Files.output, Files.reference, "P")

    # check using randomized listings
    for i in xrange(8):
        fn = "RAND%02d" % i
        xdm(Disks.basic2, "-e", fn, "-o", Files.input)
        xdm(Disks.basic2, "-e", fn + "-L", "-o", Files.reference)

        # compare generated xbas99 listing with TI BASIC reference
        xbas(Files.input, "-d", "-o", Files.output)
        checkListingEq(Files.output, Files.reference)

        # compare generated xbas99 basic program with TI BASIC reference
        xbas(Files.reference, "-c", "-j", "3", "-o", Files.output)
        checkFilesEq("Tokenization", Files.output, Files.input, "P")

    # check long format
    path = os.path.join(Dirs.basic, "sample-l.bin")
    xbas(path, "-d", "-o", Files.output)
    path = os.path.join(Dirs.basic, "sample-n.bin")
    xbas(path, "-d", "-o", Files.reference)
    checkFilesEq("Long Format", Files.output, Files.reference, "P")

    # check listing protection
    xdm(Disks.basic1, "-e", "STATMNTS-L", "-o", Files.input)
    xbas(Files.input, "-c", "-j", "3", "--protect", "-o", Files.output)
    xbas(Files.input, "-c", "-j", "3", "-o", Files.reference)
    checkFilesEq("Protection",
                 Files.output,
                 Files.reference,
                 "P",
                 mask=[(0, 2)])

    # cleanup
    os.remove(Files.input)
    os.remove(Files.output)
    os.remove(Files.reference)
Esempio n. 10
0
def runtest():
    """check command line interface"""

    # setup
    with open(Disks.volumes, "wb") as v:
        for i in xrange(4 * 1600):
            v.write("\x00" * 256)  # Disk.bytesPerSector
    shutil.copyfile(Disks.recsgen, Disks.work)

    # volume operations
    xvm(Disks.volumes, "2", "-w", Disks.recsgen, "--keep-size")
    xvm(Disks.volumes, "1,3-4", "-w", Disks.recsdis, "--keep-size")

    with open(Files.error, "w") as fout:
        xvm(Disks.volumes, "1-5", stdout=fout)
        xvm(Disks.volumes, "4", "-i", stdout=fout)
        xvm(Disks.volumes, "5", "-i", stderr=fout, rc=1)

    xvm(Disks.volumes, "2", "-r", Files.output)
    checkFilesEq("xvm", Files.output, Disks.recsgen, "P")
    xvm(Disks.volumes, "1", "-r", Files.output)
    checkFilesEq("xvm", Files.output, Disks.recsdis, "P")
    xvm(Disks.volumes, "4", "-r", Files.output)
    checkFilesEq("xvm", Files.output, Disks.recsdis, "P")
    xvm(Disks.volumes, "4", "-r", Files.output, "--keep-size")
    checkFilesEq("xvm", Files.output, Disks.recsdis, "P",
                 mask=[(360 * 256, 1600 * 256)])

    # file operations
    xvm(Disks.volumes, "2", "-e", "DF254X015P", "-o", Files.output)
    xdm(Disks.recsgen, "-e", "DF254X015P", "-o", Files.reference)
    checkFilesEq("xvm", Files.output, Files.reference, "P")

    xvm(Disks.volumes, "1", "-w", Disks.work, "--keep-size")
    ref = os.path.join(Dirs.refs, "sector1")
    xdm(Disks.work, "-a", ref, "-f", "DF80")
    xvm(Disks.volumes, "1", "-a", ref, "-f", "DF80")
    xvm(Disks.volumes, "1", "-r", Files.output)
    checkFilesEq("xvm", Files.output, Disks.work, "P")

    xvm(Disks.volumes, "3", "-w", Disks.work)
    xvm(Disks.volumes, "3", "-a", ref, "-f", "DF80", "-n", "REFFILE")
    xvm(Disks.volumes, "3", "-r", Files.output)
    xdm(Files.output, "-e", "REFFILE", "-q", "-o", Files.reference)

    ref = os.path.join(Dirs.refs, "glob")
    xvm(Disks.volumes, "1", "-a", ref + "?", "-n", "GLOBA1", shell=True)
    xvm(Disks.volumes, "1", "-e", "GLOBA1", "-o", Files.output)
    xvm(Disks.volumes, "1", "-e", "GLOBA2", "-o", Files.output)
    with open(Files.error, "w") as ferr:
        xvm(Disks.volumes, "1", "-e", "GLOBA3", "-o", Files.output,
            stderr=ferr, rc=1)
    xvm(Disks.volumes, "1", "-d", "GLOB*", "-o", Files.output)
    xvm(Disks.volumes, "1", "-a", ref + "*", "-n", "GLOBB1", shell=True)
    xvm(Disks.volumes, "1", "-e", "GLOBB1", "-o", Files.output)
    xvm(Disks.volumes, "1", "-e", "GLOBB2", "-o", Files.output)
    xvm(Disks.volumes, "1", "-e", "GLOBB3", "-o", Files.output)

    # cleanup
    os.remove(Files.output)
    os.remove(Files.reference)
    os.remove(Files.error)
    os.remove(Disks.work)
    os.remove(Disks.volumes)
Esempio n. 11
0
def runtest():
    """check command line interface"""

    # setup
    with open(Disks.volumes, "wb") as v:
        for i in xrange(4 * 1600):
            v.write("\x00" * 256)  # Disk.bytesPerSector
    shutil.copyfile(Disks.recsgen, Disks.work)

    # volume operations
    xvm(Disks.volumes, "2", "-w", Disks.recsgen, "--keep-size")
    xvm(Disks.volumes, "1,3-4", "-w", Disks.recsdis, "--keep-size")

    with open(Files.error, "w") as fout:
        xvm(Disks.volumes, "1-5", stdout=fout)
        xvm(Disks.volumes, "4", "-i", stdout=fout)
        xvm(Disks.volumes, "5", "-i", stderr=fout, rc=1)

    xvm(Disks.volumes, "2", "-r", Files.output)
    checkFilesEq("xvm", Files.output, Disks.recsgen, "P")
    xvm(Disks.volumes, "1", "-r", Files.output)
    checkFilesEq("xvm", Files.output, Disks.recsdis, "P")
    xvm(Disks.volumes, "4", "-r", Files.output)
    checkFilesEq("xvm", Files.output, Disks.recsdis, "P")
    xvm(Disks.volumes, "4", "-r", Files.output, "--keep-size")
    checkFilesEq("xvm",
                 Files.output,
                 Disks.recsdis,
                 "P",
                 mask=[(360 * 256, 1600 * 256)])

    # file operations
    xvm(Disks.volumes, "2", "-e", "DF254X015P", "-o", Files.output)
    xdm(Disks.recsgen, "-e", "DF254X015P", "-o", Files.reference)
    checkFilesEq("xvm", Files.output, Files.reference, "P")

    xvm(Disks.volumes, "1", "-w", Disks.work, "--keep-size")
    ref = os.path.join(Dirs.refs, "sector1")
    xdm(Disks.work, "-a", ref, "-f", "DF80")
    xvm(Disks.volumes, "1", "-a", ref, "-f", "DF80")
    xvm(Disks.volumes, "1", "-r", Files.output)
    checkFilesEq("xvm", Files.output, Disks.work, "P")

    xvm(Disks.volumes, "3", "-w", Disks.work)
    xvm(Disks.volumes, "3", "-a", ref, "-f", "DF80", "-n", "REFFILE")
    xvm(Disks.volumes, "3", "-r", Files.output)
    xdm(Files.output, "-e", "REFFILE", "-q", "-o", Files.reference)

    ref = os.path.join(Dirs.refs, "glob")
    xvm(Disks.volumes, "1", "-a", ref + "?", "-n", "GLOBA1", shell=True)
    xvm(Disks.volumes, "1", "-e", "GLOBA1", "-o", Files.output)
    xvm(Disks.volumes, "1", "-e", "GLOBA2", "-o", Files.output)
    with open(Files.error, "w") as ferr:
        xvm(Disks.volumes,
            "1",
            "-e",
            "GLOBA3",
            "-o",
            Files.output,
            stderr=ferr,
            rc=1)
    xvm(Disks.volumes, "1", "-d", "GLOB*", "-o", Files.output)
    xvm(Disks.volumes, "1", "-a", ref + "*", "-n", "GLOBB1", shell=True)
    xvm(Disks.volumes, "1", "-e", "GLOBB1", "-o", Files.output)
    xvm(Disks.volumes, "1", "-e", "GLOBB2", "-o", Files.output)
    xvm(Disks.volumes, "1", "-e", "GLOBB3", "-o", Files.output)

    # cleanup
    os.remove(Files.output)
    os.remove(Files.reference)
    os.remove(Files.error)
    os.remove(Disks.work)
    os.remove(Disks.volumes)
Esempio n. 12
0
def runtest():
    """check command line interface"""

    # setup
    shutil.copyfile(Disks.recsgen, Disks.work)

    # disk image operations
    with open(Files.output, "w") as f1, open(Files.reference, "w") as f2:
        xdm(Disks.work, "-i", stdout=f2)
        xdm(Disks.work, "-q", stdout=f1)
    checkFilesEq("CLI", Files.output, Files.reference, "DIS/VAR255")

    xdm(Disks.work, "-e", "PROG00255", "DV064X010", "DF002X001")
    xdm(Disks.work, "-e", "PROG00255", "-o", Files.output)
    checkFilesEq("CLI", Files.output, "prog00255", "PROGRAM")
    xdm(Disks.work, "-e", "DV064X010", "-o", Files.output)
    checkFilesEq("CLI", Files.output, "dv064x010", "DIS/VAR64")
    xdm(Disks.work, "-e", "DF002X001", "-o", Files.output)
    checkFilesEq("CLI", Files.output, "df002x001", "DIS/FIX 2")

    with open(Files.output, "w") as f1:
        xdm(Disks.work, "-p", "DV064X010", stdout=f1)
    checkFilesEq("CLI", Files.output, "dv064x010", "DIS/VAR 64")

    with open(Files.error, "w") as ferr:
        xdm(Disks.work, "-e", "INVALID", stderr=ferr, rc=1)

    xdm(Disks.work, "-S", "0x01", "-o", Files.output)
    checkFilesEq("CLI", Files.output,
                 os.path.join(Dirs.refs, "sector1"), "DIS/VAR255")

    # add, rename, remove files
    shutil.copyfile(Disks.blank, Disks.work)
    xdm(Disks.work, "-a", "prog00255", "dv064x010", "df002x001")
    xdm(Disks.work, "-e", "PROG00255", "-o", Files.output)
    checkFilesEq("CLI", Files.output, "prog00255", "PROGRAM")
    xdm(Disks.work, "-e", "DV064X010", "-o", Files.output)
    checkFilesEq("CLI", Files.output, "dv064x010", "PROGRAM")  #!

    shutil.copyfile(Disks.work, Disks.tifiles)
    xdm(Disks.work, "-e", "PROG00255", "-o", Files.reference)
    xdm(Disks.work, "-r", "PROG00255:OTHERNAME")
    xdm(Disks.work, "-e", "OTHERNAME", "-o", Files.output)
    checkFilesEq("CLI", Files.output, Files.reference, "P")
    xdm(Disks.work, "-r", "OTHERNAME:PROG00255")
    checkFilesEq("CLI", Disks.work, Disks.tifiles, "P")

    xdm(Disks.work, "-d", "PROG00255", "DV064X010", "DF002X001")
    with open(Files.output, "w") as f1, open(Files.reference, "w") as f2:
        xdm(Disks.work, "-i", stdout=f1)
        xdm(Disks.blank, "-i", stdout=f2)
    checkFilesEq("CLI", Files.output, Files.reference, "DIS/VAR255")

    shutil.copyfile(Disks.recsgen, Disks.work)
    xdm(Disks.work, "-e", "DF127*", "PROG00001", "PROG00002")
    if (not os.path.isfile("df127x001") or not os.path.isfile("df127x010") or
        not os.path.isfile("df127x020p")):
        error("CLI", "DF127*: Missing files")

    xdm(Disks.work, "-d", "PROG*", "D?010X060")
    with open(Files.error, "w") as ferr:
        xdm(Disks.work, "-e", "PROG00255", stderr=ferr, rc=1)
        xdm(Disks.work, "-e", "DV010X060", stderr=ferr, rc=1)
        xdm(Disks.work, "-e", "DF010X060", stderr=ferr, rc=1)

    # multi-file naming
    xdm(Disks.work, "-n", "MULTI", "-a", "prog00001", "prog00255", "prog00002")
    xdm(Disks.work, "-e", "MULTI", "-o", Files.output)
    checkFilesEq("CLI", "prog00001", Files.output, "P")
    xdm(Disks.work, "-e", "MULTJ", "-o", Files.output)
    checkFilesEq("CLI", "prog00255", Files.output, "P")
    xdm(Disks.work, "-e", "MULTK", "-o", Files.output)
    checkFilesEq("CLI", "prog00002", Files.output, "P")

    xdm("-T", "prog00001", "prog00255", "prog00002", "-n", "MULTFI")
    xdm(Disks.work, "-t", "-a", "prog00001.tfi", "prog00255.tfi",
        "prog00002.tfi")
    xdm(Disks.work, "-e", "MULTFI", "-o", Files.output)
    checkFilesEq("CLI", "prog00001", Files.output, "P")
    xdm(Disks.work, "-e", "MULTFJ", "-o", Files.output)
    checkFilesEq("CLI", "prog00255", Files.output, "P")
    xdm(Disks.work, "-e", "MULTFK", "-o", Files.output)
    checkFilesEq("CLI", "prog00002", Files.output, "P")

    xdm("-T", "prog00255", "prog00002", "-9", "-n", "MULV9T")
    xdm(Disks.work, "-9", "-a", "prog00255.v9t9", "prog00002.v9t9")
    xdm(Disks.work, "-e", "MULV9T", "-o", Files.output)
    checkFilesEq("CLI", "prog00255", Files.output, "P")
    xdm(Disks.work, "-e", "MULV9U", "-o", Files.output)
    checkFilesEq("CLI", "prog00002", Files.output, "P")

    ref = os.path.join(Dirs.refs, "glob")
    xdm(Disks.work, "-a", ref + "?", "-n", "GLOBA1", shell=True)
    xdm(Disks.work, "-e", "GLOBA1", "-o", Files.output)
    xdm(Disks.work, "-e", "GLOBA2", "-o", Files.output)
    with open(Files.error, "w") as ferr:
        xdm(Disks.work, "-e", "GLOBA3", "-o", Files.output, stderr=ferr, rc=1)
    xdm(Disks.work, "-d", "GLOB*", "-o", Files.output)
    xdm(Disks.work, "-a", ref + "*", "-n", "GLOBB1", shell=True)
    xdm(Disks.work, "-e", "GLOBB1", "-o", Files.output)
    xdm(Disks.work, "-e", "GLOBB2", "-o", Files.output)
    xdm(Disks.work, "-e", "GLOBB3", "-o", Files.output)

    # initialize disk
    xdm(Disks.work, "--initialize", "360", "-n", "SSSD")
    checkFileSize(Disks.work, 360 * 256)
    checkFilesEq("CLI", Disks.work, Disks.blank, "P")
    os.remove(Disks.work)
    xdm(Disks.work, "--initialize", "SSSD", "-n", "SSSD")
    checkFileSize(Disks.work, 360 * 256)
    checkFilesEq("CLI", Disks.work, Disks.blank, "P")
    xdm(Disks.work, "--initialize", "800", "-n", "INIT")
    with open(Files.output, "w") as f:
        xdm(Disks.work, "-i", stdout=f)
    checkFileMatches(Files.output, [(0, "\s2\s+used\s+798\s+free\s")])
    os.remove(Disks.work)
    xdm(Disks.work, "--initialize", "CF", "-n", "INIT")
    with open(Files.output, "w") as f:
        xdm(Disks.work, "-i", stdout=f)
    checkFileMatches(Files.output, [(0, "\s2\s+used\s+1598\s+free\s")])
    with open(Files.error, "w") as ferr:
        xdm(Disks.work, "--initialize", "1", stderr=ferr, rc=1)
        xdm(Disks.work, "--initialize", "1601", stderr=ferr, rc=1)
        xdm(Disks.work, "--initialize", "FOO", stderr=ferr, rc=1)
    f = os.path.join(Dirs.refs, "vardis")
    for n in ["AA", "BB"]:
        xdm(Disks.work, "--initialize", "SSSD", "-a", f, "-n", n)
        with open(Files.output, "w") as fout:
            xdm(Disks.work, "-i", stdout=fout)
        checkFileMatches(Files.output, [(0, n + "\s+"), (2, n + "\s+")])

    # set geometry
    xdm(Disks.work, "--initialize", "1600", "-n", "GEO")
    for g, p in [("1S1D", "1S/1D\s+40 TpS"), ("99T8D7S", "7S/8D\s+99 TpS"),
                 ("22TDD", "7S/2D\s+22 TpS"), ("DSSD", "2S/1D\s+22 TpS"),
                 ("1T", "2S/1D\s+1 TpS"), ("3D10T9S", "9S/3D\s+10 TpS"),
                 ("SDDS", "2S/1D\s+10 TpS"), ("SS", "1S/1D\s+10 TpS")]:
        xdm(Disks.work, "--set-geometry", g)
        with open(Files.output, "w") as fout:
            xdm(Disks.work, "-i", "-q", stdout=fout)
        checkFileMatches(Files.output, [(0, p)])

    # resize disk
    shutil.copyfile(Disks.recsgen, Disks.work)
    for s in ["800", "248", "1600"]:
        xdm(Disks.work, "-Z", s, "-q")
        for f in ["PROG02560", "DF129X010", "DV127X010", "DV255X015P"]:
            xdm(Disks.work, "-e", f, "-q", "-o", Files.output)
            xdm(Disks.recsgen, "-e", f, "-o", Files.reference)
            checkFilesEq("CLI", Files.output, Files.reference, "PROGRAM")
    with open(Files.error, "w") as ferr:
        xdm(Disks.work, "-Z", "240", stderr=ferr, rc=1)
        xdm(Disks.work, "-Z", "1608", stderr=ferr, rc=1)

    # new geometry handling (v1.5.3)
    for c, g, p in [
            ("--initialize", "SSSD", r"358 free\s+90 KB\s+1S/1D\s+40 TpS"),
            ("--resize", "DS1D", r"718 free\s+180 KB\s+2S/1D\s+40 TpS"),
            ("--set-geometry", "80T", r"718 free\s+180 KB\s+2S/1D\s+80 TpS"), # geom mismatch
            ("--initialize", "408", r"406 free\s+102 KB\s+2S/1D\s+40 TpS"),
            ("--resize", "DSSD80T", r"1438 free\s+360 KB\s+2S/1D\s+80 TpS"),
            ("--resize", "2DSS", r"718 free\s+180 KB\s+1S/2D\s+40 TpS"),
            ("-Z", "208", r"206 free\s+52 KB\s+1S/2D\s+40 TpS"),
            ("--set-geometry", "SD80T", r"206 free\s+52 KB\s+1S/1D\s+80 TpS"),
            ("-X", "DSSD80T", r"1438 free\s+360 KB\s+2S/1D\s+80 TpS"),
            ("--set-geometry", "20T", r"1438 free\s+360 KB\s+2S/1D\s+20 TpS")]: # geom mismatch
        xdm(Disks.work, c, g)
        with open(Files.output, "w") as fout:
            xdm(Disks.work, "-i", "-q", stdout=fout)
        checkFileMatches(Files.output, [(0, p)])
    with open(Files.error, "w") as ferr:
        xdm(Disks.work, "--initialize", "SS80T", stderr=ferr, rc=1)
        xdm(Disks.work, "--resize", "2S", stderr=ferr, rc=1)
        xdm(Disks.work, "--resize", "80T", stderr=ferr, rc=1)
        xdm(Disks.work, "--set-geometry", "123", stderr=ferr, rc=1)
    
    # repair disks
    shutil.copyfile(Disks.bad, Disks.work)
    with open(Files.output, "w") as f1, open(Files.reference, "w") as f2:
        xdm(Disks.work, "-C", stderr=f1, rc=1)
        xdm(Disks.work, "-R", stderr=f2)
    checkFileLen(Files.output, minlines=2)
    with open(Files.output, "w") as f1:
        xdm(Disks.work, "-C", stderr=f1)
    checkFileLen(Files.output, maxlines=0)

    # FIAD operations
    shutil.copyfile(Disks.recsgen, Disks.work)
    xdm(Disks.work, "-e", "PROG00255", "DV064X010", "-t")
    xdm(Disks.work, "-e", "PROG00255", "-t", "-o", Files.output)
    checkFilesEq("CLI", Files.output, "prog00255.tfi", "PROGRAM")
    xdm(Disks.work, "-e", "DV064X010", "-t", "-o", Files.output)
    checkFilesEq("CLI", Files.output, "dv064x010.tfi", "PROGRAM")

    with open(Files.output, "w") as f:
        xdm("-I", "prog00255.tfi", "dv064x010.tfi", stdout=f)

    xdm(Disks.work, "-e", "PROG00255", "DV064X010", "-9")
    xdm(Disks.work, "-e", "PROG00255", "-9", "-o", Files.output)
    checkFilesEq("CLI", Files.output, "prog00255.v9t9", "PROGRAM")
    xdm(Disks.work, "-e", "DV064X010", "-9", "-o", Files.output)
    checkFilesEq("CLI", Files.output, "dv064x010.v9t9", "PROGRAM")

    with open(Files.output, "w") as f:
        xdm("-I", "prog00255.v9t9", "dv064x010.v9t9", stdout=f)

    xdm(Disks.work, "-e", "PROG00255")
    xdm("-T", "prog00255", "-o", Files.output)
    checkFilesEq("CLI", Files.output, "prog00255.tfi", "PROGRAM", Masks.TIFile)
    xdm("-T", "prog00255", "-9", "-o", Files.output)
    checkFilesEq("CLI", Files.output, "prog00255.v9t9", "PROGRAM", Masks.v9t9)

    xdm(Disks.work, "-e", "DV064X010", "-o", Files.reference)
    xdm("-F", "dv064x010.tfi")
    checkFilesEq("CLI", "dv064x010", Files.reference, "DIS/VAR 64")
    xdm("-F", "dv064x010.tfi", "-o", Files.output)
    checkFilesEq("CLI", Files.output, "dv064x010", "PROGRAM")

    xdm("-F", "dv064x010.v9t9", "-9")
    checkFilesEq("CLI", "dv064x010", Files.reference, "DIS/VAR 64")
    xdm("-F", "dv064x010.v9t9", "-o", Files.output)
    checkFilesEq("CLI", Files.output, "dv064x010", "PROGRAM")

    xdm("-T", "dv064x010", "-o", Files.output,
        "-n", "DV064X010", "-f", "DIS/VAR 64")
    checkFilesEq("CLI", Files.output, "dv064x010.tfi", "PROGRAM", Masks.TIFile)
    os.remove("dv064x010.tfi")
    xdm("-T", "dv064x010", "-n", "DV064X010", "-f", "DIS/VAR 64")
    checkFilesEq("CLI", "dv064x010.tfi", Files.output, "PROGRAM", Masks.TIFile)

    xdm("-T", "dv064x010", "-9", "-o", Files.output,
        "-n", "DV064X010", "-f", "DIS/VAR 64")
    checkFilesEq("CLI", Files.output, "dv064x010.v9t9", "PROGRAM", Masks.v9t9)
    os.remove("dv064x010.v9t9")
    xdm("-T", "dv064x010", "-9", "-n", "DV064X010", "-f", "DIS/VAR 64")
    checkFilesEq("CLI", "dv064x010.v9t9", Files.output, "PROGRAM", Masks.v9t9)

    # stdin and stdout
    ref = os.path.join(Dirs.refs, "vardis")
    with open(ref, "r") as fin:
        xdm(Disks.work, "--initialize", "sssd", "-a", "-", "-f", "dv40", stdin=fin)
    with open(Files.output, "w") as fout:
        xdm(Disks.work, "-e", "STDIN", "-o", "-", stdout=fout)
    checkFilesEq("stdin/stdout", Files.output, ref, "DV")
    ref = os.path.join(Dirs.refs, "sector1")
    with open(Files.reference, "wb") as fout:
        xdm(Disks.work, "--initialize", "sssd", "-a", ref, "-n", "T", "-o", "-", stdout=fout)
    with open(Files.reference, "rb") as fin:
        xdm("-", "-e", "T", "-o", Files.output, stdin=fin)
    checkFilesEq("stdin/stdout", Files.output, ref, "P")
        
    # usage errors
    with open(Files.error, "w") as ferr:
        xdm("-a", Files.output, stderr=ferr, rc=1)
        xdm("-T", "prog00001", "prog00002", "-o", Files.output,
            stderr=ferr, rc=1)
        xdm("-T", "prog00001", "prog00002", "-9", "-o", Files.output,
            stderr=ferr, rc=1)
        xdm("-F", "-o", Files.output, stderr=ferr, rc=2)

    # cleanup
    os.remove(Files.output)
    os.remove(Files.reference)
    os.remove(Files.error)
    os.remove(Disks.work)
    os.remove(Disks.tifiles)
    for fn in [
        "prog00001", "prog00002", "prog00255", "dv064x010",
        "df002x001", "df127x001", "df127x010", "df127x020p",
        "prog00001.tfi", "prog00002.tfi", "prog00255.tfi", "dv064x010.tfi",
        "prog00002.v9t9", "prog00255.v9t9", "dv064x010.v9t9"
        ]:
        os.remove(fn)
Esempio n. 13
0
def runtest():
    """check reading and writing of random data"""
    
    # setup
    shutil.copyfile(Disks.blank, Disks.work)
    shutil.copyfile(Disks.blank, Disks.tifiles)

    # create files
    files = []
    for count, length in [
            (1, 2), (300, 2), (60, 10), (10, 63), (10, 64), (10, 126),
            (1, 127), (10, 127), (10, 128), (10, 129), (1, 254), (5, 254),
            (1, 255), (5, 255)
            ]:
        files.append(createTextFile(count, length, False, False))
        files.append(createTextFile(count, length, True, False))
    for count, length in [(20, 127), (15, 254), (15, 255)]:
        files.append(createTextFile(count, length, False, True))
        files.append(createTextFile(count, length, True, True))
    for size in [1, 2, 254, 255, 511, 513, 2560]:
        files.append(createBinaryFile(size))

    bigFiles = []
    for count, length in [(200, 127), (100, 254), (100, 255)]:
        bigFiles.append(createTextFile(count, length, False, True))
        bigFiles.append(createTextFile(count, length, True, True))
    for size in [25600]:
        bigFiles.append(createBinaryFile(size))

    # add files one by one and check
    for name, path, fmt in files:
        xdm(Disks.work, "-a", path, "-f", fmt)
        xdm(Disks.work, "-e", name, "-o", Files.output)
        checkFilesEq("Write records", Files.output, path, fmt)

    # remove files one by one and check
    for name, path, fmt in files:
        xdm(Disks.work, "-e", name, "-o", Files.output)
        checkFilesEq("Write records", Files.output, path, fmt)
        xdm(Disks.work, "-d", name)

    # add all files
    for name, path, fmt in files:
        xdm(Disks.work, "-a", path, "-f", fmt)

    # extract in and convert to/from TIFiles format
    for name, path, fmt in files:
        xdm(Disks.work, "-e", name, "-o", Files.reference)
        xdm(Disks.work, "-e", name, "-t", "-o", Files.tifile)
        xdm("-F", Files.tifile, "-o", Files.output)
        checkFilesEq("Write records", Files.output, Files.reference, fmt)
        xdm("-T", Files.reference, "-o", Files.output, "-f", fmt, "-n", name)
        checkFilesEq("Write records", Files.output, Files.tifile,
                     "PROGRAM", [(0x1e, 0x26)])

    # add and remove TIFiles files
    for name, path, fmt in files:
        xdm(Disks.work, "-e", name, "-t", "-o", Files.tifile)
        xdm(Disks.tifiles, "-t", "-a", Files.tifile)
    checkFilesEq("Write records", Disks.tifiles, Disks.work, "P")

    # convert to and from TIFiles cycle
    for name, fmt in [("intvar32v", "IV32"), ("intfix32v", "IF32"),
                      ("vardis", "dv40")]:
        path = os.path.join(Dirs.refs, name)
        xdm(Disks.work, "-a", path, "-f", fmt, "-n", "T")
        xdm(Disks.work, "-e", "T", "-t", "-o", Files.output)
        xdm(Disks.work, "-d", "T")
        xdm(Disks.work, "-a", Files.output, "-t")
        xdm(Disks.work, "-e", "T", "-o", Files.output)
        checkFilesEq("TIFiles cycle", Files.output, path, fmt)

    # add and remove big files
    for name, path, fmt in bigFiles:
        xdm(Disks.work, "-a", path, "-f", fmt)
        xdm(Disks.work, "-e", name, "-o", Files.output)
        checkFilesEq("Write records", Files.output, path, fmt)
        xdm(Disks.work, "-d", name)

    # check truncating of DIS/VAR files with long records
    path = os.path.join(Dirs.refs, "vardis")
    with open(path, "r") as f:
        reflines = f.readlines()
    for l in [8, 7, 4]:
        xdm(Disks.work, "-a", path, "-f", "DV%d" % l, "-q")
        xdm(Disks.work, "-e", "VARDIS", "-o", Files.output)
        checkTrunc(Files.output, reflines, l)

    # create well-defined TI disk (checked-in state frozen)
    shutil.copyfile(Disks.recsgen, Disks.work)
    for name, path, fmt in files:
        xdm(Disks.work, "-a", path, "-f", fmt)

    # remove temporary files
    for name, path, fmt in files + bigFiles:
        os.remove(path)
    os.remove(Files.output)
    os.remove(Files.tifile)
    os.remove(Files.reference)
    os.remove(Disks.work)
    os.remove(Disks.tifiles)
Esempio n. 14
0
def runtest():
    """compare xbas99 generation to TI references"""

    for fn in [
            "KEYWORDS", "STATMNTS", "NUMBERS", "COMMENTS", "LOWRCASE",
            "GIBBRISH"
            ]:
        # compare generated xbas99 listing with TI BASIC reference
        xdm(Disks.basic1, "-e", fn, "-o", Files.input)
        xdm(Disks.basic1, "-e", fn + "-L", "-o", Files.reference)
        xbas(Files.input, "-d", "-o", Files.output)
        checkListingEq(Files.output, Files.reference)

        # ditto with MERGE format
        xdm(Disks.basic1, "-e", fn + "-M", "-o", Files.input)
        xbas(Files.input, "-d", "--merge", "-o", Files.output)
        if os.name != "nt":
            checkListingEq(Files.output, Files.reference)

        # compare generated xbas99 basic program with TI BASIC reference
        xdm(Disks.basic1, "-e", fn + "-L", "-o", Files.input)
        xdm(Disks.basic1, "-e", fn, "-o", Files.reference)
        xbas(Files.input, "-c", "-j", "3", "-o", Files.output)
        checkFilesEq("Tokenization", Files.output, Files.reference, "P")

        # ditto with non-canonically formatted original source
        rawlist = os.path.join(Dirs.basic, fn.lower() + ".txt")
        genListing(rawlist, Files.input)
        xbas(Files.input, "-c", "-o", Files.output)
        checkFilesEq("Tokenization", Files.output, Files.reference, "P")

    # check using randomized listings
    for i in xrange(8):
        fn = "RAND%02d" % i
        xdm(Disks.basic2, "-e", fn, "-o", Files.input)
        xdm(Disks.basic2, "-e", fn + "-L", "-o", Files.reference)

        # compare generated xbas99 listing with TI BASIC reference
        xbas(Files.input, "-d", "-o", Files.output)
        checkListingEq(Files.output, Files.reference)

        # compare generated xbas99 basic program with TI BASIC reference
        xbas(Files.reference, "-c", "-j", "3", "-o", Files.output)
        checkFilesEq("Tokenization", Files.output, Files.input, "P")

    # check long format
    path = os.path.join(Dirs.basic, "sample-l.bin")
    xbas(path, "-d", "-o", Files.output)
    path = os.path.join(Dirs.basic, "sample-n.bin")
    xbas(path, "-d", "-o", Files.reference)
    checkFilesEq("Long Format", Files.output, Files.reference, "P")

    # check listing protection
    xdm(Disks.basic1, "-e", "STATMNTS-L", "-o", Files.input)
    xbas(Files.input, "-c", "-j", "3", "--protect", "-o", Files.output)
    xbas(Files.input, "-c", "-j", "3", "-o", Files.reference)
    checkFilesEq("Protection", Files.output, Files.reference, "P",
                 mask=[(0, 2)])

    # cleanup
    os.remove(Files.input)
    os.remove(Files.output)
    os.remove(Files.reference)
Esempio n. 15
0
def runtest():
    """check cross-generated output against native reference files"""

    # object code
    for infile, opts, reffile in [("gaops.gpl", [], "GAOPS-Q"),
                                  ("gainst.gpl", [], "GAINST-Q"),
                                  (
                                      "gabranch.gpl",
                                      [],
                                      "GABRANCH-Q",
                                  ), ("gamove.gpl", [], "GAMOVE-Q"),
                                  ("gafmt.gpl", ["-s", "rag"], "GAFMT-Q"),
                                  ("gadirs.gpl", [], "GADIRS-Q"),
                                  ("gacopy.gpl", [], "GACOPY-Q"),
                                  ("gaexts.gpl", [], "GAEXTS-Q"),
                                  ("gapass.gpl", [], "GAPASS-Q")]:
        source = os.path.join(Dirs.gplsources, infile)
        xdm(Disks.gplsrcs, "-e", reffile, "-o", Files.reference)
        xga(*[source] + opts + ["-o", Files.output])
        checkGbcFilesEq(infile, Files.output, Files.reference)

    # cart generation
    for name in ["gacart", "gahello"]:
        source = os.path.join(Dirs.gplsources, name + ".gpl")
        ref = os.path.join(Dirs.refs, name + ".rpk")
        xga(source, "-c", "-o", Files.output)
        checkFilesEq("GPL cart",
                     Files.output,
                     ref,
                     "P",
                     mask=((0x8, 0x1e), (0x188, 0xfff)))

    # extensions
    source = os.path.join(Dirs.gplsources, "gaxprep.gpl")
    xga(source, "-D", "isdef=2", "-o", Files.output)
    xdm(Disks.gplsrcs, "-e", "GAXPREP-Q", "-o", Files.reference)
    checkGbcFilesEq(source, Files.output, Files.reference)

    # error messages
    for s in ["gaerrs0.gpl", "gaerrs1.gpl"]:
        source = os.path.join(Dirs.gplsources, s)
        with open(source, "r") as fin:
            expect = [
                lino + 1 for lino, line in enumerate(fin) if "* ERROR" in line
            ]
        with open(Files.error, "w") as ferr:
            xga(source, "-o", Files.output, stderr=ferr, rc=1)
        with open(Files.error, "r") as fin:
            try:
                found = [int(line[:4]) for line in fin if line[0] != "*"]
            except ValueError:
                error("Error messages", "Unexpected error message")
        if found != expect:
            error(
                "Error messages", "Error mismatch, extra: " +
                str([x for x in found if x not in expect]) + " missing: " +
                str([x for x in expect if x not in found]))

    # cleanup
    os.remove(Files.output)
    os.remove(Files.reference)
    os.remove(Files.error)