def _voidRemoteStopCallBackHandler(self): info("%s", self.uuid) self.validateChecklistItem("subprocess-exited-normally") self._prepareArguments() Test.stop(self) self.ping() # Check if we have new arguments and # have to run another time if self.args: self.start() else: self.tearDown()
def setUp(self): if not Test.setUp(self): return False self._tests = [] # list of (test, args, monitors) self.tests = [] # executed tests # FIXME : asynchronous starts ??? return True
def __init__(self, bus=None, bus_address="", metadata = None, test_arguments = None, env=None, *args, **kwargs): """ bus is the private DBusConnection used for testing. bus_address is the address of the private DBusConnection used for testing. You need to provide at least bus or bus_address. """ if (metadata == None): raise Exception("You need to provide test metadata") self._metadata = metadata self._test_arguments = test_arguments Test.__init__(self, bus_address=bus_address, *args, **kwargs) if (bus == None) and (bus_address == ""): raise Exception("You need to provide at least a bus or bus_address") self._bus = bus self._bus_address = bus_address self._remote_tearing_down = False if self._testrun: sid = self._testrun.connect("new-remote-test", self._newRemoteTest) self._newremotetestsid = sid sid = self._testrun.connect("removed-remote-test", self._removedRemoteTest) self._testrunremovedtestsigid = sid self._process = None self._processpollid = 0 self._remoteinstance = None # return code from subprocess self._returncode = None # variables for remote launching, can be modified by monitors self._stdin = None self._stdout = None self._stderr = None self._redir_tty_thread = None self._preargs = [] self._environ = env or {} self._environ.update(os.environ.copy()) self._subprocessspawntime = 0 self._subprocessconnecttime = 0 self._pid = 0
def setUp(self): info("uuid:%s", self.uuid) if Test.setUp(self) == False: return False # get the remote launcher pargs = self._preargs pargs.extend(self.get_remote_launcher_args()) shell = isinstance (pargs, basestring) cwd = self._testrun.getWorkingDirectory() self._environ["PRIVATE_DBUS_ADDRESS"] = self._bus_address info("Setting PRIVATE_DBUS_ADDRESS : %r" % self._bus_address) info("bus:%r" % self._bus) self._prepareArguments() if False: # useful to allow some time to run dbus-monitor on the private bus print("Setting PRIVATE_DBUS_ADDRESS : %r" % self._bus_address) time.sleep(5) # spawn the other process info("opening %r" % pargs) info("cwd %s" % cwd) try: self._subprocessspawntime = time.time() self._process = subprocess.Popen(pargs, stdin = self._stdin, stdout = subprocess.PIPE, stderr = subprocess.PIPE, env=self._environ, shell = shell, cwd=cwd) self._ensureOutRedirection() self._pid = self._process.pid except: exception("Error starting the subprocess command ! %r", pargs) self.validateChecklistItem("dbus-process-spawned", False) return False debug("Subprocess created successfully [pid:%d]", self._pid) self.validateChecklistItem("dbus-process-spawned") # add a poller for the proces self._processpollid = gobject.timeout_add(500, self._pollSubProcess) # Don't forget to set a timeout for waiting for the connection return True
def getArguments(self): d = Test.getArguments(self) for sub in self.tests: d.update(sub.getArguments()) return d
def ping(self): Test.ping(self)
def start(self): info("uuid:%s", self.uuid) if Test.start(self) == False: return False return self.callRemoteStart()