Exemple #1
0
def libcore_stub_gen_base_test():
  scan = _create_scan()
  ctx = _create_ctx()
  # create stub
  gen = LibStubGen()
  stub = gen.gen_stub(scan, ctx)
  _check_stub(stub)
  # call func
  stub.PrintHello()
  stub.Dummy()
  stub.Swap()
Exemple #2
0
def libcore_stub_gen_base_test():
    scan = _create_scan()
    ctx = _create_ctx()
    # create stub
    gen = LibStubGen()
    stub = gen.gen_stub(scan, ctx)
    _check_stub(stub)
    # call func
    stub.PrintHello()
    stub.Dummy()
    stub.Swap()
Exemple #3
0
def libcore_stub_gen_exc_default_test():
    scan = _create_scan()
    ctx = _create_ctx()
    # create stub
    gen = LibStubGen()
    stub = gen.gen_stub(scan, ctx)
    _check_stub(stub)
    # call func
    ctx.mem.w_cstr(0, 'RuntimeError')
    with pytest.raises(RuntimeError):
        stub.RaiseError()
Exemple #4
0
def libcore_stub_gen_exc_default_test():
  scan = _create_scan()
  ctx = _create_ctx()
  # create stub
  gen = LibStubGen()
  stub = gen.gen_stub(scan, ctx)
  _check_stub(stub)
  # call func
  ctx.mem.w_cstr(0, 'RuntimeError')
  with pytest.raises(RuntimeError):
    stub.RaiseError()
Exemple #5
0
def libcore_stub_gen_fake_base_test():
  name = 'vamostest.library'
  fd = read_lib_fd(name)
  ctx = _create_ctx()
  # create stub
  gen = LibStubGen()
  stub = gen.gen_fake_stub(name, fd, ctx)
  _check_stub(stub)
  # call func
  stub.PrintHello()
  stub.Dummy()
  stub.Swap()
Exemple #6
0
def libcore_stub_gen_fake_base_test():
    name = 'vamostest.library'
    fd = read_lib_fd(name)
    ctx = _create_ctx()
    # create stub
    gen = LibStubGen()
    stub = gen.gen_fake_stub(name, fd, ctx)
    _check_stub(stub)
    # call func
    stub.PrintHello()
    stub.Dummy()
    stub.Swap()
Exemple #7
0
def libcore_stub_gen_profile_test():
    scan = _create_scan()
    ctx = _create_ctx()
    profile = LibProfileData(scan.get_fd())
    # create stub
    gen = LibStubGen()
    stub = gen.gen_stub(scan, ctx, profile)
    _check_stub(stub)
    # call func
    stub.PrintHello()
    stub.Dummy()
    stub.Swap()
    _check_profile(scan.get_fd(), profile)
Exemple #8
0
def libcore_stub_gen_profile_test():
  scan = _create_scan()
  ctx = _create_ctx()
  profile = LibProfileData(scan.get_fd())
  # create stub
  gen = LibStubGen()
  stub = gen.gen_stub(scan, ctx, profile)
  _check_stub(stub)
  # call func
  stub.PrintHello()
  stub.Dummy()
  stub.Swap()
  _check_profile(scan.get_fd(), profile)
Exemple #9
0
def libcore_stub_gen_exc_default_test():
    name = 'vamostest.library'
    impl = VamosTestLibrary()
    fd = read_lib_fd(name)
    ctx = _create_ctx()
    # create stub
    gen = LibStubGen()
    stub = gen.gen_stub(name, impl, fd, ctx)
    _check_stub(stub)
    # call func
    ctx.mem.w_cstr(0, 'RuntimeError')
    with pytest.raises(RuntimeError):
        stub.RaiseError()
Exemple #10
0
def libcore_stub_gen_fake_profile_test():
  name = 'vamostest.library'
  fd = read_lib_fd(name)
  ctx = _create_ctx()
  profile = LibProfileData(fd)
  # create stub
  gen = LibStubGen()
  stub = gen.gen_fake_stub(name, fd, ctx, profile)
  _check_stub(stub)
  # call func
  stub.PrintHello()
  stub.Dummy()
  stub.Swap()
  _check_profile(fd, profile)
Exemple #11
0
def libcore_stub_gen_fake_profile_test():
    name = 'vamostest.library'
    fd = read_lib_fd(name)
    ctx = _create_ctx()
    profile = LibProfileData(fd)
    # create stub
    gen = LibStubGen()
    stub = gen.gen_fake_stub(name, fd, ctx, profile)
    _check_stub(stub)
    # call func
    stub.PrintHello()
    stub.Dummy()
    stub.Swap()
    _check_profile(fd, profile)
Exemple #12
0
def libcore_stub_gen_log_test(caplog):
  caplog.set_level(logging.INFO)
  scan = _create_scan()
  ctx = _create_ctx()
  log_missing = logging.getLogger('missing')
  log_valid = logging.getLogger('valid')
  # create stub
  gen = LibStubGen(log_missing=log_missing, log_valid=log_valid)
  stub = gen.gen_stub(scan, ctx)
  _check_stub(stub)
  # call func
  stub.PrintHello()
  stub.Dummy()
  stub.Swap()
  _check_log(caplog)
Exemple #13
0
def libcore_stub_gen_log_test(caplog):
    caplog.set_level(logging.INFO)
    scan = _create_scan()
    ctx = _create_ctx()
    log_missing = logging.getLogger('missing')
    log_valid = logging.getLogger('valid')
    # create stub
    gen = LibStubGen(log_missing=log_missing, log_valid=log_valid)
    stub = gen.gen_stub(scan, ctx)
    _check_stub(stub)
    # call func
    stub.PrintHello()
    stub.Dummy()
    stub.Swap()
    _check_log(caplog)
Exemple #14
0
def libcore_stub_gen_fake_log_test(caplog):
  caplog.set_level(logging.INFO)
  name = 'vamostest.library'
  fd = read_lib_fd(name)
  ctx = _create_ctx()
  log_missing = logging.getLogger('missing')
  log_valid = logging.getLogger('valid')
  # create stub
  gen = LibStubGen(log_missing=log_missing, log_valid=log_valid)
  stub = gen.gen_fake_stub(name, fd, ctx)
  _check_stub(stub)
  # call func
  stub.PrintHello()
  stub.Dummy()
  stub.Swap()
  _check_log_fake(caplog)
Exemple #15
0
def libcore_stub_gen_fake_log_test(caplog):
    caplog.set_level(logging.INFO)
    name = 'vamostest.library'
    fd = read_lib_fd(name)
    ctx = _create_ctx()
    log_missing = logging.getLogger('missing')
    log_valid = logging.getLogger('valid')
    # create stub
    gen = LibStubGen(log_missing=log_missing, log_valid=log_valid)
    stub = gen.gen_fake_stub(name, fd, ctx)
    _check_stub(stub)
    # call func
    stub.PrintHello()
    stub.Dummy()
    stub.Swap()
    _check_log_fake(caplog)
Exemple #16
0
def libcore_stub_gen_log_profile_test(caplog):
    caplog.set_level(logging.INFO)
    scan = _create_scan()
    ctx = _create_ctx()
    log_missing = logging.getLogger("missing")
    log_valid = logging.getLogger("valid")
    profile = LibProfileData(scan.get_fd())
    # create stub
    gen = LibStubGen(log_missing=log_missing, log_valid=log_valid)
    stub = gen.gen_stub(scan, ctx, profile)
    _check_stub(stub)
    # call func
    stub.PrintHello()
    stub.Dummy()
    stub.Swap()
    _check_log(caplog)
    _check_profile(scan.get_fd(), profile)
Exemple #17
0
def libcore_stub_gen_multi_arg(caplog):
    caplog.set_level(logging.INFO)
    scan = _create_scan()
    ctx = _create_ctx()
    log_missing = logging.getLogger('missing')
    log_valid = logging.getLogger('valid')
    profile = LibProfileData(scan.get_fd())
    # create stub
    gen = LibStubGen(log_missing=log_missing, log_valid=log_valid)
    stub = gen.gen_stub(scan, ctx, profile)
    _check_stub(stub)
    # call func
    stub.PrintHello(1, 2, a=3)
    stub.Dummy(3, b='hello')
    stub.Swap('hugo', None, c=3)
    _check_log(caplog)
    _check_profile(scan.get_fd(), profile)
Exemple #18
0
def libcore_stub_gen_multi_arg(caplog):
  caplog.set_level(logging.INFO)
  scan = _create_scan()
  ctx = _create_ctx()
  log_missing = logging.getLogger('missing')
  log_valid = logging.getLogger('valid')
  profile = LibProfileData(scan.get_fd())
  # create stub
  gen = LibStubGen(log_missing=log_missing, log_valid=log_valid)
  stub = gen.gen_stub(scan, ctx, profile)
  _check_stub(stub)
  # call func
  stub.PrintHello(1, 2, a=3)
  stub.Dummy(3, b='hello')
  stub.Swap('hugo', None, c=3)
  _check_log(caplog)
  _check_profile(scan.get_fd(), profile)
Exemple #19
0
def libcore_stub_gen_exc_default_test(capsys):
    name = 'vamostest.library'
    impl = VamosTestLibrary()
    fd = read_lib_fd(name)
    ctx = _create_ctx()
    # create stub
    gen = LibStubGen()
    stub = gen.gen_stub(name, impl, fd, ctx)
    _check_stub(stub)
    # call func
    ctx.mem.w_cstr(0, 'RuntimeError')
    with pytest.raises(RuntimeError):
        stub.RaiseError()
    # check for traceback
    captured = capsys.readouterr()
    lines = captured.err.strip().split('\n')
    assert lines[0] == 'Traceback (most recent call last):'
    assert lines[-1] == 'RuntimeError: VamosTest'
Exemple #20
0
def libcore_stub_gen_multi_arg_test(caplog):
    caplog.set_level(logging.INFO)
    scan = _create_scan()
    ctx = _create_ctx()
    log_missing = logging.getLogger("missing")
    log_valid = logging.getLogger("valid")
    profile = LibProfileData(scan.get_fd())
    # create stub
    gen = LibStubGen(log_missing=log_missing, log_valid=log_valid)
    stub = gen.gen_stub(scan, ctx, profile)
    _check_stub(stub)
    # call func
    stub.PrintHello(1, 2, a=3)
    stub.Dummy(3, b="hello")
    stub.Swap("hugo", None, c=3)
    stub.PrintString("a", b=4, c=5)
    _check_log(caplog)
    _check_profile(scan.get_fd(), profile)
Exemple #21
0
def libcore_stub_gen_fake_log_profile_test(caplog):
    caplog.set_level(logging.INFO)
    name = "vamostest.library"
    fd = read_lib_fd(name)
    ctx = _create_ctx()
    log_missing = logging.getLogger("missing")
    log_valid = logging.getLogger("valid")
    profile = LibProfileData(fd)
    # create stub
    gen = LibStubGen(log_missing=log_missing, log_valid=log_valid)
    stub = gen.gen_fake_stub(name, fd, ctx, profile)
    _check_stub(stub)
    # call func
    stub.PrintHello()
    stub.Dummy()
    stub.Swap()
    _check_log_fake(caplog)
    _check_profile(fd, profile)
Exemple #22
0
def libcore_stub_gen_multi_arg(capsys):
    caplog.set_level(logging.INFO)
    name = 'vamostest.library'
    impl = VamosTestLibrary()
    fd = read_lib_fd(name)
    ctx = _create_ctx()
    log_missing = logging.getLogger('missing')
    log_valid = logging.getLogger('valid')
    profile = LibProfile(name, fd)
    # create stub
    gen = LibStubGen(log_missing=log_missing, log_valid=log_valid)
    stub = gen.gen_stub(name, impl, fd, ctx, profile)
    _check_stub(stub)
    # call func
    stub.PrintHello(1, 2, a=3)
    stub.Dummy(3, b='hello')
    stub.Swap('hugo', None, c=3)
    _check_log(caplog)
    _check_profile(fd, profile)
Exemple #23
0
def libcore_stub_gen_log_profile_test(caplog):
    caplog.set_level(logging.INFO)
    name = 'vamostest.library'
    impl = VamosTestLibrary()
    fd = read_lib_fd(name)
    ctx = _create_ctx()
    log_missing = logging.getLogger('missing')
    log_valid = logging.getLogger('valid')
    profile = LibProfileData(fd)
    # create stub
    gen = LibStubGen(log_missing=log_missing, log_valid=log_valid)
    stub = gen.gen_stub(name, impl, fd, ctx, profile)
    _check_stub(stub)
    # call func
    stub.PrintHello()
    stub.Dummy()
    stub.Swap()
    _check_log(caplog)
    _check_profile(fd, profile)
def _create_stub(do_profile=False, do_log=False):
    name = 'vamostest.library'
    impl = VamosTestLibrary()
    fd = read_lib_fd(name)
    ctx = _create_ctx()
    if do_profile:
        profile = LibProfileData(fd)
    else:
        profile = None
    if do_log:
        log_missing = logging.getLogger('missing')
        log_valid = logging.getLogger('valid')
    else:
        log_missing = None
        log_valid = None
    # create stub
    gen = LibStubGen(log_missing=log_missing, log_valid=log_valid)
    stub = gen.gen_stub(name, impl, fd, ctx, profile)
    return stub
Exemple #25
0
def libcore_stub_gen_base_test():
    scan = _create_scan()
    ctx = _create_ctx()
    # create stub
    gen = LibStubGen()
    stub = gen.gen_stub(scan, ctx)
    _check_stub(stub)
    # call func
    stub.PrintHello()
    stub.Dummy()
    # check arg transfer
    ctx.cpu.w_reg(REG_D0, 21)
    ctx.cpu.w_reg(REG_D1, 10)
    stub.Swap()
    assert ctx.cpu.r_reg(REG_D0) == 10
    assert ctx.cpu.r_reg(REG_D1) == 21
    # check return
    stub.Add()
    assert ctx.cpu.r_reg(REG_D0) == 31
def _create_stub(do_profile=False, do_log=False):
  name = 'vamostest.library'
  impl = VamosTestLibrary()
  fd = read_lib_fd(name)
  scanner = LibImplScanner()
  scan = scanner.scan(name, impl, fd)
  ctx = _create_ctx()
  if do_profile:
    profile = LibProfileData(fd)
  else:
    profile = None
  if do_log:
    log_missing = logging.getLogger('missing')
    log_valid = logging.getLogger('valid')
  else:
    log_missing = None
    log_valid = None
  # create stub
  gen = LibStubGen(log_missing=log_missing, log_valid=log_valid)
  stub = gen.gen_stub(scan, ctx, profile)
  return stub
def _create_stub(do_profile=False, do_log=False):
    name = "vamostest.library"
    impl = VamosTestLibrary()
    fd = read_lib_fd(name)
    scanner = LibImplScanner()
    scan = scanner.scan(name, impl, fd)
    ctx = _create_ctx()
    if do_profile:
        profile = LibProfileData(fd)
    else:
        profile = None
    if do_log:
        log_missing = logging.getLogger("missing")
        log_valid = logging.getLogger("valid")
    else:
        log_missing = None
        log_valid = None
    # create stub
    gen = LibStubGen(log_missing=log_missing, log_valid=log_valid)
    stub = gen.gen_stub(scan, ctx, profile)
    return stub
Exemple #28
0
def libcore_stub_gen_exc_custom_test(capsys):
    name = 'vamostest.library'
    impl = VamosTestLibrary()
    fd = read_lib_fd(name)
    ctx = _create_ctx()

    # create stub

    def custom_handler(self):
        print("hello, world!")

    gen = LibStubGen(exc_handler=custom_handler)
    stub = gen.gen_stub(name, impl, fd, ctx)
    _check_stub(stub)
    # call func
    ctx.mem.w_cstr(0, 'RuntimeError')
    stub.RaiseError()
    # check for traceback
    captured = capsys.readouterr()
    lines = captured.out.strip().split('\n')
    assert lines[-1] == "hello, world!"
Exemple #29
0
def libcore_stub_gen_base_test(capsys):
    scan = _create_scan()
    ctx = _create_ctx()
    # create stub
    gen = LibStubGen()
    stub = gen.gen_stub(scan, ctx)
    _check_stub(stub)
    # call func
    stub.PrintHello()
    cap = capsys.readouterr()
    assert cap.out.strip() == "VamosTest: PrintHello()"
    stub.Dummy()
    # check arg transfer
    ctx.cpu.w_reg(REG_D0, 21)
    ctx.cpu.w_reg(REG_D1, 10)
    stub.Swap()
    assert ctx.cpu.r_reg(REG_D0) == 10
    assert ctx.cpu.r_reg(REG_D1) == 21
    # check return
    stub.Add()
    assert ctx.cpu.r_reg(REG_D0) == 31
    stub.PrintString()
    cap = capsys.readouterr()
    assert cap.out.strip() == "VamosTest: PrintString('hello, world!')"