Ejemplo n.º 1
0
def setup_all_pipes():
    write_pipe = Pipe("env1", "write", 'w', "mame/pipes")
    lua_read_pipe = setup_pipe(write_pipe)

    read_pipe = Pipe("env1", "read", 'r', "mame/pipes")
    lua_write_pipe = setup_pipe(read_pipe)

    return write_pipe, lua_read_pipe, read_pipe, lua_write_pipe
Ejemplo n.º 2
0
    def test_write(self):
        write_pipe, lua_read_pipe = [None, None]
        try:
            write_pipe = Pipe("env1", "write", 'w', "mame/pipes")
            lua_read_pipe = setup_pipe(write_pipe)

            write_pipe.writeln("test")
            assert_that(lua_read_pipe.readline(), equal_to("test\n"))
        finally:
            close_pipes(write_pipe, lua_read_pipe)
Ejemplo n.º 3
0
def run_write(output_queue):
    write_pipe, lua_read_pipe = [None, None]
    try:
        write_pipe = Pipe("env1", "write", 'w', "mame/pipes")
        lua_read_pipe = setup_pipe(write_pipe)

        write_pipe.writeln("test")
        output_queue.put(lua_read_pipe.readline())
    finally:
        close_pipes(write_pipe, lua_read_pipe)
Ejemplo n.º 4
0
def run_read(output_queue):
    read_pipe, lua_write_pipe = [None, None]
    try:
        read_pipe = Pipe("env1", "read", 'r', "mame/pipes")
        lua_write_pipe = setup_pipe(read_pipe)

        lua_write_pipe.write("test\n")
        lua_write_pipe.flush()
        output_queue.put(read_pipe.readln(timeout=1))
    finally:
        close_pipes(read_pipe, lua_write_pipe)
Ejemplo n.º 5
0
    def test_read(self):
        read_pipe, lua_write_pipe = [None, None]
        try:
            read_pipe = Pipe("env1", "read", 'r', "mame/pipes")
            lua_write_pipe = setup_pipe(read_pipe)

            lua_write_pipe.write("test\n")
            lua_write_pipe.flush()
            assert_that(read_pipe.readln(timeout=0.1), equal_to(b"test"))
        finally:
            close_pipes(read_pipe, lua_write_pipe)
Ejemplo n.º 6
0
    def test_readln_empty(self):
        read_pipe, lua_write_pipe = [None, None]
        try:
            read_pipe = Pipe("env1", "read", 'r', "mame/pipes")
            lua_write_pipe = setup_pipe(read_pipe)

            with self.assertRaises(IOError) as context:
                read_pipe.readln(timeout=0.1)

            assert_that(str(context.exception), contains_string("Failed to read value from 'readPipe'"))
        finally:
            close_pipes(read_pipe, lua_write_pipe)
Ejemplo n.º 7
0
    def test_write_to_read_pipe(self):
        read_pipe, lua_write_pipe = [None, None]
        try:
            read_pipe = Pipe("env1", "read", 'r', "mame/pipes")
            lua_write_pipe = setup_pipe(read_pipe)

            with self.assertRaises(IOError) as context:
                read_pipe.writeln("TEST")

            assert_that(str(context.exception), contains_string("Attempted to write to '/home/michael/dev/MAMEToolkit/test/emulator/mame/pipes/read-env1.pipe' in 'r' mode"))

        finally:
            close_pipes(read_pipe, lua_write_pipe)
Ejemplo n.º 8
0
    def test_read_from_write_pipe(self):
        write_pipe, lua_read_pipe = [None, None]
        try:
            write_pipe = Pipe("env1", "write", 'w', "mame/pipes")
            lua_read_pipe = setup_pipe(write_pipe)

            with self.assertRaises(IOError) as context:
                write_pipe.readln()

            assert_that(str(context.exception), contains_string("Attempted to read from '/home/michael/dev/MAMEToolkit/test/emulator/mame/pipes/write-env1.pipe' in 'w' mode"))

        finally:
            close_pipes(write_pipe, lua_read_pipe)