Exemplo n.º 1
0
 def kill(self, stagedShutdown=False):
     # Take a screenshot to capture the screen state just before
     # the application is killed.
     if not self.device._device_serial.startswith('emulator-'):
         dump_device_screen(self.device, get_default_logger())
     elif self.utilityPath:
         # Do not use the on-device screenshot options since
         # they rarely work well with Firefox on the Android
         # emulator. dump_screen provides an effective
         # screenshot of the emulator and its host desktop.
         dump_screen(self.utilityPath, get_default_logger())
     if stagedShutdown:
         # Trigger an ANR report with "kill -3" (SIGQUIT)
         try:
             self.device.pkill(self.procName, sig=3, attempts=1)
         except ADBTimeoutError:
             raise
         except:  # NOQA: E722
             pass
         time.sleep(3)
         # Trigger a breakpad dump with "kill -6" (SIGABRT)
         try:
             self.device.pkill(self.procName, sig=6, attempts=1)
         except ADBTimeoutError:
             raise
         except:  # NOQA: E722
             pass
         # Wait for process to end
         retries = 0
         while retries < 3:
             if self.device.process_exist(self.procName):
                 print("%s still alive after SIGABRT: waiting..." % self.procName)
                 time.sleep(5)
             else:
                 return
             retries += 1
         try:
             self.device.pkill(self.procName, sig=9, attempts=1)
         except ADBTimeoutError:
             raise
         except:  # NOQA: E722
             print("%s still alive after SIGKILL!" % self.procName)
         if self.device.process_exist(self.procName):
             self.device.stop_application(self.procName)
     else:
         self.device.stop_application(self.procName)
Exemplo n.º 2
0
 def kill(self, stagedShutdown=False):
     # Take a screenshot to capture the screen state just before
     # the application is killed.
     # Do not use the on-device screenshot options since
     # they rarely work well with Firefox on the Android
     # emulator. dump_screen provides an effective
     # screenshot of the emulator and its host desktop.
     if not self.device._device_serial.startswith('emulator-'):
         dump_device_screen(self.device, get_default_logger())
     elif self.utilityPath:
         dump_screen(self.utilityPath, get_default_logger())
     if stagedShutdown:
         # Trigger an ANR report with "kill -3" (SIGQUIT)
         try:
             self.device.pkill(self.procName, sig=3, attempts=1, root=True)
         except ADBTimeoutError:
             raise
         except:  # NOQA: E722
             pass
         time.sleep(3)
         # Trigger a breakpad dump with "kill -6" (SIGABRT)
         try:
             self.device.pkill(self.procName, sig=6, attempts=1, root=True)
         except ADBTimeoutError:
             raise
         except:  # NOQA: E722
             pass
         # Wait for process to end
         retries = 0
         while retries < 3:
             if self.device.process_exist(self.procName):
                 print("%s still alive after SIGABRT: waiting..." % self.procName)
                 time.sleep(5)
             else:
                 break
             retries += 1
         if self.device.process_exist(self.procName):
             try:
                 self.device.pkill(self.procName, sig=9, attempts=1, root=True)
             except ADBTimeoutError:
                 raise
             except:  # NOQA: E722
                 print("%s still alive after SIGKILL!" % self.procName)
         if self.device.process_exist(self.procName):
             self.device.stop_application(self.procName)
     else:
         self.device.stop_application(self.procName)
     # Test harnesses use the MOZ_CRASHREPORTER environment variables to suppress
     # the interactive crash reporter, but that may not always be effective;
     # check for and cleanup errant crashreporters.
     crashreporter = "%s.CrashReporter" % self.procName
     if self.device.process_exist(crashreporter):
         print("Warning: %s unexpectedly found running. Killing..." % crashreporter)
         try:
             self.device.pkill(crashreporter, root=True)
         except ADBTimeoutError:
             raise
         except:  # NOQA: E722
             pass
     if self.device.process_exist(crashreporter):
         print("ERROR: %s still running!!" % crashreporter)