示例#1
0
def map_interface(node_name, include_lst):
    cwd = Path(os.environ['UNITEST_build_DIR']) / node_name / "mapping"
    cwd.make_dirs()

    (cwd / 'structarray_interface.c').write_text(scade_interface_template)

    cmd = (["gcc", "-save-temps", "-std=c99", "-g"] +
           [f"-I{str(include_dir)}" for include_dir in include_lst] +
           ["structarray_interface.c", "-o", "structarray_interface.exe"])
    ret = cwd.run(*cmd)
    if ret.returncode != 0:
        raise ValueError("gcc couldn't compile properly")

    ret = cwd.run("./structarray_interface.exe")

    for k in ["input", "output"]:
        u = structarray.StructInfo(cwd / 'structarray_interface.exe')
        u.parse(k)
        u.save(cwd, k)
示例#2
0
def map_context(node_name, include_lst):

    cwd = Path(os.environ['UNITEST_build_DIR']) / node_name / "mapping"
    cwd.make_dirs()

    (cwd / 'structarray_context.c').write_text(
        scade_context_template.format(node_name=node_name))

    cmd = (["gcc", "-save-temps", "-std=c99", "-g"] +
           [f"-I{str(include_dir)}" for include_dir in include_lst] +
           ["structarray_context.c", "-o", "structarray_context.exe"])
    ret = cwd.run(*cmd)
    if ret.returncode != 0:
        raise ValueError("gcc couldn't compile properly")

    ret = cwd.run("./structarray_context.exe")
    txt = ret.stdout.decode(sys.stdout.encoding)
    (cwd / "structarray_ctype.json").write_text(txt.replace(',\n}', '\n}'))

    u = structarray.StructInfo(cwd / 'structarray_context.exe')
    u.parse('context')
    u.save(cwd, 'context')

    return u
示例#3
0
#!/usr/bin/env python3

import random
import sys

random.seed(0)

from cc_pathlib import Path

tmp_dir = Path('./tmp')
tmp_dir.make_dirs()
tmp_dir.delete(content_only=True)

letter = 'abcdefghijklmnopqrstuvwxyz0123456789'

content_map = dict()

for i in range(256):
    l = random.randrange(8, 16)
    c = random.randrange(len(letter))
    m = letter[c] * l

    (tmp_dir / f"{i:04d}.txt").write_text(m)
    content_map[i] = m

tmp_dir.dedup('*.txt')

exit_value = 0
for i in content_map:
    m_ref = content_map[i]
    m_tst = (tmp_dir / f"{i:04d}.txt").read_text()