diff options
author | Nathan Harold <nharold@google.com> | 2016-05-03 11:53:34 -0700 |
---|---|---|
committer | Nathan Harold <nharold@google.com> | 2016-05-11 12:54:40 -0700 |
commit | 3a1cedbaad6a715555fdd58939df18e5f1d41c72 (patch) | |
tree | b064da6dd510ba3fefc89581b0b216acbafb2e68 | |
parent | 47dab7f88a6aa985e55c833cad500a5dbedd3dea (diff) | |
download | connectivity-android-n-preview-3.tar.gz |
Update TelephonyBaseTest to fix taking of bug reportsandroid-wear-n-preview-3android-wear-n-preview-1android-n-preview-3
-Take bug reports following both test failures and exceptions.
-Fix a bug where only the first device's bugreport is taken.
-Fix the tombstone-pulling logic to capture unique snapshots
rather than simply overwriting the previous tombstones.
Bug: 28557319
Change-Id: Ia17e60440d819a2072ffec89ae8f5e24baf08d27
-rw-r--r-- | acts/framework/acts/test_utils/tel/TelephonyBaseTest.py | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/acts/framework/acts/test_utils/tel/TelephonyBaseTest.py b/acts/framework/acts/test_utils/tel/TelephonyBaseTest.py index 256e62fb5..0045b60df 100644 --- a/acts/framework/acts/test_utils/tel/TelephonyBaseTest.py +++ b/acts/framework/acts/test_utils/tel/TelephonyBaseTest.py @@ -17,10 +17,12 @@ Base Class for Defining Common Telephony Test Functionality """ +import os import time import traceback from acts.base_test import BaseTestClass from acts.signals import TestSignal +from acts import utils from acts.test_utils.tel.tel_subscription_utils import \ get_subid_from_slot_index @@ -159,22 +161,26 @@ class TelephonyBaseTest(BaseTestClass): def teardown_test(self): return True + def on_exception(self, test_name, begin_time): + return self._take_bug_report(test_name, begin_time) + def on_fail(self, test_name, begin_time): - return True + return self._take_bug_report(test_name, begin_time) - def on_exception(self, test_name, begin_time): - # Since it's a debug flag, as long as it's "set" we consider it valid - if "no_bug_report_on_fail" not in self.user_params: - # magical sleep to ensure the runtime restart or reboot begins - time.sleep(1) - for ad in self.android_devices: - try: - ad.adb.wait_for_device() - ad.take_bug_report(test_name, begin_time) - # TODO: b/25290103 rename tombstone files correctly - # and make support generic and move to - # base_test and utils respectively - ad.adb.pull('/data/tombstones/', self.log_path) - except: - ad.log.error("Failed to take a bug report for {}, {}" - .format(ad.serial, test_name)) + def _take_bug_report(self, test_name, begin_time): + if "no_bug_report_on_fail" in self.user_params: + return + + # magical sleep to ensure the runtime restart or reboot begins + time.sleep(1) + for ad in self.android_devices: + try: + ad.adb.wait_for_device() + ad.take_bug_report(test_name, begin_time) + tombstone_path = os.path.join(ad.log_path, "BugReports", + "{},{}".format(begin_time, ad.serial).replace(' ','_')) + utils.create_dir(tombstone_path) + ad.adb.pull('/data/tombstones/', tombstone_path) + except: + ad.log.error("Failed to take a bug report for {}, {}" + .format(ad.serial, test_name)) |