def __init__(self, o, iostr, io2str, io3str, tester, name=None, io1_dummy_write=None, CA=None, do_close=True, auth_begin_rv=gensio.GE_NOTSUP, expect_pw=None, expect_pw_rv=gensio.GE_NOTSUP, password=None): self.o = o if (name): self.name = name else: self.name = iostr self.waiter = gensio.waiter(o) self.acc = gensio.gensio_accepter(o, iostr, self) self.acc.startup() self.acc2 = gensio.gensio_accepter(o, io2str, self) self.acc2.startup() self.io1 = self.acc2.str_to_gensio(io3str, None) self.io2 = None self.CA = CA h = utils.HandleData(o, io3str, io=self.io1, password=password) self.auth_begin_rv = auth_begin_rv self.expect_pw = expect_pw self.expect_pw_rv = expect_pw_rv try: self.io1.open_s() except: self.io1 = None self.close() raise if (io1_dummy_write): # For UDP, kick start things. self.io1.write(io1_dummy_write, None) try: self.wait() except: self.close() raise if (io1_dummy_write): self.io2.handler.set_compare(io1_dummy_write) if (self.io2.handler.wait_timeout(1000) == 0): raise Exception( ("%s: %s: " % ("test_accept", self.io2.handler.name)) + ("Timed out waiting for dummy read at byte %d" % self.io2.handler.compared)) tester(self.io1, self.io2) if do_close: self.close()
def test_stdio_basic_stderr(): print("Test stdio basic stderr echo") io = utils.alloc_io(o, "stdio,sh -c 'cat 1>&2'", chunksize=64) io.handler.ignore_input = True io.read_cb_enable(True) err = io.open_channel_s(None, None) utils.HandleData(o, "stderr", chunksize=64, io=err) utils.test_dataxfer(io, err, "This is a test string!") utils.io_close(io) utils.io_close(err) print(" Success!")
def __init__(self, o, pipedev, configdata=None, emudata=None, extra_args=""): """Create a running ipmisim program The given config data is written to a file and used as the config file. It is started with the -r and -d options set, you can supply extra options if you like as a string. """ prog = os.getenv("IPMISIM_EXEC") if (not prog): prog = "ipmi_sim" if not configdata: configdata = default_ipmisim_config % pipedev if not emudata: emudata = default_ipmisim_emu self.cfile = tempfile.NamedTemporaryFile(mode="w+") self.cfile.write(configdata) self.cfile.flush() self.efile = tempfile.NamedTemporaryFile(mode="w+") self.efile.write(emudata) self.efile.flush() self.o = o args = "stdio," + prog + " -p -c " + self.cfile.name + " -f " + self.efile.name + " " + extra_args if (utils.debug): print("Running: " + args) self.handler = utils.HandleData(o, args, name="ipmisim daemon") self.io = self.handler.io self.io.closeme = True self.io.open_s() # Uncomment the following or set it yourself to get output from # the ipmisim daemon printed. #self.handler.debug = 2 self.pid = utils.remote_id_int(self.io) self.handler.set_waitfor("> ") if (self.handler.wait_timeout(2000) == 0): raise Exception("Timeout waiting for ipmi_sim to start") self.handler.ignore_input = True # Leave read on so if we enable debug we can see output from the # daemon. self.io.read_cb_enable(True) return
def new_connection(self, acc, io): utils.HandleData(self.o, None, io=io, name=self.name) self.io2 = io self.waiter.wake()