Example #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)
Example #2
0
def runtest():
    """check cross-generated output against native reference files"""

    # input and output files
    source = os.path.join(Dirs.gplsources, "gacart.gpl")
    with open(Files.output, "wb") as f:
        xga(source, "-o", "-", stdout=f)
    xga(source, "-o", Files.reference)
    check_files_eq("stdout", Files.output, Files.reference, "P")

    with open(Files.output, "wb") as f:
        xga(source, "-i", "-G", ">6000", "-A", ">0030", "-o", "-", stdout=f)
    xga(source, "-i", "-G", ">6000", "-A", ">0030", "-o", Files.reference)
    check_files_eq("stdout", Files.output, Files.reference, "P")

    with open(Files.output, "w") as f:
        xga(source, "-o", Files.input, "-L", "-", stdout=f)
    xga(source, "-o", Files.input, "-L", Files.reference)
    check_text_eq(Files.output, Files.reference)

    source = os.path.join(Dirs.gplsources, "nonexisting")
    with open(Files.error, "w") as ferr:
        xga(source, "-o", Files.output, stderr=ferr, rc=1)
    with open(Files.error, "r") as ferr:
        errs = ferr.readlines()
    if len(errs) != 1 or errs[0].strip() != "Error: File not found":
        error("File error", "Incorrect file error message")

    # text -t
    source = os.path.join(Dirs.gplsources, "gacart.gpl")
    xga(source, "-o", Files.reference)
    xga(source, "-t", "c4r", "-o", Files.output)
    check_bin_text_equal_c(Files.output, Files.reference)

    xga(source, "-t", "b4", "-o", Files.output)
    check_bin_text_equal_basic(Files.output, Files.reference)

    # list and symbols -L
    source = os.path.join(Dirs.gplsources, "gahello.gpl")
    xga(source, "-o", Files.error, "-L", Files.input)
    xga(source, "-o", Files.reference)
    with open(Files.input, "r") as flist, open(Files.error, "w") as fout:
        listfile = [
            line[16:] for line in flist.readlines() if line[0:4] != "****"
        ][1:]
        fout.writelines(listfile)
    xga(Files.error, "-o", Files.output)
    check_binary_files_eq("list", Files.output, Files.reference)  # checks code
    check_list_addr_data(Files.input, Files.reference,
                         0x0000)  # checks addr and data

    # cleanup
    os.remove(Files.input)
    os.remove(Files.output)
    os.remove(Files.reference)
    os.remove(Files.error)
Example #3
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)
Example #4
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)
Example #5
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)
Example #6
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)
Example #7
0
def runtest():
    """check cross-generated output against native reference files"""

    # run disassembler
    for srcfile, dopts, aopts in [
            ("gaops.gpl", ["-a", "0", "-r", "6", "17a"], []),
            ("gainst.gpl", ["-a", "0", "-r", "6", "a2", "a3", "aa", "ab", "ac", "b2", "b4"], []),
            ("gabranch.gpl", ["-a", "0", "-f", "5"], []),
            ("gamove.gpl", ["-a", "0", "-f", "6"], []),
            ("gafmt.gpl", ["-a", "0", "-f", "5", "-y", "rag"], []),
            ("gacopy.gpl", ["-a", ">2000", "-r", "2000"], []),
            ("gaexts.gpl", ["-a", "0", "-r", "0x1e"], []),
            ("gapass.gpl", ["-a", "0x6030", "-r", "6030"], [])
            ]:
        source = os.path.join(Dirs.gplsources, srcfile)
        xga(*[source] + aopts + ["-o", Files.reference])
        xdg(*[Files.reference] + dopts + ["-p", "-o", Files.input])
        xga(*[Files.input] + aopts + ["-o", Files.output])
        check_files_eq(srcfile, Files.output, Files.reference, "PROGRAM")
        check_bytes(Files.input, source)

    # top-down disassembler
    for srcfile, dopts, aopts in [
            ("gaops.gpl", ["-a", "0", "-f", "6"], []),
            ("gainst.gpl", ["-a", "0", "-f", "6"], []),
            ("gabranch.gpl", ["-a", "0", "-f", "5"], []),
            ("gamove.gpl", ["-a", "0", "-f", "6"], []),
            ("gafmt.gpl", ["-a", "0", "-f", "5", "-y", "rag"], []),
            ("gadirs.gpl", ["-a", "0", "-f", "0"], []),
            ("gacopy.gpl", ["-a", ">2000", "-f", ">2000"], []),
            ("gaexts.gpl", ["-a", "0", "-f", "0x1e"], []),
            ("gapass.gpl", ["-a", "0x6030", "-f", ">6030"], [])
            ]:
        source = os.path.join(Dirs.gplsources, srcfile)
        xga(*[source] + aopts + ["-o", Files.reference])
        xdg(*[Files.reference] + dopts + ["-p", "-o", Files.input])
        xga(*[Files.input] + aopts + ["-o", Files.output])
        check_files_eq(srcfile, Files.output, Files.reference, "PROGRAM")
        if count_bytes(Files.output) > 0:
            error("BYTE", "Too many BYTE directives in result")

    # disassembler run
    for srcfile in ["dgruns.gpl"]:
        source = os.path.join(Dirs.gplsources, srcfile)
        xga(*[source] + ["-o", Files.reference])
        xdg(*[Files.reference] + ["-a", "0", "-r", "0x0", "-p", "-o", Files.input])
        xga(*[Files.input] + ["-o", Files.output])
        check_files_eq(srcfile, Files.output, Files.reference, "PROGRAM")
        check_bytes(Files.input, source)

    # disassemble blob
    binary = os.path.join(Dirs.refs, "blobg.bin")
    #TODO: universal character escape \x..
    #xdg(binary, "-a", "0", "-f", "start", "-p", "-o", Files.input)
    #xga(Files.input, "-o", Files.output)
    #check_files_eq("blobg", Files.output, binary, "PROGRAM")
    #xdg(binary, "-a", "0", "-r", "start", "-p", "-o", Files.input)
    #xga(Files.input, "-o", Files.output)
    #check_files_eq("blobg-run", Files.output, binary, "PROGRAM")

    # disassemble random
    randrange = [n for n in xrange(256) if n != 0x08 and n != 0xfb]
    for r in xrange(16):
        random.seed(r)
        binary = "".join([chr(random.choice(randrange)) for i in xrange(2048)])
        with open(Files.reference, "wb") as fref:
            fref.write(binary)
        xdg(Files.reference, "-a", "1000", "-f", "1000", "-p", "-o", Files.input)
        xga(Files.input, "-o", Files.output)
        check_files_eq("random" + str(r), Files.reference, Files.output, "PROGRAM")

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

    # disassembler: run
    for srcfile, aopts, addr, start in [
            #("asopcs.asm", ["-R"], "0000", "0000"]), only for -d
            #("asexprs.asm", [], "0000", "0154"),  too many segments
        ("ashello.asm", ["-R", "--base", "0xa000"], "a000", "a016"),
        ("asregs.asm", ["-R"], "0000", "0000"),
        ("ascart.asm", ["-R"], "0000", "000c"),
        ("darun.asm", ["-R"], "0000", "0002")
    ]:
        source = os.path.join(Dirs.sources, srcfile)
        xas(*[source, "-b"] + aopts + ["-w", "-o", Files.reference])
        xda(Files.reference, "-a", addr, "-r", start, "-p", "-o", Files.input)
        xas(*[Files.input, "-b", "-R", "-o", Files.output])
        check_files_eq(srcfile, Files.output, Files.reference, "PROGRAM")

    # disassembler: top-down
    for srcfile, aopts, addr, start in [("asopcs.asm", ["-R"], "0000", "0000"),
                                        ("asexprs.asm", [], "0000", "0154"),
                                        ("asregs.asm", ["-R"], "0000", "0000"),
                                        ("ascart.asm", ["-R"], "0000", "000c"),
                                        ("darun.asm", ["-R"], "0000", "0002")]:
        source = os.path.join(Dirs.sources, srcfile)
        xas(*[source, "-b"] + aopts + ["-w", "-o", Files.reference])
        xda(Files.reference, "-a", addr, "-f", start, "-p", "-o", Files.input)
        xas(*[Files.input, "-b", "-R", "-w", "-o", Files.output])
        check_files_eq(srcfile, Files.output, Files.reference, "PROGRAM")

    # running disassembler
    source = os.path.join(Dirs.sources, "darun.asm")
    xas(source, "-b", "-R", "-w", "-o", Files.reference)
    xda(Files.reference, "-a", "0", "-r", "2", "-p", "-o", Files.output)
    check_eq(check_data(Files.output), check_data(source), "run")

    source = os.path.join(Dirs.sources, "daexec.asm")
    xas(source, "-b", "-R", "-w", "-o", Files.reference)
    xda(Files.reference, "-a", "1000", "-r", "103c", "1008", "-p", "-o",
        Files.output)
    check_eq(check_data(Files.output), check_data(source), "run")

    # disassemble cart BINs
    for binfile, start in (("blobm.bin", "6012"), ("blobh.bin", "start")):
        binary = os.path.join(Dirs.refs, binfile)
        xda(binary, "-a", "6000", "-r", start, "-p", "-o", Files.input)
        xas(Files.input, "-b", "-R", "-w", "-o", Files.output)
        check_files_eq(binary, Files.output, binary, "PROGRAM")

        xda(binary, "-a", "6000", "-f", start, "-p", "-o", Files.input)
        xas(Files.input, "-b", "-R", "-w", "-o", Files.output)
        check_files_eq(binary, Files.output, binary, "PROGRAM")

    # disassemble random
    for r in xrange(16):
        random.seed(r)
        binary = "".join([chr(random.randrange(256)) for i in xrange(2048)])
        with open(Files.reference, "wb") as fref:
            fref.write(binary)
        xda(Files.reference, "-a", "1000", "-f", "1000", "-p", "-o",
            Files.input)
        xas(Files.input, "-b", "-R", "-w", "-o", Files.output)
        check_files_eq("random" + str(r), Files.reference, Files.output,
                       "PROGRAM")

    # Cleanup
    os.remove(Files.input)
    for f in glob.glob(Files.output + "*"):
        os.remove(f)
    for f in glob.glob(Files.reference + "*"):
        os.remove(f)
Example #9
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)
Example #10
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)
        if os.name != "nt":
            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", "-j", "3", "-o", Files.output)
        check_files_eq("Tokenization", Files.output, Files.reference, "P")

        # 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_files_eq("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)
        check_listing_eq(Files.output, Files.reference)

        # compare generated xbas99 basic program with TI BASIC reference
        xbas(Files.reference, "-c", "-j", "3", "-o", Files.output)
        check_files_eq("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)
    check_files_eq("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)
    check_files_eq("Protection",
                   Files.output,
                   Files.reference,
                   "P",
                   mask=[(0, 2)])

    # cleanup
    os.remove(Files.input)
    os.remove(Files.output)
    os.remove(Files.reference)
Example #11
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)
        check_files_eq('HFE', Files.input, Files.reference, 'PROGRAM')
        xhm('-F', Files.input, '-o', Files.output)
        check_files_eq('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)
    check_file_contains(Files.output, 'HFEDISK.*1S/1D.*40')
    check_file_contains(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')
    check_files_eq('HFE', Files.output, ref, 'DV')
    with open(Files.output, 'wb') as fout:
        xhm(Disks.work, '-p', 'TESTFILE', stdout=fout)
    check_files_eq('HFE', Files.output, ref, 'DV')

    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')
    check_files_eq('HFE', Files.output, ref, 'DV')

    # image resize
    with open(Files.output, 'w') as fout:
        xhm('--hfe-info', Disks.work, stdout=fout)
    check_file_contains(Files.output, 'Tracks: 40')
    check_file_contains(Files.output, 'Sides: 1')
    check_file_contains(Files.output, 'Encoding: 2')  # SD
    xhm(Disks.work, '-Z', 'dsdd')
    with open(Files.output, 'w') as fout:
        xhm('--hfe-info', Disks.work, stdout=fout)
    check_file_contains(Files.output, 'Tracks: 40')
    check_file_contains(Files.output, 'Sides: 2')
    check_file_contains(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)
    check_file_contains(Files.output, r'2S/1D\s+80')
    check_file_contains(Files.output, r'WALDO.*PROGRAM')
    with open(Files.output, 'w') as fout:
        xhm('--hfe-info', Disks.work, stdout=fout)
    check_file_contains(Files.output, 'Tracks: 80')
    check_file_contains(Files.output, 'Sides: 2')
    check_file_contains(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)
    check_file_contains(Files.output, r'Tracks: 40')
    check_file_contains(Files.output, r'Sides: 2')  # DS
    check_file_contains(Files.output, r'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)
Example #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)
    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)
Example #13
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", "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, inp_file)
        xdm(Disks.asmsrcs, "-e", ref_file, "-o", Files.reference)
        xas(*[source] + opts + ["-o", Files.output])
        check_obj_code_eq(Files.output, Files.reference)
        xas(*[source] + opts + ["--strict", "-o", Files.output])
        check_obj_code_eq(Files.output, Files.reference)
        if compr_file:
            # compressed object code
            xas(*[source] + opts + ["-C", "-o", Files.output])
            xdm(Disks.asmsrcs, "-e", compr_file, "-o", Files.reference)
            check_obj_code_eq(Files.output, Files.reference)

    # image files
    for inp_file, opts, ref_file 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, inp_file)
        xas(*[source] + opts + ["-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", "-w", "-o", Files.output)
        for i, ref_file in enumerate(reffiles):
            xdm(Disks.asmimgs, "-e", ref_file, "-o", Files.reference)
            check_files_eq("Image file",
                           Files.outputff[i],
                           Files.reference,
                           fmt="P")

    # 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)

    # cleanup
    for i in xrange(4):
        os.remove(Files.outputff[i])
    os.remove(Files.reference)
Example #14
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)
Example #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.bytes_per_sector
    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)
    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)

    # cleanup
    os.remove(Files.output)
    os.remove(Files.reference)
    os.remove(Files.error)
    os.remove(Disks.work)
    os.remove(Disks.volumes)
Example #16
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")

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

    with open(Files.output, "w") as f1:
        xdm(Disks.work, "-p", "DV064X010", stdout=f1)
    check_files_eq("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)
    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", "prog00255", "dv064x010", "df002x001")
    xdm(Disks.work, "-e", "PROG00255", "-o", Files.output)
    check_files_eq("CLI", Files.output, "prog00255", "PROGRAM")
    xdm(Disks.work, "-e", "DV064X010", "-o", Files.output)
    check_files_eq("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)
    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", "prog00255", "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", "prog00255", Files.output, "P")
    xdm(Disks.work, "-e", "MULTK", "-o", Files.output)
    check_files_eq("CLI", "prog00002", Files.output, "P")

    xdm("-T", "prog00001", "prog00255", "prog00002", "-n",
        "MULTFI")  # -n applies to internal names!
    xdm(Disks.work, "-t", "-a", "prog00001.tfi", "prog00255.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", "prog00255", Files.output, "P")
    xdm(Disks.work, "-e", "MULTFK", "-o", Files.output)
    check_files_eq("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)
    check_files_eq("CLI", "prog00255", 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", 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")
    with open(Files.output, "w") as f:
        xdm(Disks.work, "-i", 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)
        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)
        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("\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=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", "F16", "V16",
            "f16.tfi", "v16.tfi", "F1", "f1.v9t9", "V1"
    ]:
        os.remove(fn)
Example #17
0
def runtest():
    '''check cross-generated output against native reference files'''

    # input and output files
    source = os.path.join(Dirs.gplsources, 'gacart.gpl')
    with open(Files.output, 'wb') as f:
        xga(source, '-o', '-', stdout=f)
    xga(source, '-o', Files.reference)
    check_files_eq('stdout', Files.output, Files.reference, 'P')

    xga(source, '-o', Dirs.tmp)
    if not os.path.isfile(os.path.join(Dirs.tmp, 'gacart.gbc')):
        error('output', '-o <dir> failed')

    with open(Files.output, 'wb') as f:
        xga(source, '-G', '>6000', '-A', '>0030', '-o', '-', stdout=f)
    xga(source, '-G', '>6000', '-A', '>0030', '-o', Files.reference)
    check_files_eq('stdout', Files.output, Files.reference, 'P')

    with open(Files.output, 'w') as f:
        xga(source, '-o', Files.input, '-L', '-', stdout=f)
    xga(source, '-o', Files.input, '-L', Files.reference)
    check_text_eq(Files.output, Files.reference)

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

    # text -t
    source = os.path.join(Dirs.gplsources, 'gacart.gpl')
    xga(source, '-o', Files.reference)
    xga(source, '-t', 'c4r', '-o', Files.output)
    check_bin_text_equal_c(Files.output, Files.reference)

    xga(source, '-t', 'b4', '-o', Files.output)
    check_bin_text_equal_basic(Files.output, Files.reference)

    # listing and symbols -L
    source = os.path.join(Dirs.gplsources, 'gahello.gpl')
    xga(source, '-o', Files.error, '-L', Files.input)
    xga(source, '-o', Files.reference)
    with open(Files.input, 'r') as flist, open(Files.error, 'w') as fout:
        listfile = [
            line[14:] for line in flist.readlines() if line[0:4].isdigit()
        ]
        fout.writelines(listfile)
    xga(Files.error, '-o', Files.output)
    check_binary_files_eq('listing', Files.output,
                          Files.reference)  # checks code
    check_list_addr_data(Files.input, Files.reference,
                         0x0000)  # checks addr and data

    # cleanup
    os.remove(Files.input)
    os.remove(Files.reference)
    os.remove(Files.error)
    os.remove(Files.output)
Example #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(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)
Example #19
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)
Example #20
0
def runtest():
    """check cross-generated output against native reference files"""

    # run disassembler
    for srcfile, dopts, aopts in [
        ('gaops.gpl', ['-a', '0', '-r', '6', '17a'], []),
        ('gainst.gpl',
         ['-a', '0', '-r', '6', 'a2', 'a3', 'aa', 'ab', 'ac', 'b2', 'b4'], []),
        ('gabranch.gpl', ['-a', '0', '-f', '5'], []),
        ('gamove.gpl', ['-a', '0', '-f', '6'], []),
        ('gafmt.gpl', ['-a', '0', '-f', '5', '-y', 'rag'], []),
        ('gacopy.gpl', ['-a', '>2000', '-r', '2000'], []),
        ('gaexts.gpl', ['-a', '0', '-r', '0x1e'], []),
        ('gapass.gpl', ['-a', '0x6030', '-r', '6030'], [])
    ]:
        source = os.path.join(Dirs.gplsources, srcfile)
        xga(*[source] + aopts + ['-o', Files.reference])
        xdg(*[Files.reference] + dopts + ['-p', '-o', Files.input])
        xga(*[Files.input] + aopts + ['-o', Files.output])
        check_files_eq(srcfile, Files.output, Files.reference, 'PROGRAM')
        check_bytes(Files.input, source)

    # top-down disassembler
    for srcfile, dopts, aopts in [
        ('gaops.gpl', ['-a', '0', '-f', '6'], []),
        ('gainst.gpl', ['-a', '0', '-f', '6'], []),
        ('gabranch.gpl', ['-a', '0', '-f', '5'], []),
        ('gamove.gpl', ['-a', '0', '-f', '6'], []),
        ('gafmt.gpl', ['-a', '0', '-f', '5', '-y', 'rag'], []),
        ('gadirs.gpl', ['-a', '0', '-f', '0'], []),
        ('gacopy.gpl', ['-a', '>2000', '-f', '>2000'], []),
        ('gaexts.gpl', ['-a', '0', '-f', '0x1e'], []),
        ('gapass.gpl', ['-a', '0x6030', '-f', '>6030'], [])
    ]:
        source = os.path.join(Dirs.gplsources, srcfile)
        xga(*[source] + aopts + ['-o', Files.reference])
        xdg(*[Files.reference] + dopts + ['-p', '-o', Files.input])
        xga(*[Files.input] + aopts + ['-o', Files.output])
        check_files_eq(srcfile, Files.output, Files.reference, 'PROGRAM')
        xdg(*[Files.reference] + dopts +
            ['-o', Files.output
             ])  # -p would introduce BYTEs where not disassembled
        if count_bytes(Files.output) > 0:
            error('BYTE', 'Unwanted BYTE directives in result')

    # disassembler run
    for srcfile in ['dgruns.gpl']:
        source = os.path.join(Dirs.gplsources, srcfile)
        xga(*[source] + ['-o', Files.reference])
        xdg(*[Files.reference] +
            ['-a', '0', '-r', '0x0', '-p', '-o', Files.input])
        xga(*[Files.input] + ['-o', Files.output])
        check_files_eq(srcfile, Files.output, Files.reference, 'PROGRAM')
        check_bytes(Files.input, source)

    # disassemble blob
    binary = os.path.join(Dirs.refs, 'blobg.bin')
    #TODO: universal character escape \x..
    #xdg(binary, '-a', '0', '-f', 'start', '-p', '-o', Files.input)
    #xga(Files.input, '-o', Files.output)
    #check_files_eq('blobg', Files.output, binary, 'PROGRAM')
    #xdg(binary, '-a', '0', '-r', 'start', '-p', '-o', Files.input)
    #xga(Files.input, '-o', Files.output)
    #check_files_eq('blobg-run', Files.output, binary, 'PROGRAM')

    # disassemble random
    randrange = [n for n in range(256) if n != 0x08 and n != 0xfb]
    for r in range(16):
        random.seed(r)
        binary = bytes([random.choice(randrange) for i in range(2048)])
        with open(Files.reference, 'wb') as fref:
            fref.write(binary)
        xdg(Files.reference, '-a', '1000', '-f', '1000', '-p', '-o',
            Files.input)
        xga(Files.input, '-o', Files.output)
        check_files_eq('random' + str(r), Files.reference, Files.output,
                       'PROGRAM')

    # cleanup
    os.remove(Files.input)
    os.remove(Files.output)
    os.remove(Files.reference)
Example #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(Disks.work, "-I", Files.reference, stdout=f)
    check_file_matches(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)
    check_files_eq("Short TIFiles", Files.output, Files.reference, "DIS/VAR64")

    # cleanup
    os.remove(Files.output)
    os.remove(Disks.work)
Example #22
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)
        check_files_eq("HFE", Files.input, Files.reference, "PROGRAM")
        xhm("-F", Files.input, "-o", Files.output)
        check_files_eq("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)
    check_file_contains(Files.output, "HFEDISK.*1S/1D.*40")
    check_file_contains(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")
    check_files_eq("HFE", Files.output, ref, "DV")
    with open(Files.output, "wb") as fout:
        xhm(Disks.work, "-p", "TESTFILE", stdout=fout)
    check_files_eq("HFE", Files.output, ref, "DV")

    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")
    check_files_eq("HFE", Files.output, ref, "DV")

    # image resize
    with open(Files.output, "w") as fout:
        xhm("--hfe-info", Disks.work, stdout=fout)
    check_file_contains(Files.output, "Tracks: 40")
    check_file_contains(Files.output, "Sides: 1")
    check_file_contains(Files.output, "Encoding: 2")  # SD
    xhm(Disks.work, "-Z", "dsdd")
    with open(Files.output, "w") as fout:
        xhm("--hfe-info", Disks.work, stdout=fout)
    check_file_contains(Files.output, "Tracks: 40")
    check_file_contains(Files.output, "Sides: 2")
    check_file_contains(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)
    check_file_contains(Files.output, r"2S/1D\s+80")
    check_file_contains(Files.output, r"WALDO.*PROGRAM")
    with open(Files.output, "w") as fout:
        xhm("--hfe-info", Disks.work, stdout=fout)
    check_file_contains(Files.output, "Tracks: 80")
    check_file_contains(Files.output, "Sides: 2")
    check_file_contains(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)
    check_file_contains(Files.output, r"Tracks: 40")
    check_file_contains(Files.output, r"Sides: 2")  # DS
    check_file_contains(Files.output, r"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)