コード例 #1
0
def runtest():
    """run regression tests"""

    # check for errors
    source = os.path.join(Dirs.gplsources, 'gaerrs.gpl')
    with open(Files.error, 'w') as ferr:
        xga(source, '-o', Files.output, stderr=ferr, rc=1)
    act_errors = read_stderr(Files.error, include_warnings=False)
    exp_errors = get_source_markers(source, tag=r';ERROR')
    check_errors(exp_errors, act_errors)

    # error messages in pass 0 and 1
    for s in ['gaerrs0.gpl', 'gaerrs1.gpl']:
        source = os.path.join(Dirs.gplsources, s)
        with open(Files.error, 'w') as ferr:
            xga(source, '-o', Files.output, stderr=ferr, rc=1)
        act_errors = read_stderr(Files.error, include_warnings=False)
        exp_errors = get_source_markers(source, tag=r'\* ERROR')
        check_errors(exp_errors, act_errors)

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

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

    # warnings
    source = os.path.join(Dirs.gplsources, 'gawarn.gpl')
    with open(Files.error, 'w') as ferr:
        xga(source, '-o', Files.output, stderr=ferr, rc=0)
    act_errors = read_stderr(Files.error, include_warnings=True)
    exp_errors = get_source_markers(source, tag=r';WARN')
    check_errors(exp_errors, act_errors)

    # cleanup
    os.remove(Files.output)
    os.remove(Files.error)
コード例 #2
0
def runtest():
    """run regression tests"""

    # check for errors
    source = os.path.join(Dirs.gplsources, "gaerrs.gpl")
    with open(Files.error, "w") as ferr:
        xga(source, "-o", Files.output, stderr=ferr, rc=1)
    act_errors = read_stderr(Files.error, include_warnings=False)
    exp_errors = get_source_markers(source, tag=r";ERROR")
    check_errors(exp_errors, act_errors)

    # error messages in pass 0 and 1
    for s in ["gaerrs0.gpl", "gaerrs1.gpl"]:
        source = os.path.join(Dirs.gplsources, s)
        with open(Files.error, "w") as ferr:
            xga(source, "-o", Files.output, stderr=ferr, rc=1)
        act_errors = read_stderr(Files.error, include_warnings=False)
        exp_errors = get_source_markers(source, tag=r"\* ERROR")
        check_errors(exp_errors, act_errors)

    # open .if-.endif or .defm-.endm
    source = os.path.join(Dirs.gplsources, "gaopenif.gpl")
    with open(Files.error, "w") as ferr:
        xga(source, "-o", Files.output, stderr=ferr, rc=1)
    with open(Files.error, "r") as fin:
        msgs = " ".join(fin.readlines())
    if "Missing .endif" not in msgs:
        error("open", "Missing error for open .if/.endif")

    source = os.path.join(Dirs.gplsources, "gaopenmac.gpl")
    with open(Files.error, "w") as ferr:
        xga(source, "-o", Files.output, stderr=ferr, rc=1)
    with open(Files.error, "r") as fin:
        msgs = " ".join(fin.readlines())
    if "Missing .endm" not in msgs:
        error("open", "Missing error for open .defm/.endm")

    # warnings
    source = os.path.join(Dirs.gplsources, "gawarn.gpl")
    with open(Files.error, "w") as ferr:
        xga(source, "-o", Files.output, stderr=ferr, rc=0)
    act_errors = read_stderr(Files.error, include_warnings=True)
    exp_errors = get_source_markers(source, tag=r";WARN")
    check_errors(exp_errors, act_errors)

    # cleanup
    os.remove(Files.output)
    os.remove(Files.error)
コード例 #3
0
def runtest():
    """check error messages against native assembler listing"""

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

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

    # compare
    check_errors(ti_errors, xas_errors)

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

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

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

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

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

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

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

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

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

    # cleanup
    os.remove(Files.error)
    os.remove(Files.reference)
コード例 #4
0
ファイル: as-checkext.py プロジェクト: deicherse/xdt99
def runtest():
    """check xdt99 extensions"""

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    # cleanup
    os.remove(Files.output)
    os.remove(Files.reference)
    for fn in set(save1s + save2s + save3s + save4s + save5s):
        os.remove(fn)
コード例 #5
0
ファイル: as-checkobj.py プロジェクト: peberlein/xdt99
def runtest():
    """check cross-generated output against native reference files"""

    # object code
    for inp_file, opts, ref_file, compr_file in [
        ('asdirs.asm', [], 'ASDIRS-O', 'ASDIRS-C'),
        ('asorgs.asm', [], 'ASORGS-O', 'ASORGS-C'),
        ('asopcs.asm', [], 'ASOPCS-O', 'ASOPCS-C'),
        ('asexprs.asm', [], 'ASEXPRS-O', None),
        ('asbss.asm', [], 'ASBSS-O', 'ASBSS-C'),
        ('asregs.asm', ['-R'], 'ASREGS-O', 'ASREGS-C'),
        ('ashellon.asm', ['-R'], 'ASHELLO-O', 'ASHELLO-C'),
        ('ascopy.asm', [], 'ASCOPY-O', None),
        ('ascopyn.asm', [], 'ASCOPYN-O', None),
        ('assize1.asm', [], 'ASSIZE1-O', 'ASSIZE1-C'),
        ('assize2.asm', [], 'ASSIZE2-O', None),
        ('assize3.asm', [], 'ASSIZE3-O', None),
        ('assize4.asm', [], 'ASSIZE4-O', None),
        ('asextsym.asm', [], 'ASEXTSYM-O', None),
        ('asdorg.asm', [], 'ASDORG-O', None),
        ('asrorg.asm', [], 'ASRORG-O', None),
        ('asimg1.asm', [], 'ASIMG1-O', 'ASIMG1-C'),
        ('asimg2.asm', [], 'ASIMG2-O', None),
        ('asimg3.asm', [], 'ASIMG3-OX', None),
        ('asreloc.asm', [], 'ASRELOC-O', None),
        ('asxorg.asm', [], 'ASXORG-O', None),
        ('ascart.asm', ['-R'], 'ASCART-O', 'ASCART-C')
    ]:
        source = os.path.join(Dirs.sources, inp_file)
        xdm(Disks.asmsrcs, '-e', ref_file, '-o', Files.reference)
        xas(*[source] + opts + ['-q', '-o', Files.output])
        check_obj_code_eq(Files.output, Files.reference)
        xas(*[source] + opts + ['--strict', '-q', '-o', Files.output])
        check_obj_code_eq(Files.output, Files.reference)
        if compr_file:
            # compressed object code
            xas(*[source] + opts + ['-C', '-q', '-o', Files.output])
            xdm(Disks.asmsrcs, '-e', compr_file, '-o', Files.reference)
            check_obj_code_eq(Files.output, Files.reference, compressed=True)

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

    for inp_file, reffiles in [
        ('aslimg.asm', ['ASLIMG-I', 'ASLIMG-J', 'ASLIMG-K']),
        ('assimg.asm', ['ASSIMG-I', 'ASSIMG-J', 'ASSIMG-K', 'ASSIMG-L']),
        ('asreloc.asm', ['ASRELOC-I'])
    ]:
        source = os.path.join(Dirs.sources, inp_file)
        xas(source, '-R', '-i', '-q', '-o', Files.output)
        gendata = []
        refdata = []
        for i, ref_file in enumerate(reffiles):
            xdm(Disks.asmimgs, '-e', ref_file, '-o', Files.reference)
            with open(Files.outputff[i],
                      'rb') as fgen, open(Files.reference, 'rb') as fref:
                gendata.append(fgen.read())
                refdata.append(fref.read())
        check_image_set_eq(gendata, refdata)

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

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

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

    # cleanup
    for i in range(4):
        os.remove(Files.outputff[i])
    os.remove(Files.reference)
コード例 #6
0
def runtest():
    """check error messages against native assembler listing"""

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

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

    # compare
    check_errors(ti_errors, xas_errors)

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

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

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

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

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

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

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

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

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

    # cleanup
    os.remove(Files.error)
    os.remove(Files.reference)
コード例 #7
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)
コード例 #8
0
ファイル: as-checkext.py プロジェクト: peberlein/xdt99
def runtest():
    """check xdt99 extensions"""

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

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

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

    # macro with text argument in listing
    source = os.path.join(Dirs.sources, 'asmactxt.asm')
    xas(source, 'vmbw.a99', '-R', '-b', '-o', Files.input, '-L', Files.output)
    if "'0'" in content_lines(Files.output):
        error('macro/listing', 'Macro arguments not escaped in listing')

    # SAVE directive
    source = os.path.join(Dirs.sources, 'asxsave.asm')
    xas(source, '-b', '--base', '0xb000', '-q', '-o', Files.output)
    for i, a in enumerate(['_b000', '_b020', '_b030', '_b080']):
        ref = os.path.join(Dirs.refs, f'asxsave_{i}.bin')
        check_binary_files_eq('SAVE', Files.output + a, ref)

    xas(source, '-t', 'a2', '-a', '0xb000', '-q', '-o', Files.output)
    for i, a in enumerate(['_b000', '_b020', '_b030', '_b080']):
        ref = os.path.join(Dirs.refs, f'asxsave_{i}.bin')
        check_dat_file_eq(Files.output + a, ref)

    source = os.path.join(Dirs.sources, 'asxsavee.asm')
    xas(source, '-b', '-a', '0x6000', '-q', '-o', Files.output)
    if content(Files.output) != b'\x22\x22\x22\x22':
        error('SAVE', 'Bad file contents')

    source = os.path.join(Dirs.sources, 'asxsaveo.asm')
    xas(source, '-b', '-o', Files.output)
    ref2 = os.path.join(Dirs.sources, 'asxsaveo2.asm')
    ref6 = os.path.join(Dirs.sources, 'asxsaveo6.asm')
    xas(ref2, '-b', '-o', Files.reference)
    check_binary_files_eq('SAVE', Files.output + '_2000', Files.reference)
    xas(ref6, '-b', '-o', Files.reference)
    check_binary_files_eq('SAVE', Files.output + '_6000', Files.reference)

    # remove front/back padding from saved binary
    source = os.path.join(Dirs.sources, 'asxsavem.asm')
    # this padding could be avoided if saves would *enable* splitting of segments
    xas(source, '-b', '-o', Files.output)
    ref = os.path.join(Dirs.sources, 'asxsavem0.asm')
    xas(ref, '-b', '-o', Files.reference)
    check_binary_files_eq('SAVE', Files.output, Files.reference)

    # bank switching: obsolete AORG addr, bank
    source = os.path.join(Dirs.sources, 'asxbank1.asm')
    xas(source, '-b', '-a', '>6030', '-q', '-o', Files.output)
    save2s = [Files.output + '_b' + str(ext) for ext in range(3)]
    check_concat_eq(save2s, os.path.join(Dirs.refs, 'save2'))

    source = os.path.join(Dirs.sources, 'asxbank2.asm')
    xas(source, '-b', '-q', '-o', Files.output)
    for i, a in enumerate([
            '_c000_b0', '_d000_b0', '_e000_b0', '_c000_b1', '_d000_b1',
            '_e000_b1'
    ]):
        xas(os.path.join(Dirs.sources, 'asxbank2' + a + '.asm'), '-b', '-q',
            '-o', Files.reference)
        check_binary_files_eq('BANK+SAVE', Files.output + a, Files.reference)

    source = os.path.join(Dirs.sources, 'asxsegm.asm')
    xas(source, '-i', '-q', '-o', Files.output)
    check_file_sizes([(Files.outputff[i], size)
                      for i, size in enumerate([26, 20, 14])])
    for i, val in enumerate([0x10, 0x20, 0x30]):
        check_image_values(Files.outputff[i], val)

    # BANK directive
    source = os.path.join(Dirs.sources, 'asdbank.asm')
    xas(source, '-b', '-R', '-o', Files.output)
    ref1 = os.path.join(Dirs.sources, 'asdbank_b0.asm')
    ref2 = os.path.join(Dirs.sources, 'asdbank_b1.asm')
    xas(ref1, '-b', '-R', '-o', Files.reference)
    check_binary_files_eq('BANK', Files.output + '_b0', Files.reference)
    xas(ref2, '-b', '-R', '-o', Files.reference)
    check_binary_files_eq('BANK', Files.output + '_b1', Files.reference)

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

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

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

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

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

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

    # auto-generated constants (b#, w#)
    source = os.path.join(Dirs.sources, 'asauto.asm')
    xas(source, '-R', '-o', Files.output)
    ref = os.path.join(Dirs.sources, 'asauton.asm')
    xas(ref, '-R', '-o', Files.reference)
    check_obj_code_eq(Files.output, Files.reference)

    xas(source, '-R', '-a', '>2000', '-o', Files.output)
    xas(ref, '-R', '-a', '>2000', '-o', Files.reference)
    check_obj_code_eq(Files.output, Files.reference)  # relocated

    xas(source, '-b', '-R', '-o', Files.output)
    xas(ref, '-b', '-R', '-o', Files.reference)
    check_binary_files_eq('auto-const', Files.output,
                          Files.reference)  # as binary

    # size modifier (s#)
    source = os.path.join(Dirs.sources, 'assmod.asm')
    with open(Files.error, 'w') as ferr:
        xas(source, '-b', '-R', '-o', Files.output, stderr=ferr, rc=0)
    ref = os.path.join(Dirs.sources, 'assmodn.asm')
    xas(ref, '-b', '-R', '-q', '-o', Files.reference)
    check_binary_files_eq('s#', Files.output, Files.reference)

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

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

    # 9995 and F18A
    source1 = os.path.join(Dirs.sources, 'as9995.asm')
    xas(source1, '-R', '-b', '-5', '-o', Files.output)
    ref = os.path.join(Dirs.refs, 'as9995.ref')
    check_binary_files_eq('9995', Files.output, ref)

    source2 = os.path.join(Dirs.sources, 'asf18a.asm')
    xas(source2, '-R', '-b', '--f18a', '-o', Files.output)
    ref = os.path.join(Dirs.refs, 'asf18a.ref')
    check_binary_files_eq('f18a', Files.output, ref)

    with open(source1, 'r') as f1, open(source2, 'r') as f2:
        lines1 = f1.readlines()
        lines2 = f2.readlines()
        with open(Files.input, 'w') as fout:
            fout.writelines(lines1 + lines2)
    xas(Files.input, '-R', '-5', '-18', '-o', Files.output, rc=0)

    # cleanup
    for fn in glob.glob("tmp/outpu*"):
        os.remove(fn)
    os.remove(Files.input)
    os.remove(Files.reference)