def testWrapper(self): self.start_time = time.time() for d in self.config.devices: dev = getattr(self.config, d) dev.test_to_log = self dev.test_prefix = d.encode("utf8") for c in board.consoles: c.test_to_log = self c.test_prefix = 'console-%s' % str(board.consoles.index(c) + 1) if not c.isalive(): self.result_grade = "SKIP" print("\n\n=========== Test skipped! Board is not alive... =============") self.skipTest("Board is not alive") raise try: if wan and hasattr(self, 'wan_setup'): self.wan_setup() if lan and hasattr(self, 'lan_setup'): self.lan_setup() if wlan and hasattr(self, 'wlan_setup'): self.wlan_setup() if self.config.retry and not self.dont_retry: retry = self.config.retry else: retry = 0 while retry >= 0: try: self.runTest() board.touch() retry = -1 except Exception as e: retry = retry - 1 if(retry > 0): if hasattr(e, 'get_trace'): print(e.get_trace()) else: print("Exception has no trace, type = %s" % type(e)) print("\n\n----------- Test failed! Retrying in 5 seconds... -------------") time.sleep(5) else: raise if wan and hasattr(self, 'wan_cleanup'): self.wan_cleanup() if lan and hasattr(self, 'lan_cleanup'): self.lan_cleanup() if wlan and hasattr(self, 'wlan_cleanup'): self.wlan_cleanup() if hasattr(self, 'expected_failure') and self.expected_failure: self.result_grade = "Unexp OK" else: self.result_grade = "OK" self.stop_time = time.time() except unittest2.case.SkipTest: self.stop_time = time.time() self.result_grade = "SKIP" print("\n\n=========== Test skipped! Moving on... =============") raise except Exception as e: self.stop_time = time.time() if hasattr(self, 'expected_failure') and self.expected_failure: self.result_grade = "Exp FAIL" else: self.result_grade = "FAIL" print("\n\n=========== Test failed! Running recovery Time: %s ===========" % now_short(self._format)) if e.__class__.__name__ == "TIMEOUT": print(e.get_trace()) else: print(e) traceback.print_exc(file=sys.stdout) self.recover() raise
def setUp(self): lib.common.test_msg("\n==================== Begin %s Time: %s ====================" % (self.__class__.__name__, now_short(self._format)))
def tearDown(self): lib.common.test_msg("\n==================== End %s Time: %s ======================" % (self.__class__.__name__, now_short(self._format)))
def testWrapper(self): self.start_time = time.time() if not board.isalive(): self.result_grade = "SKIP" print( "\n\n=========== Test skipped! Board is not alive... =============" ) self.skipTest("Board is not alive") raise try: if wan and hasattr(self, 'wan_setup'): self.wan_setup() if lan and hasattr(self, 'lan_setup'): self.lan_setup() if wlan and hasattr(self, 'wlan_setup'): self.wlan_setup() if self.config.retry and not self.dont_retry: retry = self.config.retry else: retry = 0 while retry >= 0: try: self.runTest() board.touch() retry = -1 except Exception as e: retry = retry - 1 if (retry > 0): print(e.get_trace()) print( "\n\n----------- Test failed! Retrying in 5 seconds... -------------" ) time.sleep(5) else: raise if wan and hasattr(self, 'wan_cleanup'): self.wan_cleanup() if lan and hasattr(self, 'lan_cleanup'): self.lan_cleanup() if wlan and hasattr(self, 'wlan_cleanup'): self.wlan_cleanup() if hasattr(self, 'expected_failure') and self.expected_failure: self.result_grade = "Unexp OK" else: self.result_grade = "OK" self.stop_time = time.time() except unittest2.case.SkipTest: self.stop_time = time.time() self.result_grade = "SKIP" print("\n\n=========== Test skipped! Moving on... =============") raise except Exception as e: self.stop_time = time.time() if hasattr(self, 'expected_failure') and self.expected_failure: self.result_grade = "Exp FAIL" else: self.result_grade = "FAIL" print( "\n\n=========== Test failed! Running recovery Time: %s ===========" % now_short(self._format)) if e.__class__.__name__ == "TIMEOUT": print(e.get_trace()) else: print(e) traceback.print_exc(file=sys.stdout) self.recover() raise