Exemplo n.º 1
0
    def test_console_read(self, semihost_builder, data, readlen):
        console = RecordingSemihostIOHandler()
        agent = semihost.SemihostAgent(semihost_builder.ctx, console=console)
        semihost_builder.set_agent(agent)

        console.set_input_data(semihost.STDIN_FD, data)

        result, resultData = semihost_builder.do_read(semihost.STDIN_FD,
                                                      readlen)

        assert result == (readlen - min(readlen, len(data)))

        expectedData = data[:min(len(data), readlen)]
        assert resultData == expectedData
Exemplo n.º 2
0
def ioh(ctx):
    handler = semihost.SemihostIOHandler()
    agent = semihost.SemihostAgent(ctx, io_handler=handler)
    return handler, agent
Exemplo n.º 3
0
 def test_only_console(self, ctx):
     c = RecordingSemihostIOHandler()
     a = semihost.SemihostAgent(ctx, io_handler=None, console=c)
     assert type(a.io_handler) is semihost.SemihostIOHandler
     assert a.console is c
Exemplo n.º 4
0
 def test_only_io_handler(self, ctx):
     c = RecordingSemihostIOHandler()
     a = semihost.SemihostAgent(ctx, io_handler=c, console=None)
     assert a.io_handler is c
     assert a.console is c
Exemplo n.º 5
0
 def test_no_io_handler(self, ctx):
     a = semihost.SemihostAgent(ctx, io_handler=None, console=None)
     assert type(a.io_handler) is semihost.SemihostIOHandler
     assert type(a.console) is semihost.SemihostIOHandler
     assert a.console is a.io_handler
Exemplo n.º 6
0
def console_semihost_builder(semihost_builder):
    console = RecordingSemihostIOHandler()
    agent = semihost.SemihostAgent(semihost_builder.ctx, console=console)
    semihost_builder.set_agent(agent)
    return semihost_builder
Exemplo n.º 7
0
def ioh(tgt):
    handler = semihost.SemihostIOHandler()
    agent = semihost.SemihostAgent(tgt, io_handler=handler)
    return handler, agent
Exemplo n.º 8
0
def semihost_telnet_agent(ctx, telnet, request):
    agent = semihost.SemihostAgent(ctx, console=telnet)
    def cleanup():
        agent.cleanup()
    request.addfinalizer(cleanup)
    return agent