def run_once(self): time.sleep(self._init_delay) self._suspender = power_suspend.Suspender( self.resultsdir, method=self._method, suspend_state=self._suspend_state) # Find the interface which is used for most communication. if self._check_connection: with open('/proc/net/route') as fh: for line in fh: fields = line.strip().split() if fields[1] != '00000000' or not int(fields[3], 16) & 2: continue interface = fields[0] while not self._done(): time.sleep(self._min_resume + random.randint(0, self._max_resume_window)) # Check the network interface to the caller is still available if self._check_connection: link_status = None try: with open('/sys/class/net/' + interface + '/operstate') as link_file: link_status = link_file.readline().strip() except Exception: pass if link_status != 'up': logging.error('Link to the server gone, reboot') utils.system('reboot') self._suspender.suspend(random.randint(0, 3) + self._min_suspend)
def initialize(self, suspend_state=''): """ Entry point. @param suspend_state: Force to suspend to a specific state ("mem" or "freeze"). If the string is empty, suspend state is left to the default pref on the system. """ self._suspender = power_suspend.Suspender(self.resultsdir, throw=True, device_times=True, suspend_state=suspend_state)
def suspend_resume(self, duration=10): suspender = power_suspend.Suspender(self.resultsdir, throw=True) suspender.suspend(duration) logging.info('Machine resumed') # Race condition hack alert: Before we added this sleep, this # test was very sensitive to the relative timing of the test # and modem resumption. There is a window where flimflam has # not yet learned that the old modem has gone away (it doesn't # find this out until seconds after we resume) and the test is # running. If the test finds and attempts to use the old # modem, those operations will fail. There's no good # hardware-independent way to see the modem go away and come # back, so instead we sleep time.sleep(4)
def run_once(self): time.sleep(self._init_delay) self._suspender = power_suspend.Suspender( self.resultsdir, method=self._method) timeout = time.time() + self._duration while time.time() < timeout: time.sleep(self._min_resume + random.randint(0, 3)) # Check the network interface to the caller is still available if self._interface: link_status = None try: with open('/sys/class/net/' + self._interface + '/operstate') as link_file: link_status = link_file.readline().strip() except: pass if link_status != 'up': logging.error('Link to the server gone, reboot') utils.system('reboot') self._suspender.suspend(random.randint(0, 3) + self._min_suspend)
def initialize(self): self._suspender = power_suspend.Suspender(self.resultsdir, throw=True, device_times=True)
def initialize(self): self._suspender = power_suspend.Suspender(self.resultsdir, method=sys_power.do_suspend, throw=True)