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()
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()
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()
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()
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()
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)
def libcore_stub_gen_base_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 stub.PrintHello() stub.Dummy() stub.Swap()
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)
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)
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)
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)
def libcore_stub_gen_log_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') # create stub gen = LibStubGen(log_missing=log_missing, log_valid=log_valid) stub = gen.gen_stub(name, impl, fd, ctx) _check_stub(stub) # call func stub.PrintHello() stub.Dummy() stub.Swap() _check_log(caplog)
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)
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)
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)
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'
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)
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) 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
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
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!"
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!')"