예제 #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", [], "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 + ["-w", "-o", Files.output])
        check_gbc_files_eq(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)
        check_files_eq("GPL cart",
                       Files.output,
                       ref,
                       "P",
                       mask=((0x8, 0x1e), (0x188, 0xfff)))

    # cleanup
    os.remove(Files.output)
    os.remove(Files.reference)
예제 #2
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', [], '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 + ['-q', '-o', Files.output])
        check_gbc_files_eq(infile, Files.output, Files.reference)

    # cart generation
    source = os.path.join(Dirs.gplsources, 'gahello.gpl')
    ref = os.path.join(Dirs.refs, 'gahello.rpk')
    xga(source, '-c', '-o', Files.output)
    with ZipFile(Files.output, 'r') as zout, ZipFile(ref, 'r') as zref:
        outdata = zout.read('GAHELLO.bin')
        refdata = zref.read('GAHELLO.bin')
        if outdata != refdata:
            error('GPL cart', 'Main file mismatch')
        if 'layout.xml' not in zout.namelist(
        ) or 'meta-inf.xml' not in zout.namelist():
            error('GPL cart', 'Missing layout or meta-inf files in RPK')

    # cleanup
    os.remove(Files.output)
    os.remove(Files.reference)
예제 #3
0
def writeImage(disk, data, name):
    """write raw data as image file to disk"""
    image = chrw(0) + chrw(imageSize) + chrw(0xA000) + data + (chrw(0x1000) * (
        (imageSize - len(data) - 6) / 2))
    path = os.path.join(Dirs.sources, name + ".img")
    with open(path, "wb") as f:
        f.write(image)
    xdm(disk, "-a", path, "-n", name)
예제 #4
0
def write_image(disk, data, name):
    """write raw data as image file to disk"""
    image = (bytes(1) + chrw(IMAGE_SIZE) + chrw(0xa000) + data +
             (chrw(0x1000) * ((IMAGE_SIZE - len(data) - 6) / 2)))
    path = os.path.join(Dirs.sources, name + '.img')
    with open(path, 'wb') as f:
        f.write(image)
    xdm(disk, '-a', path, '-n', name)
예제 #5
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)
예제 #6
0
def runtest():
    """check cross-generated output against native reference files"""

    for infile, opts, reffile in [("ashello.asm", ["-R"], "ASHELLO-L"),
                                  ("asdirs.asm", [], "ASDIRS-L"),
                                  ("asorgs.asm", [], "ASORGS-L"),
                                  ("asopcs.asm", [], "ASOPCS-L"),
                                  ("asexprs.asm", [], "ASEXPRS-L"),
                                  ("asbss.asm", [], "ASBSS-L"),
                                  ("asregs.asm", ["-R"], "ASREGS-L"),
                                  ("assize1.asm", [], "ASSIZE1-L"),
                                  ("assize2.asm", [], "ASSIZE2-L"),
                                  ("assize3.asm", [], "ASSIZE3-L"),
                                  ("assize4.asm", [], "ASSIZE4-L"),
                                  ("astisym.asm", [], "ASTISYM-L"),
                                  ("asimg1.asm", [], "ASIMG1-L"),
                                  ("asimg2.asm", [], "ASIMG2-L"),
                                  ("asimg3.asm", [], "ASIMG3-L"),
                                  ("ascart.asm", ["-R", "-s"], "ASCART-L")]:
        source = os.path.join(Dirs.sources, infile)
        xas(*[source] + opts + ["-L", Files.output, "-o", Files.reference])
        xdm(Disks.asmsrcs, "-e", reffile, "-o", Files.reference)
        check_list_files_eq(Files.output, Files.reference)

    for infile, opts, reffile in [("ascopy.asm", [], "ASCOPY-L")
                                  #("ascopyn.asm", [], "ASCOPYN-L")
                                  ]:
        source = os.path.join(Dirs.sources, infile)
        xas(*[source] + opts + ["-L", Files.output, "-o", Files.reference])
        xdm(Disks.asmsrcs, "-e", reffile, "-o", Files.reference)
        check_list_files_eq(Files.output, Files.reference, ignore_lino=True)

    # symbols
    source = os.path.join(Dirs.sources, "ashello.asm")
    xas(source, "-R", "-L", Files.output, "-S", "-o", Files.input)
    reffile = os.path.join(Dirs.refs, "ashello.sym")
    check_end_equal(Files.output, reffile)

    # EQUs
    source = os.path.join(Dirs.sources, "ashello.asm")
    xas(source, "-R", "-E", Files.output, "-o", Files.input)
    reffile = os.path.join(Dirs.refs, "ashello.sym")
    check_sym_equ_equiv(Files.output, reffile)

    # auto-generated constants
    source = os.path.join(Dirs.sources, "asautogen.asm")
    xas(source, "-R", "-o", Files.error, "-S", "-L", Files.input)
    with open(Files.input, "r") as fin, open(Files.output, "w") as fout:
        lines = fin.readlines()[-20:]
        fout.writelines(lines)
    reffile = os.path.join(Dirs.refs, "asautogen.lst")
    check_text_files_eq("autogen", Files.output, reffile)

    # cleanup
    os.remove(Files.output)
    os.remove(Files.reference)
    os.remove(Files.error)
예제 #7
0
def runtest():
    """run regression tests"""

    # other syntax
    source = os.path.join(Dirs.gplsources, 'gahello_timt.gpl')
    xga(source, '-y', 'mizapf', '-o', Files.output)
    ref = os.path.join(Dirs.gplsources, 'gahello.gpl')
    xga(ref, '-o', Files.reference)
    check_binary_files_eq('syntax', Files.output, Files.reference)

    # preprocessor
    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)
    check_gbc_files_eq(source, Files.output, Files.reference)

    # directives
    source = os.path.join(Dirs.gplsources, 'gaxbcopy.gpl')
    xga(source, '-I', 'gpl', '-o', Files.output)
    source = os.path.join(Dirs.gplsources, 'gaxbcopyn.gpl')
    xga(source, '-o', Files.reference)
    check_binary_files_eq('bcopy', Files.output, Files.reference)

    # local labels
    source = os.path.join(Dirs.gplsources, 'gaxlocal.gpl')
    xga(source, '-o', Files.output)
    ref = os.path.join(Dirs.gplsources, 'gaxlocaln.gpl')
    xga(ref, '-o', Files.reference)
    check_binary_files_eq('locals', Files.output, Files.reference)

    # floating-point numbers
    source = os.path.join(Dirs.gplsources, 'gafloat.gpl')
    xga(source, '-o', Files.output)
    ref = os.path.join(Dirs.refs, 'asfloat.ref')
    check_binary_files_eq('float', Files.output, ref)

    # GROM n or address
    for source in (' GROM >6000\n DATA $', ' GROM 3\n DATA $'):
        with open(Files.input, 'w') as fout:
            fout.writelines(source)
        xga(Files.input, '-o', Files.output)
        with open(Files.output, 'rb') as fin:
            if fin.read()[:4] != b'\x60\x00':
                error('GROM', 'Incorrect address after GROM directive')

    # split GROMs
    source = os.path.join(Dirs.gplsources, 'gasplit.gpl')
    xga(source, '-g', '-o', Files.output)
    check_split_groms(3, 3)

    # cleanup
    os.remove(Files.input)
    os.remove(Files.output)
    os.remove(Files.reference)
예제 #8
0
def writesrc():
    # create disk
    if not os.path.isfile(Disks.asmsrcs):
        shutil.copyfile(Disks.blankDD, Disks.asmsrcs)
    # create source files
    for name in [
            "ASHELLON", "ASDIRS", "ASBSS", "ASORGS", "ASOPCS", "ASEXPRS",
            "ASREGS", "ASSIZE1", "ASSIZE2", "ASSIZE3", "ASSIZE4", "ASCOPY",
            "ASCOPY1", "ASCOPY2", "ASCOPY3", "ASCOPY4", "ASCOPYN-TI", "ASIMG1",
            "ASIMG2", "ASIMG3", "ASTISYM", "ASCART", "ASXEXT", "ASXEXT0-TI",
            "ASXEXT1-TI", "ASXEXT2-TI", "ASERRS"
    ]:
        source = os.path.join(Dirs.sources, name.lower() + ".asm")
        xdm(Disks.asmsrcs, "-a", source, "-n", name, "-f", "DIS/VAR80")
예제 #9
0
def writesrc():
    # create disk
    if not os.path.isfile(Disks.asmsrcs):
        shutil.copyfile(Disks.blankDD, Disks.asmsrcs)
    # create source files
    for name in [
            "ASHELLO", "ASDIRS", "ASBSS", "ASORGS", "ASOPCS", "ASEXPRS",
            "ASREGS", "ASSIZE1", "ASSIZE2", "ASSIZE3", "ASSIZE4",
            "ASCOPY", "ASCOPY1", "ASCOPY2", "ASCOPY3", "ASCOPY4",
            "ASCOPYN-TI", "ASIMG1", "ASIMG2", "ASIMG3", "ASTISYM",
            "ASCART", "ASXEXT", "ASXEXT0-TI", "ASXEXT1-TI", "ASXEXT2-TI",
            "ASERRS"
            ]:
        source = os.path.join(Dirs.sources, name.lower() + ".asm")
        xdm(Disks.asmsrcs, "-a", source, "-n", name, "-f", "DIS/VAR80")
예제 #10
0
def runtest():
    """run regression tests"""

    # preprocessor
    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)
    check_gbc_files_eq(source, Files.output, Files.reference)

    # directives
    source = os.path.join(Dirs.gplsources, "gaxbcopy.gpl")
    xga(source, "-I", "gpl", "-o", Files.output)
    source = os.path.join(Dirs.gplsources, "gaxbcopyn.gpl")
    xga(source, "-o", Files.reference)
    check_binary_files_eq("bcopy", Files.output, Files.reference)

    # local labels
    source = os.path.join(Dirs.gplsources, "gaxlocal.gpl")
    xga(source, "-o", Files.output)
    ref = os.path.join(Dirs.gplsources, "gaxlocaln.gpl")
    xga(ref, "-o", Files.reference)
    check_binary_files_eq("locals", Files.output, Files.reference)

    # floating-point numbers
    source = os.path.join(Dirs.gplsources, "gafloat.gpl")
    xga(source, "-o", Files.output)
    ref = os.path.join(Dirs.refs, "asfloat.ref")
    check_binary_files_eq("float", Files.output, ref)

    # GROM n or address
    for source in (" GROM >6000\n DATA $", " GROM 3\n DATA $"):
        with open(Files.input, "w") as fout:
            fout.writelines(source)
        xga(Files.input, "-o", Files.output)
        with open(Files.output, "rb") as fin:
            if fin.read()[:4] != "\x60\x00":
                error("GROM", "Incorrect address after GROM directive")

    # cleanup
    os.remove(Files.input)
    os.remove(Files.output)
    os.remove(Files.reference)
예제 #11
0
def runtest():
    """check cross-generated output against native reference files"""

    for infile, opts, reffile in [
            ("ashello.asm", ["-R"], "ASHELLO-L"),
            ("asdirs.asm", [], "ASDIRS-L"),
            ("asorgs.asm", [], "ASORGS-L"),
            ("asopcs.asm", [], "ASOPCS-L"),
            ("asexprs.asm", [], "ASEXPRS-L"),
            ("asbss.asm", [], "ASBSS-L"),
            ("asregs.asm", ["-R"], "ASREGS-L"),
            ("assize1.asm", [], "ASSIZE1-L"),
            ("assize2.asm", [], "ASSIZE2-L"),
            ("assize3.asm", [], "ASSIZE3-L"),
            ("assize4.asm", [], "ASSIZE4-L"),
            ("astisym.asm", [], "ASTISYM-L"),
            ("asimg1.asm", [], "ASIMG1-L"),
            ("asimg2.asm", [], "ASIMG2-L"),
            ("asimg3.asm", [], "ASIMG3-L"),
            ("ascart.asm", ["-R"], "ASCART-L")
            ]:
        source = os.path.join(Dirs.sources, infile)
        xas(*[source] + opts + ["-L", Files.output, "-o", Files.reference])
        xdm(Disks.asmsrcs, "-e", reffile, "-o", Files.reference)
        checkListFilesEq(Files.output, Files.reference)

    for infile, opts, reffile in [
            ("ascopy.asm", [], "ASCOPY-L")
            #("ascopyn.asm", [], "ASCOPYN-L")
            ]:
        source = os.path.join(Dirs.sources, infile)
        xas(*[source] + opts + ["-L", Files.output, "-o", Files.reference])
        xdm(Disks.asmsrcs, "-e", reffile, "-o", Files.reference)
        checkListFilesEq(Files.output, Files.reference, ignoreLino=True)

    # cleanup
    os.remove(Files.output)
    os.remove(Files.reference)
예제 #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)
예제 #13
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)
예제 #14
0
def runtest():
    """check command line interface"""

    # input and output files
    source = os.path.join(Dirs.sources, 'ashellon.asm')
    with open(Files.output, 'wb') as f:
        xas(source, '-R', '-o', '-', stdout=f)
    xdm(Disks.asmsrcs, '-e', 'ASHELLO-O', '-q', '-o', Files.reference)
    check_obj_code_eq(Files.output, Files.reference)

    xas(source, '-R', '-o', Dirs.tmp)  # -o <dir>
    if not os.path.isfile(os.path.join(Dirs.tmp, 'ashellon.obj')):
        error('output', '-o <dir> failed')

    with open(Files.output, 'wb') as f:
        xas(source,
            '-R',
            '-i',
            '-D',
            'VSBW=>210C',
            'VMBW=>2110',
            'VWTR=>211C',
            'KSCAN=>2108',
            '-o',
            '-',
            stdout=f)
    xdm(Disks.asmsrcs, '-e', 'ASHELLO-I', '-o', Files.reference)
    check_image_files_eq(Files.output, Files.reference)

    with open(Files.output, 'w') as f:
        xas(source, '-R', '-q', '-o', Files.output, '-L', '-', stdout=f)
    xdm(Disks.asmsrcs, '-e', 'ASHELLO-L', '-o', Files.reference)
    check_list_files_eq(Files.output, Files.reference)

    source = os.path.join(Dirs.sources, 'nonexisting')
    with open(Files.error, 'w') as ferr:
        xas(source, '-i', '-R', '-o', Files.output, stderr=ferr, rc=1)
    with open(Files.error, 'r') as ferr:
        errs = ferr.readlines()
    if len(errs) != 1 or 'File not found' not in errs[
            0] or 'nonexisting' not in errs[0]:
        error('File error', 'Incorrect file error message')

    # include path
    source = os.path.join(Dirs.sources, 'ascopyi.asm')
    incls = os.path.join(Dirs.sources, 'test') + ',' + os.path.join(
        Dirs.sources, 'test', 'test')
    xas(source, '-i', '-I', incls, '-o', Files.output)
    with open(Files.output, 'rb') as f:
        data = f.read()
    if len(data) != 6 + 20:
        error('Include paths', 'Incorrect image length')

    # command-line definitions
    source = os.path.join(Dirs.sources, 'asdef.asm')
    xas(source, '-b', '-D', 's1=1', 's3=3', 's2=4', '-o', Files.output)
    if content(Files.output) != b'\x01\x03':
        error('-D', 'Content mismatch')
    xas(source, '-b', '-D', 's1=2,s2=2,s3=3', '-o', Files.output)
    if content(Files.output) != b'\x02\x03':
        error('-D', 'Content mismatch')

    # rebase -a
    source = os.path.join(Dirs.sources, 'asrebase.asm')
    xas(source, '-b', '-a', '>2000', '-o', Files.output)
    ref = os.path.join(Dirs.sources, 'asrebasen.asm')
    xas(ref, '-b', '-o', Files.reference)
    check_binary_files_eq('rebase', Files.output, Files.reference)

    # various parameter combinations
    source = os.path.join(Dirs.sources, 'asxbank1.asm')
    remove([Files.reference])
    xas(source, '-b', '-q', '-o', Files.output, '-L', Files.reference)
    check_exists([Files.reference])

    # text data output
    source = os.path.join(Dirs.sources, 'ascart.asm')
    xas(source, '-b', '-R', '-o', Files.reference)
    xas(source, '-t', 'a2', '-R', '-o', Files.output)
    check_bin_text_equal_bytes(Files.output, Files.reference)

    source = os.path.join(Dirs.sources, 'asmtext.asm')
    xas(source, '-t', 'a2', '-R', '-o', Files.output)
    dat = content(Files.output, mode='r')
    if (not 'aorg >1000' in dat or 'aorg >1010' in dat or 'data' in dat
            or not 'byte' in dat or '0x' in dat or not '>' in dat):
        error('dat', 'Invalid .dat file contents')

    # symbols
    source = os.path.join(Dirs.sources, 'assyms.asm')
    xas(source, '-b', '-R', '-o', Files.reference, '-E', Files.output)
    check_symbols(
        Files.output,
        (
            ('VDPWA', 'SCAN'),  # referencecs
            (('START', '>0000'), ('S1', '>0001'), ('S2', '>0018'))))  # symbols

    # disable warnings
    source = os.path.join(Dirs.sources, 'aswarn.asm')
    with open(Files.error, 'w') as ferr:
        xas(source, '-b', '-R', '-q', '-o', Files.output, stderr=ferr, rc=0)
    if content_len(Files.error) > 0:
        error('warn', 'warnings, even though disabled')

    # linker
    source1 = os.path.join(Dirs.sources, 'aslink0a.asm')
    source2 = os.path.join(Dirs.sources, 'aslink0b.asm')
    xas(source1, '-q', '-o', Files.input)
    xas(source2, '-q', '-o', Files.output)
    with open(Files.error, "w") as ferr:
        xas('-l',
            Files.input,
            '-ll',
            Files.output,
            '-o',
            Files.reference,
            rc=2,
            stderr=ferr)  # mutually exclusive

    # cleanup
    os.remove(Files.output)
    os.remove(Files.reference)
    os.remove(Files.error)
예제 #15
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)
예제 #16
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)
예제 #17
0
def runtest():
    """check command line interface"""

    # input and output files
    source = os.path.join(Dirs.sources, "ashello.asm")
    with open(Files.output, "wb") as f:
        xas(source, "-R", "-o", "-", stdout=f)
    xdm(Disks.asmsrcs, "-e", "ASHELLO-O", "-o", Files.reference)
    checkObjCodeEq(Files.output, Files.reference)

    with open(Files.output, "wb") as f:
        xas(source, "-R", "-i", "-o", "-", stdout=f)
    xdm(Disks.asmsrcs, "-e", "ASHELLO-I", "-o", Files.reference)
    checkImageFilesEq(Files.output, Files.reference)

    with open(Files.output, "w") as f:
        xas(source, "-R", "-o", Files.output, "-L", "-", stdout=f)
    xdm(Disks.asmsrcs, "-e", "ASHELLO-L", "-o", Files.reference)
    checkListFilesEq(Files.output, Files.reference)

    source = os.path.join(Dirs.sources, "nonexisting")
    with open(Files.error, "w") as ferr:
        xas(source, "-i", "-R", "-o", Files.output, stderr=ferr, rc=1)
    with open(Files.error, "r") as ferr:
        errs = ferr.readlines()
    if len(errs) != 1 or errs[0][:10] != "File error":
        error("File errors", "Incorrect file error message")

    # include path
    source = os.path.join(Dirs.sources, "ascopyi.asm")
    incls = os.path.join(Dirs.sources, "test") + "," + \
        os.path.join(Dirs.sources, "test", "test")
    xas(source, "-i", "-I", incls, "-o", Files.output)
    with open(Files.output, "rb") as f:
        data = f.read()
    if len(data[6:]) != 20:
        error("Include paths", "Incorrect image length")

    # jumpstart disk
    source = os.path.join(Dirs.sources, "ashello.asm")
    xas(source, "-R", "--jumpstart", "-o", Files.output)
    xdm(Disks.asmsrcs, "-e", "ASHELLO-I", "-o", Files.reference)
    with open(Files.output, "rb") as fout, open(Files.reference, "rb") as fref:
        disk = fout.read()
        prog = fref.read()
    if len(disk) != 360 * 256:
        error("Jumpstart", "Incorrect disk size: %d" % len(disk))
    if disk[0:10] != "xas99-JS\xc2\xb9" or disk[56:256] != "\xff" * 200:
        error("Jumpstart", "Invalid sector 0 data")
    plen = ordw(prog[2:4]) - 6
    if disk[512:512 + plen] != prog[6:6 + plen]:
        error("Jumpstart", "Invalid program data")

    # various parameter combinations
    source = os.path.join(Dirs.sources, "asxbank1.asm")
    remove([Files.reference])
    xas(source, "-b", "-o", Files.output, "-L", Files.reference)
    checkExists([Files.reference])

    # cleanup
    os.remove(Files.output)
    os.remove(Files.reference)
    os.remove(Files.error)
예제 #18
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)
예제 #19
0
def runtest():
    """check error messages against native assembler listing"""

    # cross-assembler error messages
    source = os.path.join(Dirs.sources, "aserrs.asm")
    with open(Files.error, "w") as ferr:
        xas(source, "-s", "-o", Files.output, stderr=ferr, rc=1)
    xaserrors = readstderr(Files.error)
    
    # TI assembler error messages
    tierrors = {}
    xdm(Disks.asmsrcs, "-e", "ASERRS-L", "-o", Files.reference)
    with open(Files.reference, "r") as f:
        for line in f:
            err = re.match(r"\*{5}\s+([A-Z ]*) - (\d+)", line)
            if err:
                lino, errmsg = err.group(2), err.group(1)
                tierrors[lino] = errmsg

    # compare
    compare(tierrors, xaserrors)

    # xdt99-specific errors
    source = os.path.join(Dirs.sources, "asxerrs.asm")
    with open(Files.error, "w") as ferr:
        xas(source, "-R", "-o", Files.output, stderr=ferr, rc=1)
    xaserrors = readstderr(Files.error)
    referrors = {}
    with open(source, "r") as f:
        for i, line in enumerate(f):
            m = re.search(r";ERROR(:....)?", line)
            if m:
                if m.group(1):
                    referrors[m.group(1)[1:]] = line
                else:
                    referrors["%04d" % (i + 1)] = line

    compare(referrors, xaserrors)

    # xdt99-specific errors (image generation)
    source = os.path.join(Dirs.sources, "asxerrsb.asm")
    with open(Files.error, "w") as ferr:
        xas(source, "-R", "-b", "-o", Files.output, stderr=ferr, rc=1)
    xaserrors = readstderr(Files.error)
    referrors = {}
    with open(source, "r") as f:
        for i, line in enumerate(f):
            m = re.search(r";ERROR(:....)?", line)
            if m:
                if m.group(1):
                    referrors[m.group(1)[1:]] = line
                else:
                    referrors["%04d" % (i + 1)] = line

    compare(referrors, xaserrors)

    # files not found
    source = os.path.join(Dirs.sources, "ascopyi.asm")
    with open(Files.error, "w") as ferr:
        xas(source, "-o", Files.output, stderr=ferr, rc=1)

    # cleanup
    os.remove(Files.error)
    os.remove(Files.reference)
예제 #20
0
def runtest():
    """check command line interface"""

    # setup
    with open(Disks.volumes, 'wb') as v:
        for i in range(4 * 1600):
            v.write(bytes(2 * 256))  # Disk.bytes_per_sector plus padding
    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', stdout=fout)
        xvm(Disks.volumes, '5', '-i', stderr=fout, rc=1)

    xvm(Disks.volumes, '2', '-r', Files.output)
    check_files_eq('xvm', Files.output, Disks.recsgen, 'P')
    xvm(Disks.volumes, '1', '-r', Files.output)
    check_files_eq('xvm', Files.output, Disks.recsdis, 'P')
    xvm(Disks.volumes, '4', '-r', Files.output)
    check_files_eq('xvm', Files.output, Disks.recsdis, 'P')
    xvm(Disks.volumes, '4', '-r', Files.output, '--keep-size')
    check_files_eq('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)
    check_files_eq('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)
    check_files_eq('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)
예제 #21
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)
        check_files_eq('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)
        check_files_eq('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)
        check_files_eq('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)
        check_files_eq('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)
    check_files_eq('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)
    check_files_eq('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('-I', Files.reference, stdout=f)
    check_file_matches(Files.output,
                       [(0, r'{:10s}'.format(tiname(Files.reference)) +
                         r'\s+4  DIS/VAR 64\s+575 B\s+9 recs\s+[\d:\- ]+M')])
    xdm(Disks.work, '-X', 'sssd', '-t', '-a', rfile)
    xdm(Disks.work, '-e', 'V64V', '-o', Files.output)
    xdm('-F', rfile, '-o', Files.reference)
    check_files_eq('Short TIFiles', Files.output, Files.reference, 'DIS/VAR64')

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

    # check if listings match E/A
    for infile, opts, reffile in [('ashellon.asm', ['-R'], 'ASHELLO-L'),
                                  ('asdirs.asm', [], 'ASDIRS-L'),
                                  ('asorgs.asm', [], 'ASORGS-L'),
                                  ('asopcs.asm', [], 'ASOPCS-L'),
                                  ('asexprs.asm', [], 'ASEXPRS-L'),
                                  ('asbss.asm', [], 'ASBSS-L'),
                                  ('asregs.asm', ['-R'], 'ASREGS-L'),
                                  ('assize1.asm', [], 'ASSIZE1-L'),
                                  ('assize2.asm', [], 'ASSIZE2-L'),
                                  ('assize3.asm', [], 'ASSIZE3-L'),
                                  ('assize4.asm', [], 'ASSIZE4-L'),
                                  ('asextsym.asm', [], 'ASEXTSYM-L'),
                                  ('asimg1.asm', [], 'ASIMG1-L'),
                                  ('asimg2.asm', [], 'ASIMG2-L'),
                                  ('asimg3.asm', [], 'ASIMG3-L'),
                                  ('ascart.asm', ['-R', '-s'], 'ASCART-L')]:
        source = os.path.join(Dirs.sources, infile)
        xas(*[source] + opts + ['-q', '-L', Files.output, '-o', Files.input])
        xdm(Disks.asmsrcs, '-e', reffile, '-o', Files.reference)
        check_list_files_eq(Files.output, Files.reference)

    # check if listing words match actual words
    for infile, opts in [
        ('asdirs.asm', []),  # cannot use programs with many ?ORGs
        ('asopcs.asm', []),
        ('asbss.asm', []),
        ('asregs.asm', ['-R']),
        ('ascart.asm', ['-R', '-s']),
        ('aslist.asm', [])
    ]:
        source = os.path.join(Dirs.sources, infile)
        xas(*[source] + opts +
            ['-b', '-q', '-L', Files.output, '-o', Files.reference])
        check_list_against_binary(Files.output, Files.reference)

    # changing sources
    for infile, opts, reffile in [
        ('ascopy.asm', [], 'ASCOPY-L')
            #('ascopyn.asm', [], 'ASCOPYN-L')  # TI version is not souce-equal to xas99 version
    ]:
        source = os.path.join(Dirs.sources, infile)
        xas(*[source] + opts +
            ['-q', '-L', Files.output, '-o', Files.reference])
        xdm(Disks.asmsrcs, '-e', reffile, '-o', Files.reference)
        check_list_files_eq(Files.output, Files.reference, ignore_lino=True)

    # bytes and padding
    source = os.path.join(Dirs.sources, 'aslist.asm')
    xas(source, '-o', Files.input, '-L', Files.output)
    ref = os.path.join(Dirs.refs, 'aslist.lst')
    check_text_files_eq('listbytes', Files.output, ref)

    # symbols
    source = os.path.join(Dirs.sources, 'ashello.asm')
    xas(source, '-R', '-L', Files.output, '-S', '-q', '-o', Files.input)
    reffile = os.path.join(Dirs.refs, 'ashello.sym')
    check_end_equal(Files.output, reffile)

    # EQUs
    source = os.path.join(Dirs.sources, 'ashello.asm')
    xas(source, '-R', '-E', Files.output, '-q', '-o', Files.input)
    reffile = os.path.join(Dirs.refs, 'ashello.sym')
    check_sym_equ_equiv(Files.output, reffile)

    # auto-generated constants
    source = os.path.join(Dirs.sources, 'asauto.asm')
    reffile = os.path.join(Dirs.refs, 'asauto.lst')
    with open(reffile, 'r') as fref:
        reflines = [line.rstrip() for line in fref.readlines()]
    xas(source, '-R', '-o', Files.error, '-S', '-L', Files.output)
    with open(Files.output, 'r') as fout:
        lines = [line.rstrip() for line in fout.readlines()][-len(reflines):]
    if lines != reflines:
        error('auto', 'auto-const listing mismatch')

    # cleanup
    os.remove(Files.output)
    os.remove(Files.reference)
    os.remove(Files.error)
예제 #23
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)
    check_files_eq('CLI', Files.output, Files.reference, 'DIS/VAR255')

    ref_prog = os.path.join(Dirs.refs, 'prog00255')
    xdm(Disks.work, '-e', 'PROG00255', '-o', Files.output)
    check_files_eq('CLI', Files.output, ref_prog, 'PROGRAM')
    ref_dv = os.path.join(Dirs.refs, 'dv064x010')
    xdm(Disks.work, '-e', 'DV064X010', '-o', Files.output)
    check_files_eq('CLI', Files.output, ref_dv, 'DIS/VAR64')
    ref_df = os.path.join(Dirs.refs, 'df002x001')
    xdm(Disks.work, '-e', 'DF002X001', '-o', Files.output)
    check_files_eq('CLI', Files.output, ref_df, 'DIS/FIX 2')

    with open(Files.output, 'w') as f1:
        xdm(Disks.work, '-p', 'DV064X010', stdout=f1)
    check_files_eq('CLI', Files.output, ref_dv, '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)
    check_files_eq('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', ref_prog, ref_dv, ref_df)
    xdm(Disks.work, '-e', 'PROG00255', '-o', Files.output)
    check_files_eq('CLI', Files.output, ref_prog, 'PROGRAM')
    xdm(Disks.work, '-e', 'DV064X010', '-o', Files.output)
    check_files_eq('CLI', Files.output, ref_dv,
                   'PROGRAM')  # use PROGRAM here to compare!

    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)
    check_files_eq('CLI', Files.output, Files.reference, 'P')
    xdm(Disks.work, '-r', 'OTHERNAME:PROG00255')
    check_files_eq('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)
    check_files_eq('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', ref_prog, 'prog00002')
    xdm(Disks.work, '-e', 'MULTI', '-o', Files.output)
    check_files_eq('CLI', 'prog00001', Files.output, 'P')
    xdm(Disks.work, '-e', 'MULTJ', '-o', Files.output)
    check_files_eq('CLI', ref_prog, Files.output, 'P')
    xdm(Disks.work, '-e', 'MULTK', '-o', Files.output)
    check_files_eq('CLI', 'prog00002', Files.output, 'P')

    xdm('-T', 'prog00001', ref_prog, 'prog00002', '-n',
        'MULTFI')  # -n applies to internal names!
    xdm(Disks.work, '-t', '-a', 'prog00001.tfi', ref_prog + '.tfi',
        'prog00002.tfi')
    xdm(Disks.work, '-e', 'MULTFI', '-o', Files.output)
    check_files_eq('CLI', 'prog00001', Files.output, 'P')
    xdm(Disks.work, '-e', 'MULTFJ', '-o', Files.output)
    check_files_eq('CLI', ref_prog, Files.output, 'P')
    xdm(Disks.work, '-e', 'MULTFK', '-o', Files.output)
    check_files_eq('CLI', 'prog00002', Files.output, 'P')

    xdm('-T', ref_prog, 'prog00002', '-9', '-n', 'MULV9T')
    xdm(Disks.work, '-9', '-a', ref_prog + '.v9t9', 'prog00002.v9t9')
    xdm(Disks.work, '-e', 'MULV9T', '-o', Files.output)
    check_files_eq('CLI', ref_prog, Files.output, 'P')
    xdm(Disks.work, '-e', 'MULV9U', '-o', Files.output)
    check_files_eq('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')
    check_file_size(Disks.work, 360 * 256)
    check_files_eq('CLI', Disks.work, Disks.blank, 'P')
    os.remove(Disks.work)
    xdm(Disks.work, '--initialize', 'SSSD', '-n', 'SSSD')
    check_file_size(Disks.work, 360 * 256)
    check_files_eq('CLI', Disks.work, Disks.blank, 'P')
    xdm(Disks.work, '--initialize', '800', '-n', 'INIT')
    with open(Files.output, 'w') as f:
        xdm(Disks.work, '-i', '-q', stdout=f)
    check_file_matches(Files.output, [(0, '\s2\s+used\s+798\s+free\s')])
    os.remove(Disks.work)
    xdm(Disks.work, '--initialize', 'CF', '-n', 'INIT', '-q')
    with open(Files.output, 'w') as f:
        xdm(Disks.work, '-i', '-q', stdout=f)
    check_file_matches(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)
        check_file_matches(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+40T'), ('99T8D7S', '7S/8D\s+99T'),
                 ('22TDD', '7S/2D\s+22T'), ('DSSD', '2S/1D\s+22T'),
                 ('1T', '2S/1D\s+1T'), ('3D10T9S', '9S/3D\s+10T'),
                 ('SDDS', '2S/1D\s+10T'), ('SS', '1S/1D\s+10T')]:
        xdm(Disks.work, '--set-geometry', g, '-q')
        with open(Files.output, 'w') as fout:
            xdm(Disks.work, '-i', '-q', stdout=fout)
        check_file_matches(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)
            check_files_eq('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+40T'),
        ('--resize', 'DS1D', r'718 free\s+180 KB\s+2S/1D\s+40T'),
        ('--set-geometry', '80T',
         r'718 free\s+180 KB\s+2S/1D\s+80T'),  # geom mismatch
        ('--initialize', '408', r'406 free\s+102 KB\s+2S/1D\s+40T'),
        ('--resize', 'DSSD80T', r'1438 free\s+360 KB\s+2S/1D\s+80T'),
        ('--resize', '2DSS', r'718 free\s+180 KB\s+1S/2D\s+40T'),
        ('-Z', '208', r'206 free\s+52 KB\s+1S/2D\s+40T'),
        ('--set-geometry', 'SD80T', r'206 free\s+52 KB\s+1S/1D\s+80T'),
        ('-X', 'DSSD80T', r'1438 free\s+360 KB\s+2S/1D\s+80T'),
        ('--set-geometry', '20T', r'1438 free\s+360 KB\s+2S/1D\s+20T')
    ]:  # geom mismatch
        xdm(Disks.work, c, g, '-q')
        with open(Files.output, 'w') as fout:
            xdm(Disks.work, '-i', '-q', stdout=fout)
        check_file_matches(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)

    # xdm99 vs real images
    rfile = os.path.join(Dirs.refs, 'ti-text')  # TEXT D/V80
    with open(Files.output, 'w') as fout, open(Files.error, 'w') as ferr:
        xdm(Disks.work, '-X', 'sssd', '-n', 'TI-DISK', stderr=ferr, rc=0)
        xdm(Disks.work,
            '-a',
            rfile,
            '-n',
            'TEXT',
            '-f',
            'dv80',
            stderr=ferr,
            rc=0)
        check_file_len(Files.error, max_lines=0)
        check_disks_eq(Disks.work, Disks.tisssd)
        xdm(Disks.work, '-X', 'dsdd', '-n', 'TI-DISK', stderr=ferr, rc=0)
        xdm(Disks.work,
            '-a',
            rfile,
            '-n',
            'TEXT',
            '-f',
            'dv80',
            stderr=ferr,
            rc=0)
        check_file_len(Files.error, max_lines=0)
        check_disks_eq(Disks.work, Disks.tidsdd)
        xdm(Disks.work, '-Z', 'sssd', stderr=ferr, rc=0)
        check_file_len(Files.error, max_lines=0)
        check_disks_eq(Disks.work, Disks.tisssd)
        xdm(Disks.work, '--set-geometry', 'ssdd', stderr=ferr, rc=0)  # warn
        check_file_len(Files.error, min_lines=1, max_lines=1)
        xdm(Disks.work, '-i', stdout=fout, stderr=ferr, rc=0)  # warn
        check_file_len(Files.error, min_lines=2, max_lines=2)
        xdm(Disks.work, '-Z', 'dsdd', stderr=ferr, rc=0)
        check_file_len(Files.error, max_lines=2)
        check_disks_eq(Disks.work, Disks.tidsdd)
        xdm(Disks.work, '--set-geometry', 'ssdd80t', stderr=ferr, rc=0)
        check_file_len(Files.error, max_lines=2)
        xdm(Disks.work, '-X', 'dssd80t', '-n', 'TI-DSSD80', stderr=ferr, rc=0)
        check_file_len(Files.error, max_lines=2)
        check_disks_eq(Disks.work, Disks.tidssd80)

    # 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)
    check_file_len(Files.output, min_lines=2)
    with open(Files.output, 'w') as f1:
        xdm(Disks.work, '-C', stderr=f1)
    check_file_len(Files.output, max_lines=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)
    check_files_eq('CLI', Files.output, 'prog00255.tfi', 'PROGRAM')
    xdm(Disks.work, '-e', 'DV064X010', '-t', '-o', Files.output)
    check_files_eq('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)
    check_files_eq('CLI', Files.output, 'prog00255.v9t9', 'PROGRAM')
    xdm(Disks.work, '-e', 'DV064X010', '-9', '-o', Files.output)
    check_files_eq('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)
    check_files_eq('CLI', Files.output, 'prog00255.tfi', 'PROGRAM',
                   Masks.TIFile)
    xdm('-T', 'prog00255', '-9', '-o', Files.output)
    check_files_eq('CLI', Files.output, 'prog00255.v9t9', 'PROGRAM',
                   Masks.v9t9)

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

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

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

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

    # TI names
    shutil.copyfile(Disks.recsdis, Disks.work)
    xdm(Disks.work, '-t', '-e', 'F16', 'V16')
    xdm(Disks.work, '-t', '-e', 'F16', 'V16', '--ti-names')
    check_files_eq('TI names', 'F16', 'f16.tfi', 'PROGRAM')
    check_files_eq('TI names', 'V16', 'v16.tfi', 'PROGRAM')
    xdm(Disks.work, '-9', '-e', 'F1')
    xdm(Disks.work, '-9', '-e', 'F1', '--ti-names')
    check_files_eq('TI names', 'F1', 'f1.v9t9', 'PROGRAM')
    xdm(Disks.work, '-e', 'V1', '-o', Files.reference)
    xdm(Disks.work, '-e', 'V1', '--ti-names')
    check_files_eq('TI names', 'V1', Files.reference, 'PROGRAM')

    # conversion between TI/PC names ('.' vs '/')
    file1 = os.path.join(Dirs.refs, 'vardis')
    with open(os.path.join(Dirs.tmp, 'file.y.z'), 'wb') as f:
        f.write(b'\xff' * 100)
    xdm(Disks.work, '-X', 'sssd', '-a', file1, '-n', 'FILE.X')
    xdm(Disks.work, '-a', os.path.join(Dirs.tmp, 'file.y.z'))
    with open(Files.output, 'w') as fout:
        xdm(Disks.work, '-i', stdout=fout, rc=0)
    check_lines_start(Files.output, ('FILE/X', 'FILE/Y'), skip=1)

    xdm(Disks.work, '-r', 'FILE/X:NEW.FILE/X')
    with open(Files.output, 'w') as fout:
        xdm(Disks.work, '-i', stdout=fout, rc=0)
    check_lines_start(Files.output, ('NEW/FILE/X', 'FILE/Y'), skip=1)

    xdm(Disks.work, '-e', '*')
    check_file_exists('new.file.x')
    os.remove('new.file.x')
    check_file_exists('file.y')
    os.remove('file.y')

    xdm(Disks.work, '-e', 'FILE/Y', '-t')
    check_file_exists('file.y.tfi')
    os.remove('file.y.tfi')

    # rename disk (-n)
    xdm(Disks.work, '-X', 'sssd', '-n', 'FIRST.NAME')
    with open(Files.output, 'w') as fout:
        xdm(Disks.work, '-i', stdout=fout, rc=0)
    check_lines_start(Files.output, ('FIRST/NAME', ))

    xdm(Disks.work, '-n', 'SECND.NAME')
    with open(Files.output, 'w') as fout:
        xdm(Disks.work, '-i', stdout=fout, rc=0)
    check_lines_start(Files.output, ('SECND/NAME', ))

    # output directory -o <dir>
    ref1 = os.path.join(Dirs.refs, 'glob1')
    ref2 = os.path.join(Dirs.refs, 'glob12')
    xdm(Disks.work, '-X', 'sssd', '-a', ref1, ref2)
    xdm(Disks.work, '-e', 'GLOB*', '-o', Dirs.tmp)
    check_file_exists(os.path.join(Dirs.tmp, 'glob1'))
    os.remove(os.path.join(Dirs.tmp, 'glob1'))
    check_file_exists(os.path.join(Dirs.tmp, 'glob12'))
    os.remove(os.path.join(Dirs.tmp, 'glob12'))

    xdm(Disks.work, '-X', 'sssd', '-a', ref1, ref2)
    with open(Files.error, 'w') as ferr:
        xdm(Disks.work, '-e', 'GLOB*', '-o', Files.output, stderr=ferr, rc=1)

    # 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)
    check_files_eq('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)
    check_files_eq('stdin/stdout', Files.output, ref, 'P')

    # usage errors
    with open(Files.error, 'w') as ferr:
        xdm('-a', Files.output, stderr=ferr, rc=2)
        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', 'df127x001', 'df127x010', 'df127x020p',
            'prog00001.tfi', 'prog00002.tfi', 'prog00255.tfi', 'dv064x010.tfi',
            'prog00002.v9t9', 'prog00255.v9t9', 'dv064x010.v9t9', 'F16', 'V16',
            'f16.tfi', 'v16.tfi', 'F1', 'f1.v9t9', 'V1'
    ]:
        os.remove(fn)
예제 #24
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(create_text_file(count, length, False, False))
        files.append(create_text_file(count, length, True, False))
    for count, length in [(20, 127), (15, 254), (15, 255)]:
        files.append(create_text_file(count, length, False, True))
        files.append(create_text_file(count, length, True, True))
    for size in [1, 2, 254, 255, 511, 513, 2560]:
        files.append(create_binary_file(size))

    bigFiles = []
    for count, length in [(200, 127), (100, 254), (100, 255)]:
        bigFiles.append(create_text_file(count, length, False, True))
        bigFiles.append(create_text_file(count, length, True, True))
    for size in [25600]:
        bigFiles.append(create_binary_file(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)
        check_files_eq("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)
        check_files_eq("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)
        check_files_eq("Write records", Files.output, Files.reference, fmt)
        xdm("-T", Files.reference, "-o", Files.output, "-f", fmt, "-n", name)
        check_files_eq("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)
    check_files_eq("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)
        check_text_files_eq("TIFiles", Files.output, path)

    # 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)
        check_files_eq("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)
        check_trunc(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)
예제 #25
0
def runtest():
    """check xdt99 extensions"""

    # xdt99 extensions
    source = os.path.join(Dirs.sources, "asxext.asm")
    xas(source, "-R", "-o", Files.output)
    xdm(Disks.asmsrcs, "-e", "ASXEXT0-O", "-o", Files.reference)
    check_obj_code_eq(Files.output, Files.reference)
    xas(source, "-R", "-D", "sym2", "-o", Files.output)
    xdm(Disks.asmsrcs, "-e", "ASXEXT1-O", "-o", Files.reference)
    check_obj_code_eq(Files.output, Files.reference)
    xas(source, "-R", "-D", "sym2=2", "sym3=2", "-o", Files.output)
    xdm(Disks.asmsrcs, "-e", "ASXEXT2-O", "-o", Files.reference)
    check_obj_code_eq(Files.output, Files.reference)
    xas(source, "-R", "-D", "sym2=2,sym3=2", "-o", Files.output)
    xdm(Disks.asmsrcs, "-e", "ASXEXT2-O", "-o", Files.reference)
    check_obj_code_eq(Files.output, Files.reference)

    # some CLI options
    source = os.path.join(Dirs.sources, "ashello.asm")
    xas(source, "--embed", "-R", "-o", Files.output)

    # misc new features
    for infile, reffile in [("asxnew.asm", "ASXNEW-O"),
                            ("asmacs.asm", "ASMACS-O")]:
        source = os.path.join(Dirs.sources, infile)
        xas(source, "-o", Files.output)
        xdm(Disks.asmsrcs, "-e", reffile, "-o", Files.reference)
        check_obj_code_eq(Files.output, Files.reference)

    # SAVE directive
    source = os.path.join(Dirs.sources, "asxsave.asm")
    xas(source, "-b", "--base", "0xb000", "-o", Files.output)
    save1s = [Files.output + "_" + ext for ext in ["b000", "b020", "b030"]]
    check_concat_eq(save1s, os.path.join(Dirs.refs, "save1"))
    check_no_files([Files.output + "_b080"])

    # bank switching: obsolete AORG addr, bank
    source = os.path.join(Dirs.sources, "asxbank1.asm")
    xas(source, "-b", "-w", "-o", Files.output)
    save2s = [
        Files.output + "_" + ext for ext in
        ["0000", "6000_b0", "6000_b1", "6100_b0", "6200_b1", "6200_b2"]
    ]
    check_concat_eq(save2s, os.path.join(Dirs.refs, "save2"))
    check_no_files([Files.output + "_0000_b0", Files.output + "_6100_b1"])

    source = os.path.join(Dirs.sources, "asxbank2.asm")
    xas(source, "-b", "-w", "-o", Files.output)
    save3s = [
        Files.output + "_" + ext
        for ext in ["c000_b0", "c000_b1", "d000_b0", "e000_b1"]
    ]
    check_concat_eq(save3s, os.path.join(Dirs.refs, "save3"))
    check_no_files([
        Files.output + "_" + ext
        for ext in ["c000", "d000", "d000_b1", "e000", "e000_b0"]
    ])

    source = os.path.join(Dirs.sources, "asxsegm.asm")
    xas(source, "-b", "-w", "-o", Files.output)
    check_file_sizes([
        (Files.output + "_" + ext, size)
        for ext, size in [("0000", 20), ("b000_b1", 14), ("b010_b1",
                                                          2), ("b012_b2", 6)]
    ])

    # BANK directive
    source = os.path.join(Dirs.sources, "asdbank.asm")
    xas(source, "-b", "-R", "-o", Files.output)
    save4s = [Files.output + ext for ext in ["_6000_b0", "_6000_b1"]]
    check_concat_eq(save4s, os.path.join(Dirs.refs, "asdbank"))

    # cross-bank access
    source = os.path.join(Dirs.sources, "asxbank.asm")
    with open(Files.error, "w") as ferr:
        xas(source, "-b", "-R", "-o", Files.output, stderr=ferr,
            rc=0)  # no error

    source = os.path.join(Dirs.sources, "asnxbank.asm")
    with open(Files.error, "w") as ferr:
        xas(source, "-b", "-R", "-o", Files.output, stderr=ferr,
            rc=1)  # with errors

    # sections shared across banks
    source = os.path.join(Dirs.sources, "asshbank.asm")
    with open(Files.error, "w") as ferr:
        xas(source, "-b", "-R", "-o", Files.output, stderr=ferr,
            rc=1)  # with errors
    act_errors = read_stderr(Files.error)
    exp_errors = get_source_markers(source, r";ERROR(:....)?")
    check_errors(exp_errors, act_errors)

    source = os.path.join(Dirs.sources, "asshbankx.asm")
    with open(Files.error, "w") as ferr:
        xas(source, "-b", "-R", "-o", Files.output, stderr=ferr,
            rc=0)  # no error

    # data output (-t)
    source = os.path.join(Dirs.sources, "ashexdat.asm")
    xas(source, "-t", "a2", "-R", "-o", Files.output)
    xas(source, "-b", "-R", "-o", Files.reference)
    check_numeric_eq(Files.output, Files.reference)

    source = os.path.join(Dirs.sources, "asxtext.asm")
    xas(source, "-t", "a2", "-o", Files.output + "1")
    xas(source, "-t", "c4", "-o", Files.output + "2")
    xas(source, "-t", "b", "-o", Files.output + "3")
    xas(source, "-t", "a4", "-o", Files.output + "4")
    xas(source, "-t", "c", "-o", Files.output + "5")
    save5s = [Files.output + ext for ext in ["1", "2", "3", "4", "5"]]
    check_concat_eq(save5s, os.path.join(Dirs.refs, "asxtext"))

    # auto-generated constants (b#, w#)
    source = os.path.join(Dirs.sources, "asautogen.asm")
    xas(source, "-b", "-R", "-o", Files.output)
    source = os.path.join(Dirs.sources, "asautoman.asm")
    xas(source, "-b", "-R", "-o", Files.reference)
    check_binary_files_eq("autogen", Files.output, Files.reference)

    source = os.path.join(Dirs.sources, "asautorel.asm")
    xas(source, "-b", "-R", "-o",
        Files.output)  # address is now >00xx instead of >a0xx
    with open(Files.reference, "rb+") as f:
        data = f.read()
        data = data.replace("\xa0", "\x00")
        f.seek(0)
        f.write(data)
    check_binary_files_eq("autogen", Files.output, Files.reference)

    # register LSB access (l#)
    source = os.path.join(Dirs.sources, "asxrlb.asm")
    with open(Files.error, "w") as ferr:
        xas(source, "-b", "-R", "-o", Files.output, stderr=ferr, rc=0)
    ref = os.path.join(Dirs.sources, "asxrlbn.asm")
    xas(ref, "-b", "-R", "-o", Files.reference)
    check_binary_files_eq("rlb", Files.output, Files.reference)

    act_errors = read_stderr(Files.error, include_warnings=True)
    exp_errors = get_source_markers(source, tag=r";WARN")
    check_errors(exp_errors, act_errors)

    # size modifier (s#)
    source = os.path.join(Dirs.sources, "assmod.asm")
    with open(Files.error, "w") as ferr:
        xas(source, "-b", "-R", "-o", Files.output, stderr=ferr, rc=0)
    ref = os.path.join(Dirs.sources, "assmodn.asm")
    xas(ref, "-b", "-R", "-o", Files.reference)
    check_binary_files_eq("s#", Files.output, Files.reference)
    with open(Files.error, "r") as ferr:
        if "TEXT4" not in ferr.read():
            error("s#", "Missing warning about TEXT4")

    source = os.path.join(Dirs.sources, "assmode.asm")
    with open(Files.error, "w") as ferr:
        xas(source, "-b", "-R", "-o", Files.output, stderr=ferr, rc=1)
    act_errors = read_stderr(Files.error)
    exp_errors = get_source_markers(source, tag=r";ERROR")
    check_errors(exp_errors, act_errors)

    # floating-point numbers
    source = os.path.join(Dirs.sources, "asfloat.asm")
    xas(source, "-b", "-o", Files.output)
    ref = os.path.join(Dirs.refs, "asfloat.ref")
    check_binary_files_eq("float", Files.output, ref)

    # cleanup
    os.remove(Files.output)
    os.remove(Files.reference)
    for fn in set(save1s + save2s + save3s + save4s + save5s):
        os.remove(fn)
예제 #26
0
def runtest():
    """check linked files object code against non-linked equivalent file object code
       NOTE: Programs commented out contain multiple xORGs, so the relocation of segments
             will lead to different object codes.
    """

    for inp_file, opts, ref_file, compr_file, relaxed_check in [
        ('asdirs.asm', [], 'ASDIRS-O', 'ASDIRS-C', False),
        ('asorg2.asm', [], 'ASORG2-O', None, False),
        ('asorg3.asm', [], 'ASORG3-O', None, False),
        ('asopcs.asm', [], 'ASOPCS-O', 'ASOPCS-C', False),
        ('asbss.asm', [], 'ASBSS-O', 'ASBSS-C', False),
        ('asbss2.asm', [], 'ASBSS2-O', None, False),
        ('asbss3.asm', [], 'ASBSS3-O', None, False),
        ('asbss4.asm', [], 'ASBSS4-O', None, False),
        ('ashellon.asm', ['-R'], 'ASHELLO-O', 'ASHELLO-C', False),
        ('ascopy.asm', [], 'ASCOPY-O', None, False),
        ('assize1.asm', [], 'ASSIZE1-O', 'ASSIZE1-C', False),
        ('asextsym.asm', [], 'ASEXTSYM-O', 'ASEXTSYM-C', False),
            #('asimg1.asm', [], 'ASIMG1-O', 'ASIMG1-C', False),
        ('asimg2.asm', [], 'ASIMG2-O', None, False),
            #('asimg3.asm', [], 'ASIMG3-OX', None, False),
        ('asreloc.asm', [], 'ASRELOC-O', None, False),
        ('asxorg.asm', [], 'ASXORG-O', None,
         True),  # TODO: slightly different structure for linked code
        ('ascart.asm', ['-R'], 'ASCART-O', 'ASCART-C', False),
    ]:
        source = os.path.join(Dirs.sources, inp_file)
        xas(*[source] + opts + ['-q', '-o', Files.input])
        xas('-l', Files.input, '-o', Files.output)
        xdm(Disks.asmsrcs, '-e', ref_file, '-o', Files.reference)
        tagfilter = b'BC' if relaxed_check else None  # compare only B and C tags
        check_obj_code_eq(Files.output, Files.reference,
                          tagfilter=tagfilter)  # default

        xas('-ll', Files.input, '-o', Files.output)
        check_obj_code_eq(Files.output, Files.reference,
                          tagfilter=tagfilter)  # resolve conflicts

        if compr_file:
            # compressed object code
            xas(*[source] + opts + ['-C', '-q', '-o', Files.input])
            xas('-l', Files.input, '-C', '-o', Files.output)
            xdm(Disks.asmsrcs, '-e', compr_file, '-o', Files.reference)
            check_obj_code_eq(Files.output, Files.reference, compressed=True)

    # parsing of object code
    source = os.path.join(Dirs.sources, 'asbssorg.asm')
    xas(source, '-o', Files.reference)
    xas('-l', Files.reference, '-o', Files.output)
    check_obj_code_eq(Files.output, Files.reference)

    # link multiple files
    library = os.path.join(Dirs.sources, 'aslink0b.asm')
    xas(library, '-q', '-o', Files.input)
    source = os.path.join(Dirs.sources, 'aslink0a.asm')
    xas(source, '-l', Files.input, '-q', '-o', Files.output)
    ref = os.path.join(Dirs.sources, 'aslink0.asm')
    xas(ref, '-o', Files.reference)
    check_obj_code_eq(Files.output, Files.reference)

    xas(source, '-ll', Files.input, '-q', '-o', Files.output)
    check_obj_code_eq(Files.output, Files.reference)

    xas(source, library)  # name should be source.obj
    objname = 'aslink0a.obj'
    if not os.path.isfile(objname):
        error('multi-files', 'Bad output file for multiple inputs')

    library = os.path.join(Dirs.sources, 'aslink1b.asm')
    xas(library, '-R', '-D', 'x=1', '-q', '-o', Files.input)
    source = os.path.join(Dirs.sources, 'aslink1a.asm')
    xas(source, '-l', Files.input, '-R', '-D', 'x=1', '-q', '-o', Files.output)
    ref = os.path.join(Dirs.sources, 'aslink1.asm')
    xas(ref, '-R', '-D', 'x=1', '-q', '-o', Files.reference)
    check_obj_code_eq(Files.output, Files.reference)

    # link 3 files
    for x in ('a', 'b', 'c'):
        xas(os.path.join(Dirs.sources, 'aslink2' + x + '.asm'), '-q', '-o',
            Files.input + x)
    xas('-l', Files.input + 'a', Files.input + 'b', Files.input + 'c', '-q',
        '-b', '-o', Files.output)
    xas(os.path.join(Dirs.sources, 'aslink2.asm'), '-q', '-b', '-o',
        Files.reference)
    check_binary_files_eq('link', Files.output, Files.reference)

    xas('-ll', Files.input + 'a', Files.input + 'b', Files.input + 'c', '-q',
        '-b', '-o', Files.output)
    xas(os.path.join(Dirs.sources, 'aslink2.asm'), '-q', '-b', '-o',
        Files.reference)
    check_binary_files_eq('link', Files.output, Files.reference)

    # ditto with multiple source files
    sources = [
        os.path.join(Dirs.sources, f'aslink1{x}.asm') for x in ('a', 'b')
    ]
    xas(*sources, '-R', '-D', 'x=1', '-q', '-o', Files.output)
    ref = os.path.join(Dirs.sources, 'aslink1.asm')
    xas(ref, '-R', '-D', 'x=1', '-q', '-o', Files.reference)
    check_obj_code_eq(Files.output, Files.reference)

    sources = [
        os.path.join(Dirs.sources, f'aslink2{x}.asm') for x in ('a', 'b', 'c')
    ]
    xas(*sources, '-b', '-q', '-o', Files.output)
    ref = os.path.join(Dirs.sources, 'aslink2.asm')
    xas(ref, '-b', '-q', '-o', Files.reference)
    check_binary_files_eq('multi-source', Files.output, Files.reference)

    # link and multi-files with conflict
    source1 = os.path.join(Dirs.sources, 'aslink3a.asm')
    source2 = os.path.join(Dirs.sources, 'aslink3b.asm')
    xas(source1, source2, '-b', '-o', Files.output)
    ref = os.path.join(Dirs.sources, 'aslink3.asm')
    xas(ref, '-b', '-o', Files.reference)
    check_binary_files_eq('link', Files.output, Files.reference)

    xas(source2, '-o', Files.input)
    xas(source1, '-l', Files.input, '-b', '-o', Files.output)
    check_binary_files_eq('multi-source', Files.output, Files.reference)

    # link file with auto-generated constants
    source = os.path.join(Dirs.sources, 'asauto.asm')
    xas(source, '-R', '-o', Files.input)
    xas('-R', '-l', Files.input, '-b', '-o', Files.output)
    xas(source, '-R', '-b', '-o', Files.reference)
    check_binary_files_eq('link', Files.output, Files.reference)

    # link w/o name
    xas('-l', Files.input, '-R')
    if not os.path.isfile('a.obj'):
        error('link', 'Objcode code file with default name not found')

    # link and rebase
    source = os.path.join(Dirs.sources, 'aslinkr.asm')
    xas(source, '-q', '-o', Files.input)
    xas('-l', Files.input, '-a', '>2000', '-b', '-q', '-o', Files.output)
    xas(source, '-b', '-a', '>2000', '-o', Files.reference)
    check_binary_files_eq('link/base', Files.output, Files.reference)

    xas('-ll', Files.input, '-a', '>2000', '-b', '-q', '-o', Files.output)
    check_binary_files_eq('link/base', Files.output, Files.reference)

    # link and rorg/aorg
    lib = os.path.join(Dirs.sources, 'aslinkob.asm')
    xas(lib, '-o', Files.input)
    source = os.path.join(Dirs.sources, 'aslinkoa.asm')
    xas(source, '-a', '>4000', '-l', Files.input, '-o', Files.output)
    ref = os.path.join(Dirs.sources, 'aslinko.asm')
    xas(ref, '-o', Files.reference)
    check_obj_code_eq(Files.output, Files.reference)

    xas(source, lib, '-a', '>4000', '-o', Files.output)
    check_obj_code_eq(Files.output, Files.reference)

    xas(source, '-a', '>4000', '-ll', Files.input, '-o', Files.output)
    ref = os.path.join(Dirs.sources, 'aslinkor.asm')
    xas(ref, '-o', Files.reference)
    check_obj_code_eq(Files.output, Files.reference)

    # link and xorg
    lib = os.path.join(Dirs.sources, 'aslinkxb.asm')
    xas(lib, '-q', '-o', Files.input)
    source = os.path.join(Dirs.sources, 'aslinkxa.asm')
    xas(source, '-l', Files.input, '-q', '-o', Files.output)
    ref = os.path.join(Dirs.sources, 'aslinkx.asm')
    xas(ref, '-q', '-o', Files.reference)
    check_obj_code_eq(Files.output, Files.reference)

    xas(source, '-ll', Files.input, '-q', '-o', Files.output)
    check_obj_code_eq(Files.output, Files.reference)

    xas(source, '-l', Files.input, '-a', '>e000', '-b', '-q', '-o',
        Files.output)
    ref = os.path.join(Dirs.sources, 'aslinkxe.asm')
    xas(ref, '-b', '-q', '-o', Files.reference)
    check_binary_files_eq('link/xorg', Files.output, Files.reference)

    xas(source, '-ll', Files.input, '-a', '>e000', '-b', '-q', '-o',
        Files.output)
    ref = os.path.join(Dirs.sources, 'aslinkxer.asm')
    xas(ref, '-b', '-q', '-o', Files.reference)
    check_binary_files_eq('link/xorg', Files.output, Files.reference)

    # link and -D
    lib = os.path.join(Dirs.sources, 'aslink4b.asm')
    xas(lib, '-q', '-o', Files.input)
    source = os.path.join(Dirs.sources, 'aslink4a.asm')
    xas(source, '-l', Files.input, '-D', 'x=69', '-o',
        Files.output)  # no need for -ll case
    ref = os.path.join(Dirs.sources, 'aslink4.asm')
    xas(ref, '-D', 'x=69', '-q', '-o', Files.reference)
    check_obj_code_eq(Files.output, Files.reference)

    # in-unit conflict resolution
    # NOTE: For one program unit, internal conflicts may still be resolved
    #       against the absolute segments, yielding a non-zero offset for that
    #       single unit.  Inter-reloc conflicts cannot be resolved.
    source = os.path.join(Dirs.sources, 'asorgx.asm')
    xas(source, '-o', Files.input)
    xas('-ll', Files.input, '-b', '-o', Files.output)
    ref = os.path.join(Dirs.sources, 'asorgxn.asm')
    xas(ref, '-b', '-o', Files.reference)
    check_binary_files_eq('in-file conflict', Files.output, Files.reference)

    # symbol conflicts
    source1 = os.path.join(Dirs.sources, 'aslinks1a.asm')
    source2 = os.path.join(Dirs.sources, 'aslinks1b.asm')
    with open(Files.error, 'w') as ferr:
        xas(source1, source2, '-o', Files.output, rc=1, stderr=ferr)

    xas(source2, '-o', Files.input)
    with open(Files.error, 'w') as ferr:
        xas(source1, '-l', Files.input, '-o', Files.output, rc=1, stderr=ferr)

    source1 = os.path.join(Dirs.sources, 'aslinks2a.asm')
    xas(source1, source2, '-o', Files.output, rc=0)
    source2 = os.path.join(Dirs.sources, 'aslinks2b.asm')
    xas(source1, source2, '-o', Files.output, rc=0)

    xas(source2, '-o', Files.input)
    xas(source1, '-l', Files.input, '-o', Files.output, rc=0)

    # entry conflict
    source1 = os.path.join(Dirs.sources, 'aslinkea.asm')
    source2 = os.path.join(Dirs.sources, 'aslinkeb.asm')
    with open(Files.error, 'w') as ferr:
        xas(source1, source2, '-o', Files.output, rc=1, stderr=ferr)

    xas(source2, '-o', Files.input)
    with open(Files.error, 'w') as ferr:
        xas(source1, '-l', Files.input, '-o', Files.output, rc=1, stderr=ferr)

    # practical example
    source = os.path.join(Dirs.sources, 'asstdlib.asm')
    libs = ['vmbw.a99', 'vsbr.a99', 'vwbt.a99']
    with open(Files.error, 'w') as ferr:
        xas(source, *libs, '-R', '-o', Files.output, rc=0, stderr=ferr)
    check_file_empty(Files.error)

    # cleanup
    os.remove(Files.input)
    os.remove(Files.input + 'a')
    os.remove(Files.input + 'b')
    os.remove(Files.input + 'c')
    os.remove(Files.output)
    os.remove(Files.reference)
    os.remove(objname)
    os.remove('a.obj')
예제 #27
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)
예제 #28
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)
        check_records_by_checksum(Files.output, reclen, True)
        xdm(Disks.work, '-e', 'IV' + str(reclen), '-o', Files.output)
        check_records_by_checksum(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)
        check_files_eq('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)
        check_files_eq('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)
        check_files_eq('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)
        check_files_eq('Write INT', Files.output, ref, 'P')

    # cleanup
    os.remove(Files.output)
    os.remove(Files.reference)
    os.remove(Disks.work)
예제 #29
0
def runtest():
    """check command line interface"""

    # input and output files
    source = os.path.join(Dirs.sources, "ashello.asm")
    with open(Files.output, "wb") as f:
        xas(source, "-R", "-o", "-", stdout=f)
    xdm(Disks.asmsrcs, "-e", "ASHELLO-O", "-o", Files.reference)
    checkObjCodeEq(Files.output, Files.reference)

    with open(Files.output, "wb") as f:
        xas(source, "-R", "-i", "-o", "-", stdout=f)
    xdm(Disks.asmsrcs, "-e", "ASHELLO-I", "-o", Files.reference)
    checkImageFilesEq(Files.output, Files.reference)

    with open(Files.output, "w") as f:
        xas(source, "-R", "-o", Files.output, "-L", "-", stdout=f)
    xdm(Disks.asmsrcs, "-e", "ASHELLO-L", "-o", Files.reference)
    checkListFilesEq(Files.output, Files.reference)

    source = os.path.join(Dirs.sources, "nonexisting")
    with open(Files.error, "w") as ferr:
        xas(source, "-i", "-R", "-o", Files.output, stderr=ferr, rc=1)
    with open(Files.error, "r") as ferr:
        errs = ferr.readlines()
    if len(errs) != 1 or errs[0][:10] != "File error":
        error("File errors", "Incorrect file error message")

    # include path
    source = os.path.join(Dirs.sources, "ascopyi.asm")
    incls = os.path.join(Dirs.sources, "test") + "," + \
        os.path.join(Dirs.sources, "test", "test")
    xas(source, "-i", "-I", incls, "-o", Files.output)
    with open(Files.output, "rb") as f:
        data = f.read()
    if len(data[6:]) != 20:
        error("Include paths", "Incorrect image length")

    # jumpstart disk
    source = os.path.join(Dirs.sources, "ashello.asm")
    xas(source, "-R", "--jumpstart", "-o", Files.output)
    xdm(Disks.asmsrcs, "-e", "ASHELLO-I", "-o", Files.reference)
    with open(Files.output, "rb") as fout, open(Files.reference, "rb") as fref:
        disk = fout.read()
        prog = fref.read()
    if len(disk) != 360 * 256:
        error("Jumpstart", "Incorrect disk size: %d" % len(disk))
    if disk[0:10] != "xas99-JS\xc2\xb9" or disk[56:256] != "\xff" * 200:
        error("Jumpstart", "Invalid sector 0 data")
    plen = ordw(prog[2:4]) - 6
    if disk[512:512 + plen] != prog[6:6 + plen]:
        error("Jumpstart", "Invalid program data")

    # various parameter combinations
    source = os.path.join(Dirs.sources, "asxbank1.asm")
    remove([Files.reference])
    xas(source, "-b", "-o", Files.output, "-L", Files.reference)
    checkExists([Files.reference])

    # cleanup
    os.remove(Files.output)
    os.remove(Files.reference)
    os.remove(Files.error)
예제 #30
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)
예제 #31
0
def runtest():
    """check xdt99 extensions"""

    # xdt99 extensions
    source = os.path.join(Dirs.sources, "asxext.asm")
    xas(source, "-R", "-o", Files.output)
    xdm(Disks.asmsrcs, "-e", "ASXEXT0-O", "-o", Files.reference)
    checkObjCodeEq(Files.output, Files.reference)
    xas(source, "-R", "-D", "sym2", "-o", Files.output)
    xdm(Disks.asmsrcs, "-e", "ASXEXT1-O", "-o", Files.reference)
    checkObjCodeEq(Files.output, Files.reference)
    xas(source, "-R", "-D", "sym2=2", "sym3=2", "-o", Files.output)
    xdm(Disks.asmsrcs, "-e", "ASXEXT2-O", "-o", Files.reference)
    checkObjCodeEq(Files.output, Files.reference)

    # some CLI options
    source = os.path.join(Dirs.sources, "ashello.asm")
    xas(source, "--embed", "-R", "-o", Files.output)

    # misc new features
    for infile, reffile in [
            ("asxnew.asm", "ASXNEW-O"),
            ("asmacs.asm", "ASMACS-O")
            ]:
        source = os.path.join(Dirs.sources, infile)
        xas(source, "-o", Files.output)
        xdm(Disks.asmsrcs, "-e", reffile, "-o", Files.reference)
        checkObjCodeEq(Files.output, Files.reference)

    # SAVE directive
    source = os.path.join(Dirs.sources, "asxsave.asm")
    xas(source, "-b", "--base", "0xb000", "-o", Files.output)
    save1s = [Files.output + "_" + ext
              for ext in ["b000", "b020", "b030"]]
    checkConcatEq(save1s, os.path.join(Dirs.refs, "save1"))
    checkNoFiles([Files.output + "_b080"])

    # bank switching
    source = os.path.join(Dirs.sources, "asxbank1.asm")
    xas(source, "-b", "-o", Files.output)
    save2s = [Files.output + "_" + ext
              for ext in ["0000", "6000_b0", "6000_b1", "6100_b0",
                          "6200_b1", "6200_b2"]]
    checkConcatEq(save2s, os.path.join(Dirs.refs, "save2"))
    checkNoFiles([Files.output + "_" + ext
                  for ext in ["0000_b0", "6000", "6100_b1", "6200_b0"]])

    source = os.path.join(Dirs.sources, "asxbank2.asm")
    xas(source, "-b", "-o", Files.output)
    save3s = [Files.output + "_" + ext
              for ext in ["c000", "c000_b0", "c000_b1", "d000_b0", "e000_b1"]]
    checkConcatEq(save3s, os.path.join(Dirs.refs, "save3"))
    checkNoFiles([Files.output + "_" + ext
                  for ext in ["d000", "d000_b1", "e000", "e000_b0"]])

    source = os.path.join(Dirs.sources, "asxsegm.asm")
    xas(source, "-b", "-o", Files.output)
    checkFileSizes([(Files.output + "_" + ext, size)
                    for ext, size in [("0000", 20), ("b000_b1", 14),
                                      ("b010_b1", 2), ("b012_b2", 6)]])

    # cleanup
    os.remove(Files.output)
    os.remove(Files.reference)
    for fn in save1s + save2s + save3s:
        os.remove(fn)
예제 #32
0
def runtest():
    """check error messages against native assembler listing"""

    # cross-assembler error messages
    source = os.path.join(Dirs.sources, 'aserrs.asm')
    with open(Files.error, 'w') as ferr:
        xas(source, '-s', '-o', Files.output, stderr=ferr, rc=1)
    xas_errors = read_stderr(Files.error)

    # TI assembler error messages
    ti_errors = []
    xdm(Disks.asmsrcs, '-e', 'ASERRS-L', '-o', Files.reference)
    with open(Files.reference, 'r') as f:
        for line in f:
            err = re.match(r'\*{5}\s+([A-Z ]*) - (\d+)', line)
            if err:
                lino = err.group(2)
                ti_errors.append(lino)

    # compare
    check_errors(ti_errors, xas_errors)

    # xdt99-specific errors
    source = os.path.join(Dirs.sources, 'asxerrs.asm')
    with open(Files.error, 'w') as ferr:
        xas(source, '-R', '-o', Files.output, stderr=ferr, rc=1)
    xas_errors = read_stderr(Files.error)
    ref_errors = get_source_markers(source, r';ERROR(:....)?')
    check_errors(ref_errors, xas_errors)

    # xdt99-specific errors (image generation)
    source = os.path.join(Dirs.sources, 'asxerrsb.asm')
    with open(Files.error, 'w') as ferr:
        xas(source, '-R', '-b', '-o', Files.output, stderr=ferr, rc=1)
    xas_errors = read_stderr(Files.error)
    ref_errors = get_source_markers(source, tag=r';ERROR(:....)?')
    check_errors(ref_errors, xas_errors)

    # open .if-.endif or .defm-.endm
    source = os.path.join(Dirs.sources, 'asopenif.asm')
    with open(Files.error, 'w') as ferr:
        xas(source, '-o', Files.output, stderr=ferr, rc=1)
    with open(Files.error, 'r') as fin:
        msgs = ' '.join(fin.readlines())
    if 'Missing .endif' not in msgs:
        error('open', 'Missing error for open .if/.endif')

    source = os.path.join(Dirs.sources, 'asopenmac.asm')
    with open(Files.error, 'w') as ferr:
        xas(source, '-o', Files.output, stderr=ferr, rc=1)
    with open(Files.error, 'r') as fin:
        msgs = ' '.join(fin.readlines())
    if 'Missing .endm' not in msgs:
        error('open', 'Missing error for open .defm/.endm')

    # files not found
    source = os.path.join(Dirs.sources, 'ascopyi.asm')
    with open(Files.error, 'w') as ferr:
        xas(source, '-o', Files.output, stderr=ferr, rc=1)

    # warnings
    source = os.path.join(Dirs.sources, 'aswarn.asm')
    with open(Files.error, 'w') as ferr:
        xas(source, '-b', '-R', '-o', Files.output, stderr=ferr,
            rc=0)  # no error
    act_errors = read_stderr(Files.error, include_warnings=True)
    exp_errors = get_source_markers(source, tag=r';WARN')
    check_errors(exp_errors, act_errors)

    source = os.path.join(Dirs.sources, 'asuusym.asm')  # undefined symbols
    with open(Files.error, 'w') as ferr:
        xas(source, '-R', '-o', Files.output, stderr=ferr, rc=0)  # no error
    with open(Files.error, 'r') as fin:
        output = fin.read()
    if output.strip()[-18:] != 'U1, U2, U3, U4, U5':
        error('stdout', 'Bad listing of unreferenced symbols')

    with open(Files.error, 'w') as ferr:
        xas(source, '-R', '-q', '-o', Files.output, stderr=ferr,
            rc=0)  # no error
    with open(Files.error, 'r') as fin:
        output = fin.read()
    if output.strip():
        error('stdout', 'Unwanted  listing of unreferenced symbols')

    # STDOUT
    source = os.path.join(Dirs.sources, 'asstdout.asm')
    with open(Files.error, 'w') as fout:
        xas(source, '-b', '-R', '-o', Files.output, stdout=fout,
            rc=0)  # no error
    with open(Files.error, 'r') as fin:
        output = fin.read()
    if output.strip() != 'hello 42 world!':
        error('stdout', 'Invalid STDOUT output: ' + output)

    # cleanup
    os.remove(Files.error)
    os.remove(Files.reference)
예제 #33
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)
예제 #34
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)
예제 #35
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)
예제 #36
0
def runtest():
    """check cross-generated output against native reference files"""

    # object code
    for inp_file, opts, ref_file, compr_file in [
        ('asdirs.asm', [], 'ASDIRS-O', 'ASDIRS-C'),
        ('asorgs.asm', [], 'ASORGS-O', 'ASORGS-C'),
        ('asopcs.asm', [], 'ASOPCS-O', 'ASOPCS-C'),
        ('asexprs.asm', [], 'ASEXPRS-O', None),
        ('asbss.asm', [], 'ASBSS-O', 'ASBSS-C'),
        ('asregs.asm', ['-R'], 'ASREGS-O', 'ASREGS-C'),
        ('ashellon.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),
        ('asextsym.asm', [], 'ASEXTSYM-O', None),
        ('asdorg.asm', [], 'ASDORG-O', None),
        ('asrorg.asm', [], 'ASRORG-O', None),
        ('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, inp_file)
        xdm(Disks.asmsrcs, '-e', ref_file, '-o', Files.reference)
        xas(*[source] + opts + ['-q', '-o', Files.output])
        check_obj_code_eq(Files.output, Files.reference)
        xas(*[source] + opts + ['--strict', '-q', '-o', Files.output])
        check_obj_code_eq(Files.output, Files.reference)
        if compr_file:
            # compressed object code
            xas(*[source] + opts + ['-C', '-q', '-o', Files.output])
            xdm(Disks.asmsrcs, '-e', compr_file, '-o', Files.reference)
            check_obj_code_eq(Files.output, Files.reference, compressed=True)

    # image files
    for inp_file, ref_file in [('asimg1.asm', 'ASIMG1-I'),
                               ('asimg2.asm', 'ASIMG2-I'),
                               ('asimg3.asm', 'ASIMG3-I')]:
        source = os.path.join(Dirs.sources, inp_file)
        xas(source, '-i', '-o', Files.output)
        xdm(Disks.asmsrcs, '-e', ref_file, '-o', Files.reference)
        check_image_files_eq(Files.output, Files.reference)

    for inp_file, 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, inp_file)
        xas(source, '-R', '-i', '-q', '-o', Files.output)
        gendata = []
        refdata = []
        for i, ref_file in enumerate(reffiles):
            xdm(Disks.asmimgs, '-e', ref_file, '-o', Files.reference)
            with open(Files.outputff[i],
                      'rb') as fgen, open(Files.reference, 'rb') as fref:
                gendata.append(fgen.read())
                refdata.append(fref.read())
        check_image_set_eq(gendata, refdata)

    # JMP instruction
    source = os.path.join(Dirs.sources, 'asjmp.asm')
    with open(Files.error, 'w') as ferr:
        xas(source, '-o', Files.output, stderr=ferr, rc=1)
    xaserrors = read_stderr(Files.error)
    referrors = get_source_markers(source, r';ERROR(:....)?')
    check_errors(referrors, xaserrors)

    # xas99-defined symbols
    source = os.path.join(Dirs.sources, 'asxassym.asm')
    xas(source, '-b', '-o', Files.output)
    with open(Files.output, 'rb') as f:
        data = f.read()
    for i in range(0, len(data), 2):
        if data[i:i + 2] == b'\x00\x00':
            error('symbols', 'Undefined xas99 symbol')

    # DORG special cases
    source = os.path.join(Dirs.sources, 'asdorg.asm')
    xas(source, '-a', '>2000', '-o', Files.output)
    ref = os.path.join(Dirs.sources, 'asdorg-ti.asm')
    xas(ref, '-a', '>2000', '-o', Files.reference)
    check_obj_code_eq(Files.output, Files.reference)

    # cleanup
    for i in range(4):
        os.remove(Files.outputff[i])
    os.remove(Files.reference)
예제 #37
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)
예제 #38
0
def runtest():
    """check xdt99 extensions"""

    # xdt99 extensions
    source = os.path.join(Dirs.sources, "asxext.asm")
    xas(source, "-R", "-o", Files.output)
    xdm(Disks.asmsrcs, "-e", "ASXEXT0-O", "-o", Files.reference)
    checkObjCodeEq(Files.output, Files.reference)
    xas(source, "-R", "-D", "sym2", "-o", Files.output)
    xdm(Disks.asmsrcs, "-e", "ASXEXT1-O", "-o", Files.reference)
    checkObjCodeEq(Files.output, Files.reference)
    xas(source, "-R", "-D", "sym2=2", "sym3=2", "-o", Files.output)
    xdm(Disks.asmsrcs, "-e", "ASXEXT2-O", "-o", Files.reference)
    checkObjCodeEq(Files.output, Files.reference)
    xas(source, "-R", "-D", "sym2=2,sym3=2", "-o", Files.output)
    xdm(Disks.asmsrcs, "-e", "ASXEXT2-O", "-o", Files.reference)
    checkObjCodeEq(Files.output, Files.reference)

    # some CLI options
    source = os.path.join(Dirs.sources, "ashello.asm")
    xas(source, "--embed", "-R", "-o", Files.output)

    # misc new features
    for infile, reffile in [("asxnew.asm", "ASXNEW-O"),
                            ("asmacs.asm", "ASMACS-O")]:
        source = os.path.join(Dirs.sources, infile)
        xas(source, "-o", Files.output)
        xdm(Disks.asmsrcs, "-e", reffile, "-o", Files.reference)
        checkObjCodeEq(Files.output, Files.reference)

    # SAVE directive
    source = os.path.join(Dirs.sources, "asxsave.asm")
    xas(source, "-b", "--base", "0xb000", "-o", Files.output)
    save1s = [Files.output + "_" + ext for ext in ["b000", "b020", "b030"]]
    checkConcatEq(save1s, os.path.join(Dirs.refs, "save1"))
    checkNoFiles([Files.output + "_b080"])

    # bank switching
    source = os.path.join(Dirs.sources, "asxbank1.asm")
    xas(source, "-b", "-o", Files.output)
    save2s = [
        Files.output + "_" + ext for ext in
        ["0000", "6000_b0", "6000_b1", "6100_b0", "6200_b1", "6200_b2"]
    ]
    checkConcatEq(save2s, os.path.join(Dirs.refs, "save2"))
    checkNoFiles([
        Files.output + "_" + ext
        for ext in ["0000_b0", "6000", "6100_b1", "6200_b0"]
    ])

    source = os.path.join(Dirs.sources, "asxbank2.asm")
    xas(source, "-b", "-o", Files.output)
    save3s = [
        Files.output + "_" + ext
        for ext in ["c000", "c000_b0", "c000_b1", "d000_b0", "e000_b1"]
    ]
    checkConcatEq(save3s, os.path.join(Dirs.refs, "save3"))
    checkNoFiles([
        Files.output + "_" + ext
        for ext in ["d000", "d000_b1", "e000", "e000_b0"]
    ])

    source = os.path.join(Dirs.sources, "asxsegm.asm")
    xas(source, "-b", "-o", Files.output)
    checkFileSizes([
        (Files.output + "_" + ext, size)
        for ext, size in [("0000", 20), ("b000_b1", 14), ("b010_b1",
                                                          2), ("b012_b2", 6)]
    ])

    # cleanup
    os.remove(Files.output)
    os.remove(Files.reference)
    for fn in save1s + save2s + save3s:
        os.remove(fn)
예제 #39
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)
        check_records_by_checksum(Files.output)
    for reclen in [16, 126, 127, 128, 254, 255]:
        xdm(Disks.work, "-e", "V" + str(reclen), "-o", Files.output)
        check_records_by_checksum(Files.output)

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

    # read special records
    xdm(Disks.work, "-e", "F10R", "-o", Files.output)
    check_files_eq("VAR Records", Files.output,
                 os.path.join(Dirs.refs, "f10r.txt"), "DIS/FIX10")
    xdm(Disks.work, "-e", "V10R", "-o", Files.output)
    check_files_eq("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)
        check_files_eq("VAR Records", Files.output, Files.reference, fmt)

    # cleanup
    os.remove(Files.output)
    os.remove(Files.reference)
    os.remove(Disks.work)
예제 #40
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)
        check_listing_eq(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)
        check_listing_eq(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', '-o', Files.output)
        check_binary_files_eq('Tokenization', Files.output, Files.reference)

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

    # check using randomized listings
    for i in range(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)
        check_listing_eq(Files.output, Files.reference)

        # compare generated xbas99 basic program with TI BASIC reference
        xbas(Files.reference, '-c', '-j', ',2', '-o',
             Files.output)  # some linos missing in listing
        check_binary_files_eq('Tokenization', Files.output, Files.input)

    # 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)
    check_binary_files_eq('Long Format', Files.output, Files.reference)

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

    # join
    source = os.path.join(Dirs.basic, 'basjoin.bas')
    xbas(source, '-c', '-j', '5,10', '-o', Files.input)
    xbas(Files.input, '-d', '-o', Files.output)
    check_line_numbers(Files.output, [100, 110, 120, 125])

    # cleanup
    os.remove(Files.input)
    os.remove(Files.output)
    os.remove(Files.reference)
예제 #41
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)
예제 #42
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)