Collect cnss diag logs when failed for wifi related tests

This CL has below changes:
- Add codes of cnss diag collection for wifi base test classes
  (WifiBaseTest, WifiP2pBaseTest, AwareBaseTest, RttBaseTest)
- Add function calls for wifi test classes to collect cnss diag
  logs when test failed

Bug: 165446308
Test: Run affected tests

Merged-In: I0010055723f4225a91d3d99f1ac2dc1522aaba5b
Change-Id: I600b2a3f897c9f2c04d16e629a01347a108832fb
diff --git a/acts/framework/acts/test_utils/wifi/WifiBaseTest.py b/acts/framework/acts/test_utils/wifi/WifiBaseTest.py
index e79d03e..83a17b5 100644
--- a/acts/framework/acts/test_utils/wifi/WifiBaseTest.py
+++ b/acts/framework/acts/test_utils/wifi/WifiBaseTest.py
@@ -19,6 +19,7 @@
 
 import copy
 import itertools
+import os
 import time
 
 import acts.controllers.access_point as ap
@@ -34,6 +35,8 @@
 from acts.controllers.ap_lib import hostapd_bss_settings
 from acts.controllers.ap_lib import hostapd_constants
 from acts.controllers.ap_lib import hostapd_security
+from acts.keys import Config
+from acts.test_utils.wifi import wifi_test_utils as wutils
 
 AP_1 = 0
 AP_2 = 1
@@ -45,6 +48,40 @@
         if hasattr(self, 'attenuators') and self.attenuators:
             for attenuator in self.attenuators:
                 attenuator.set_atten(0)
+        opt_param = ["pixel_models", "cnss_diag_file"]
+        self.unpack_userparams(opt_param_names=opt_param)
+        if hasattr(self, "cnss_diag_file"):
+            if isinstance(self.cnss_diag_file, list):
+                self.cnss_diag_file = self.cnss_diag_file[0]
+            if not os.path.isfile(self.cnss_diag_file):
+                self.cnss_diag_file = os.path.join(
+                    self.user_params[Config.key_config_path.value],
+                    self.cnss_diag_file)
+
+    def setup_test(self):
+        if (hasattr(self, "android_devices") and
+                hasattr(self, "cnss_diag_file") and
+                hasattr(self, "pixel_models")):
+            wutils.start_cnss_diags(
+                self.android_devices, self.cnss_diag_file, self.pixel_models)
+
+    def teardown_test(self):
+        if (hasattr(self, "android_devices") and
+                hasattr(self, "cnss_diag_file") and
+                hasattr(self, "pixel_models")):
+            wutils.stop_cnss_diags(self.android_devices, self.pixel_models)
+
+    def on_fail(self, test_name, begin_time):
+        if hasattr(self, "android_devices"):
+            for ad in self.android_devices:
+                ad.take_bug_report(test_name, begin_time)
+                ad.cat_adb_log(test_name, begin_time)
+                wutils.get_ssrdumps(ad)
+            if (hasattr(self, "cnss_diag_file") and
+                    hasattr(self, "pixel_models")):
+                wutils.stop_cnss_diags(self.android_devices, self.pixel_models)
+                for ad in self.android_devices:
+                    wutils.get_cnss_diag_log(ad)
 
     def get_psk_network(
             self,
diff --git a/acts/framework/acts/test_utils/wifi/aware/AwareBaseTest.py b/acts/framework/acts/test_utils/wifi/aware/AwareBaseTest.py
index 0bf32ac..901b31f 100644
--- a/acts/framework/acts/test_utils/wifi/aware/AwareBaseTest.py
+++ b/acts/framework/acts/test_utils/wifi/aware/AwareBaseTest.py
@@ -14,9 +14,12 @@
 #   See the License for the specific language governing permissions and
 #   limitations under the License.
 
+import os
+
 from acts import asserts
 from acts import utils
 from acts.base_test import BaseTestClass
+from acts.keys import Config
 from acts.test_utils.wifi import wifi_test_utils as wutils
 from acts.test_utils.wifi.aware import aware_const as aconsts
 from acts.test_utils.wifi.aware import aware_test_utils as autils
@@ -31,11 +34,25 @@
     # at the same time - which can lead to very long clustering times.
     device_startup_offset = 2
 
+    def setup_class(self):
+        opt_param = ["pixel_models", "cnss_diag_file"]
+        self.unpack_userparams(opt_param_names=opt_param)
+        if hasattr(self, "cnss_diag_file"):
+            if isinstance(self.cnss_diag_file, list):
+                self.cnss_diag_file = self.cnss_diag_file[0]
+            if not os.path.isfile(self.cnss_diag_file):
+                self.cnss_diag_file = os.path.join(
+                    self.user_params[Config.key_config_path.value],
+                    self.cnss_diag_file)
+
     def setup_test(self):
         required_params = ("aware_default_power_mode",
                            "dbs_supported_models",)
         self.unpack_userparams(required_params)
 
+        if hasattr(self, "cnss_diag_file") and hasattr(self, "pixel_models"):
+            wutils.start_cnss_diags(
+                self.android_devices, self.cnss_diag_file, self.pixel_models)
         for ad in self.android_devices:
             ad.droid.wifiEnableVerboseLogging(1)
             asserts.skip_if(
@@ -62,6 +79,8 @@
             ad.ed.clear_all_events()
 
     def teardown_test(self):
+        if hasattr(self, "cnss_diag_file") and hasattr(self, "pixel_models"):
+            wutils.stop_cnss_diags(self.android_devices, self.pixel_models)
         for ad in self.android_devices:
             if not ad.droid.doesDeviceSupportWifiAwareFeature():
                 return
@@ -113,3 +132,8 @@
         for ad in self.android_devices:
             ad.take_bug_report(test_name, begin_time)
             ad.cat_adb_log(test_name, begin_time)
+            wutils.get_ssrdumps(ad)
+        if hasattr(self, "cnss_diag_file") and hasattr(self, "pixel_models"):
+            wutils.stop_cnss_diags(self.android_devices, self.pixel_models)
+            for ad in self.android_devices:
+                wutils.get_cnss_diag_log(ad)
diff --git a/acts/framework/acts/test_utils/wifi/p2p/WifiP2pBaseTest.py b/acts/framework/acts/test_utils/wifi/p2p/WifiP2pBaseTest.py
index 1c5a53f..3839e40 100644
--- a/acts/framework/acts/test_utils/wifi/p2p/WifiP2pBaseTest.py
+++ b/acts/framework/acts/test_utils/wifi/p2p/WifiP2pBaseTest.py
@@ -15,12 +15,14 @@
 #   limitations under the License.
 
 import acts.utils
+import os
 import re
 import time
 
 from acts import asserts
 from acts import utils
 from acts.base_test import BaseTestClass
+from acts.keys import Config
 from acts.test_utils.wifi import wifi_test_utils as wutils
 from acts.test_utils.wifi.p2p import wifi_p2p_const as p2pconsts
 
@@ -37,7 +39,8 @@
             ad.droid.wakeLockAcquireBright()
             ad.droid.wakeUpNow()
         required_params = ()
-        optional_params = ("skip_read_factory_mac", )
+        optional_params = (
+                "skip_read_factory_mac", "pixel_models", "cnss_diag_file")
         self.unpack_userparams(required_params,
                                optional_params,
                                skip_read_factory_mac=0)
@@ -84,6 +87,13 @@
                 "DUT3's p2p should be initialized but it didn't")
             self.dut3.name = "Android_" + self.dut3.serial
             self.dut3.droid.wifiP2pSetDeviceName(self.dut3.name)
+        if hasattr(self, "cnss_diag_file"):
+            if isinstance(self.cnss_diag_file, list):
+                self.cnss_diag_file = self.cnss_diag_file[0]
+            if not os.path.isfile(self.cnss_diag_file):
+                self.cnss_diag_file = os.path.join(
+                    self.user_params[Config.key_config_path.value],
+                    self.cnss_diag_file)
 
     def teardown_class(self):
         self.dut1.droid.wifiP2pClose()
@@ -99,10 +109,15 @@
             ad.droid.goToSleepNow()
 
     def setup_test(self):
+        if hasattr(self, "cnss_diag_file") and hasattr(self, "pixel_models"):
+            wutils.start_cnss_diags(
+                self.android_devices, self.cnss_diag_file, self.pixel_models)
         for ad in self.android_devices:
             ad.ed.clear_all_events()
 
     def teardown_test(self):
+        if hasattr(self, "cnss_diag_file") and hasattr(self, "pixel_models"):
+            wutils.stop_cnss_diags(self.android_devices, self.pixel_models)
         for ad in self.android_devices:
             # Clear p2p group info
             ad.droid.wifiP2pRequestPersistentGroupInfo()
@@ -117,6 +132,11 @@
         for ad in self.android_devices:
             ad.take_bug_report(test_name, begin_time)
             ad.cat_adb_log(test_name, begin_time)
+            wutils.get_ssrdumps(ad)
+        if hasattr(self, "cnss_diag_file") and hasattr(self, "pixel_models"):
+            wutils.stop_cnss_diags(self.android_devices, self.pixel_models)
+            for ad in self.android_devices:
+                wutils.get_cnss_diag_log(ad)
 
     def get_p2p_mac_address(self, dut):
         """Gets the current MAC address being used for Wi-Fi Direct."""
diff --git a/acts/framework/acts/test_utils/wifi/rtt/RttBaseTest.py b/acts/framework/acts/test_utils/wifi/rtt/RttBaseTest.py
index 5a7dcda..00118e2 100644
--- a/acts/framework/acts/test_utils/wifi/rtt/RttBaseTest.py
+++ b/acts/framework/acts/test_utils/wifi/rtt/RttBaseTest.py
@@ -14,15 +14,30 @@
 #   See the License for the specific language governing permissions and
 #   limitations under the License.
 
+import os
+
 from acts import asserts
 from acts import utils
 from acts.base_test import BaseTestClass
+from acts.keys import Config
 from acts.test_utils.wifi import wifi_test_utils as wutils
 from acts.test_utils.wifi.rtt import rtt_const as rconsts
 from acts.test_utils.wifi.rtt import rtt_test_utils as rutils
 
 
 class RttBaseTest(BaseTestClass):
+
+    def setup_class(self):
+        opt_param = ["pixel_models", "cnss_diag_file"]
+        self.unpack_userparams(opt_param_names=opt_param)
+        if hasattr(self, "cnss_diag_file"):
+            if isinstance(self.cnss_diag_file, list):
+                self.cnss_diag_file = self.cnss_diag_file[0]
+            if not os.path.isfile(self.cnss_diag_file):
+                self.cnss_diag_file = os.path.join(
+                    self.user_params[Config.key_config_path.value],
+                    self.cnss_diag_file)
+
     def setup_test(self):
         required_params = ("lci_reference", "lcr_reference",
                            "rtt_reference_distance_mm",
@@ -38,6 +53,9 @@
         self.rtt_max_margin_exceeded_rate_one_sided_rtt_percentage = 50
         self.rtt_min_expected_rssi_dbm = -100
 
+        if hasattr(self, "cnss_diag_file") and hasattr(self, "pixel_models"):
+            wutils.start_cnss_diags(
+                self.android_devices, self.cnss_diag_file, self.pixel_models)
         for ad in self.android_devices:
             utils.set_location_service(ad, True)
             ad.droid.wifiEnableVerboseLogging(1)
@@ -55,6 +73,8 @@
             ad.rtt_capabilities = rutils.get_rtt_capabilities(ad)
 
     def teardown_test(self):
+        if hasattr(self, "cnss_diag_file") and hasattr(self, "pixel_models"):
+            wutils.stop_cnss_diags(self.android_devices, self.pixel_models)
         for ad in self.android_devices:
             if not ad.droid.doesDeviceSupportWifiRttFeature():
                 return
@@ -66,3 +86,8 @@
         for ad in self.android_devices:
             ad.take_bug_report(test_name, begin_time)
             ad.cat_adb_log(test_name, begin_time)
+            wutils.get_ssrdumps(ad)
+        if hasattr(self, "cnss_diag_file") and hasattr(self, "pixel_models"):
+            wutils.stop_cnss_diags(self.android_devices, self.pixel_models)
+            for ad in self.android_devices:
+                wutils.get_cnss_diag_log(ad)
diff --git a/acts/framework/acts/test_utils/wifi/wifi_test_utils.py b/acts/framework/acts/test_utils/wifi/wifi_test_utils.py
index 360c301..a55cfce 100755
--- a/acts/framework/acts/test_utils/wifi/wifi_test_utils.py
+++ b/acts/framework/acts/test_utils/wifi/wifi_test_utils.py
@@ -2308,7 +2308,7 @@
 
 
 
-def get_ssrdumps(ad, test_name=""):
+def get_ssrdumps(ad):
     """Pulls dumps in the ssrdump dir
     Args:
         ad: android device object.
@@ -2317,8 +2317,7 @@
     logs = ad.get_file_names("/data/vendor/ssrdump/")
     if logs:
         ad.log.info("Pulling ssrdumps %s", logs)
-        log_path = os.path.join(ad.log_path, test_name,
-                                "SSRDUMP_%s" % ad.serial)
+        log_path = os.path.join(ad.device_log_path, "SSRDUMPS_%s" % ad.serial)
         os.makedirs(log_path, exist_ok=True)
         ad.pull_files(logs, log_path)
     ad.adb.shell("find /data/vendor/ssrdump/ -type f -delete")
@@ -2446,11 +2445,10 @@
     ad.adb.shell("setprop %s false" % prop, ignore_status=True)
 
 
-def get_cnss_diag_log(ad, test_name=""):
+def get_cnss_diag_log(ad):
     """Pulls the cnss_diag logs in the wlan_logs dir
     Args:
         ad: android device object.
-        test_name: test case name
     """
     logs = ad.get_file_names("/data/vendor/wifi/cnss_diag/wlan_logs/")
     if logs:
diff --git a/acts/tests/google/wifi/WifiAutoUpdateTest.py b/acts/tests/google/wifi/WifiAutoUpdateTest.py
index 4ce81d9..7e3b12d 100755
--- a/acts/tests/google/wifi/WifiAutoUpdateTest.py
+++ b/acts/tests/google/wifi/WifiAutoUpdateTest.py
@@ -98,17 +98,15 @@
                 "Failed up apply OTA update. Aborting tests: %s" % e)
 
     def setup_test(self):
+        super().setup_test(self)
         self.dut.droid.wakeLockAcquireBright()
         self.dut.droid.wakeUpNow()
 
     def teardown_test(self):
+        super().setup_teardown_test()
         self.dut.droid.wakeLockRelease()
         self.dut.droid.goToSleepNow()
 
-    def on_fail(self, test_name, begin_time):
-        self.dut.take_bug_report(test_name, begin_time)
-        self.dut.cat_adb_log(test_name, begin_time)
-
     def teardown_class(self):
         if "AccessPoint" in self.user_params:
             del self.user_params["reference_networks"]
diff --git a/acts/tests/google/wifi/WifiChannelSwitchStressTest.py b/acts/tests/google/wifi/WifiChannelSwitchStressTest.py
index f76331e..bdba6e1 100644
--- a/acts/tests/google/wifi/WifiChannelSwitchStressTest.py
+++ b/acts/tests/google/wifi/WifiChannelSwitchStressTest.py
@@ -59,6 +59,7 @@
             wutils.set_wifi_country_code(ad, WifiEnums.CountryCode.US)
 
     def setup_test(self):
+        super().setup_test()
         for ad in self.android_devices:
             ad.droid.wakeLockAcquireBright()
             ad.droid.wakeUpNow()
@@ -78,6 +79,7 @@
             WifiEnums.NONE_DFS_5G_FREQUENCIES)
 
     def teardown_test(self):
+        super().teardown_test()
         for ad in self.android_devices:
             ad.droid.wakeLockRelease()
             ad.droid.goToSleepNow()
@@ -92,9 +94,7 @@
             wutils.stop_pcap(self.packet_capture, self.pcap_procs, False)
         except signals.TestFailure:
             pass
-        for ad in self.android_devices:
-            ad.take_bug_report(test_name, begin_time)
-            ad.cat_adb_log(test_name, begin_time)
+        super().on_fail(test_name, begin_time)
 
     def check_cell_data_and_enable(self):
         """Make sure that cell data is enabled if there is a sim present.
diff --git a/acts/tests/google/wifi/WifiChaosTest.py b/acts/tests/google/wifi/WifiChaosTest.py
index d0a3722..77a83ec 100755
--- a/acts/tests/google/wifi/WifiChaosTest.py
+++ b/acts/tests/google/wifi/WifiChaosTest.py
@@ -112,6 +112,7 @@
         self.randomize_testcases()
 
     def setup_class(self):
+        super().setup_class()
         self.dut = self.android_devices[0]
         self.admin = 'admin' + str(random.randint(1000001, 12345678))
         wutils.wifi_test_device_init(self.dut)
@@ -155,6 +156,7 @@
         return True
 
     def setup_test(self):
+        super().setup_test()
         self.dut.droid.wakeLockAcquireBright()
         self.dut.droid.wakeUpNow()
 
@@ -165,10 +167,10 @@
         # Sleep to ensure all failed packets are captured.
         time.sleep(5)
         wutils.stop_pcap(self.pcap, self.pcap_procs, False)
-        self.dut.take_bug_report(test_name, begin_time)
-        self.dut.cat_adb_log(test_name, begin_time)
+        super().on_fail(test_name, begin_time)
 
     def teardown_test(self):
+        super().teardown_test()
         self.dut.droid.wakeLockRelease()
         self.dut.droid.goToSleepNow()
 
diff --git a/acts/tests/google/wifi/WifiConnectedMacRandomizationTest.py b/acts/tests/google/wifi/WifiConnectedMacRandomizationTest.py
index bd10a8b..14eafab 100644
--- a/acts/tests/google/wifi/WifiConnectedMacRandomizationTest.py
+++ b/acts/tests/google/wifi/WifiConnectedMacRandomizationTest.py
@@ -83,21 +83,19 @@
         self.wpapsk_5g = self.reference_networks[0]["5g"]
 
     def setup_test(self):
+        super().setup_test()
         self.dut.droid.wakeLockAcquireBright()
         self.dut.droid.wakeUpNow()
         wutils.wifi_toggle_state(self.dut, True)
         wutils.wifi_toggle_state(self.dut_softap, False)
 
     def teardown_test(self):
+        super().teardown_test()
         self.dut.droid.wakeLockRelease()
         self.dut.droid.goToSleepNow()
         wutils.reset_wifi(self.dut)
         wutils.reset_wifi(self.dut_softap)
 
-    def on_fail(self, test_name, begin_time):
-        self.dut.take_bug_report(test_name, begin_time)
-        self.dut.cat_adb_log(test_name, begin_time)
-
     def teardown_class(self):
         wutils.stop_wifi_tethering(self.dut_softap)
         self.reset_mac_address_to_factory_mac()
diff --git a/acts/tests/google/wifi/WifiCrashStressTest.py b/acts/tests/google/wifi/WifiCrashStressTest.py
index 837112a..b643bd3 100644
--- a/acts/tests/google/wifi/WifiCrashStressTest.py
+++ b/acts/tests/google/wifi/WifiCrashStressTest.py
@@ -59,6 +59,7 @@
             self.ap_iface = 'wlan1'
 
     def setup_test(self):
+        super().setup_test()
         self.dut.droid.wakeLockAcquireBright()
         self.dut.droid.wakeUpNow()
         wutils.wifi_toggle_state(self.dut, True)
@@ -67,6 +68,7 @@
         wutils.wifi_toggle_state(self.dut_client, True)
 
     def teardown_test(self):
+        super().teardown_test()
         if self.dut.droid.wifiIsApEnabled():
             wutils.stop_wifi_tethering(self.dut)
         self.dut.droid.wakeLockRelease()
@@ -76,12 +78,6 @@
         self.dut_client.droid.goToSleepNow()
         wutils.reset_wifi(self.dut_client)
 
-    def on_fail(self, test_name, begin_time):
-        self.dut.take_bug_report(test_name, begin_time)
-        self.dut.cat_adb_log(test_name, begin_time)
-        self.dut_client.take_bug_report(test_name, begin_time)
-        self.dut_client.cat_adb_log(test_name, begin_time)
-
     def teardown_class(self):
         if "AccessPoint" in self.user_params:
             del self.user_params["reference_networks"]
diff --git a/acts/tests/google/wifi/WifiCrashTest.py b/acts/tests/google/wifi/WifiCrashTest.py
index f76b1ed..e031988 100644
--- a/acts/tests/google/wifi/WifiCrashTest.py
+++ b/acts/tests/google/wifi/WifiCrashTest.py
@@ -64,19 +64,17 @@
         self.network = self.reference_networks[0]["2g"]
 
     def setup_test(self):
+        super().setup_test()
         self.dut.droid.wakeLockAcquireBright()
         self.dut.droid.wakeUpNow()
         wutils.wifi_toggle_state(self.dut, True)
 
     def teardown_test(self):
+        super().teardown_test()
         self.dut.droid.wakeLockRelease()
         self.dut.droid.goToSleepNow()
         wutils.reset_wifi(self.dut)
 
-    def on_fail(self, test_name, begin_time):
-        self.dut.take_bug_report(test_name, begin_time)
-        self.dut.cat_adb_log(test_name, begin_time)
-
     def teardown_class(self):
         if "AccessPoint" in self.user_params:
             del self.user_params["reference_networks"]
diff --git a/acts/tests/google/wifi/WifiDiagnosticsTest.py b/acts/tests/google/wifi/WifiDiagnosticsTest.py
index 8ef24bd..9e5a46f 100644
--- a/acts/tests/google/wifi/WifiDiagnosticsTest.py
+++ b/acts/tests/google/wifi/WifiDiagnosticsTest.py
@@ -60,19 +60,16 @@
         self.open_network = self.open_network[0]["2g"]
 
     def setup_test(self):
+        super().setup_test()
         self.dut.droid.wakeLockAcquireBright()
         self.dut.droid.wakeUpNow()
 
     def teardown_test(self):
+        super().teardown_test()
         self.dut.droid.wakeLockRelease()
         self.dut.droid.goToSleepNow()
         wutils.reset_wifi(self.dut)
 
-
-    def on_fail(self, test_name, begin_time):
-        self.dut.take_bug_report(test_name, begin_time)
-        self.dut.cat_adb_log(test_name, begin_time)
-
     def teardown_class(self):
         if "AccessPoint" in self.user_params:
             del self.user_params["open_network"]
diff --git a/acts/tests/google/wifi/WifiDppTest.py b/acts/tests/google/wifi/WifiDppTest.py
index 36d265e..64f7f25 100644
--- a/acts/tests/google/wifi/WifiDppTest.py
+++ b/acts/tests/google/wifi/WifiDppTest.py
@@ -77,7 +77,7 @@
         Returns:
           True is successfully configured the requirements for testing.
     """
-
+    super().setup_class()
     # Device 0 is under test. Device 1 performs the responder role
     self.dut = self.android_devices[0]
     self.helper_dev = self.android_devices[1]
@@ -132,10 +132,6 @@
   def teardown_class(self):
     wutils.reset_wifi(self.dut)
 
-  def on_fail(self, test_name, begin_time):
-    self.dut.take_bug_report(test_name, begin_time)
-    self.dut.cat_adb_log(test_name, begin_time)
-
   def create_and_save_wifi_network_config(self, security, random_network=False,
                                           r2_auth_error=False):
     """ Create a config with random SSID and password.
diff --git a/acts/tests/google/wifi/WifiEnterpriseRoamingTest.py b/acts/tests/google/wifi/WifiEnterpriseRoamingTest.py
index 0cebd42..e494997 100644
--- a/acts/tests/google/wifi/WifiEnterpriseRoamingTest.py
+++ b/acts/tests/google/wifi/WifiEnterpriseRoamingTest.py
@@ -108,6 +108,7 @@
         self.set_attns("default")
 
     def setup_test(self):
+        super().setup_test()
         self.dut.droid.wifiStartTrackingStateChange()
         self.dut.droid.wakeLockAcquireBright()
         self.dut.droid.wakeUpNow()
@@ -115,15 +116,12 @@
         self.dut.ed.clear_all_events()
 
     def teardown_test(self):
+        super().teardown_test()
         self.dut.droid.wakeLockRelease()
         self.dut.droid.goToSleepNow()
         self.dut.droid.wifiStopTrackingStateChange()
         self.set_attns("default")
 
-    def on_fail(self, test_name, begin_time):
-        self.dut.take_bug_report(test_name, begin_time)
-        self.dut.cat_adb_log(test_name, begin_time)
-
     def set_attns(self, attn_val_name):
         """Sets attenuation values on attenuators used in this test.
 
diff --git a/acts/tests/google/wifi/WifiEnterpriseTest.py b/acts/tests/google/wifi/WifiEnterpriseTest.py
index 20f5e9f..700716d 100644
--- a/acts/tests/google/wifi/WifiEnterpriseTest.py
+++ b/acts/tests/google/wifi/WifiEnterpriseTest.py
@@ -159,6 +159,7 @@
         self.dut.ed.clear_all_events()
 
     def setup_test(self):
+        super().setup_test()
         self.dut.droid.wifiStartTrackingStateChange()
         self.dut.droid.wakeLockAcquireBright()
         self.dut.droid.wakeUpNow()
@@ -167,15 +168,12 @@
         self.tcpdump_pid = start_tcpdump(self.dut, self.test_name)
 
     def teardown_test(self):
+        super().teardown_test()
         stop_tcpdump(self.dut, self.tcpdump_pid, self.test_name)
         self.dut.droid.wakeLockRelease()
         self.dut.droid.goToSleepNow()
         self.dut.droid.wifiStopTrackingStateChange()
 
-    def on_fail(self, test_name, begin_time):
-        self.dut.take_bug_report(test_name, begin_time)
-        self.dut.cat_adb_log(test_name, begin_time)
-
     """Helper Functions"""
 
     def eap_negative_connect_logic(self, config, ad):
diff --git a/acts/tests/google/wifi/WifiHiddenSSIDTest.py b/acts/tests/google/wifi/WifiHiddenSSIDTest.py
index 38f3442..8cb29cd 100644
--- a/acts/tests/google/wifi/WifiHiddenSSIDTest.py
+++ b/acts/tests/google/wifi/WifiHiddenSSIDTest.py
@@ -65,17 +65,15 @@
         self.wpa_hidden_5g = self.reference_networks[0]["5g"]
 
     def setup_test(self):
+        super().setup_test()
         self.dut.droid.wakeLockAcquireBright()
         self.dut.droid.wakeUpNow()
 
     def teardown_test(self):
+        super().teardown_test()
         self.dut.droid.wakeLockRelease()
         self.dut.droid.goToSleepNow()
 
-    def on_fail(self, test_name, begin_time):
-        self.dut.take_bug_report(test_name, begin_time)
-        self.dut.cat_adb_log(test_name, begin_time)
-
     def teardown_class(self):
         wutils.reset_wifi(self.dut)
         if "AccessPoint" in self.user_params:
diff --git a/acts/tests/google/wifi/WifiIFSTwTest.py b/acts/tests/google/wifi/WifiIFSTwTest.py
index 5b1603d..ac2022f 100644
--- a/acts/tests/google/wifi/WifiIFSTwTest.py
+++ b/acts/tests/google/wifi/WifiIFSTwTest.py
@@ -87,6 +87,7 @@
         utils.set_location_service(self.dut, True)
 
     def setup_test(self):
+        super().setup_test()
         self.dut.droid.wakeLockAcquireBright()
         self.dut.droid.wakeUpNow()
         self.dut.unlock_screen()
@@ -96,6 +97,7 @@
         self.dut.ed.clear_all_events()
 
     def teardown_test(self):
+        super().teardown_test()
         self.dut.droid.wakeLockRelease()
         self.dut.droid.goToSleepNow()
         wutils.reset_wifi(self.dut)
diff --git a/acts/tests/google/wifi/WifiIOTTwPkg1Test.py b/acts/tests/google/wifi/WifiIOTTwPkg1Test.py
index c6f8c3d..ed0d8d7 100644
--- a/acts/tests/google/wifi/WifiIOTTwPkg1Test.py
+++ b/acts/tests/google/wifi/WifiIOTTwPkg1Test.py
@@ -88,10 +88,12 @@
             self.pdu_func()
 
     def setup_test(self):
+        super().setup_test()
         self.dut.droid.wakeLockAcquireBright()
         self.dut.droid.wakeUpNow()
 
     def teardown_test(self):
+        super().teardown_test()
         self.dut.droid.wakeLockRelease()
         self.dut.droid.goToSleepNow()
         wutils.reset_wifi(self.dut)
@@ -100,10 +102,6 @@
         if "iperf_server_address" in self.user_params:
             self.iperf_server.stop()
 
-    def on_fail(self, test_name, begin_time):
-        self.dut.take_bug_report(test_name, begin_time)
-        self.dut.cat_adb_log(test_name, begin_time)
-
     """Helper Functions"""
 
     def connect_to_wifi_network(self, network):
diff --git a/acts/tests/google/wifi/WifiIOTtpeTest.py b/acts/tests/google/wifi/WifiIOTtpeTest.py
index fd141ff..3a00d0c 100644
--- a/acts/tests/google/wifi/WifiIOTtpeTest.py
+++ b/acts/tests/google/wifi/WifiIOTtpeTest.py
@@ -67,10 +67,12 @@
             self.ssid_map[SSID] = network
 
     def setup_test(self):
+        super().setup_test()
         self.dut.droid.wakeLockAcquireBright()
         self.dut.droid.wakeUpNow()
 
     def teardown_test(self):
+        super().teardown_test()
         self.dut.droid.wakeLockRelease()
         self.dut.droid.goToSleepNow()
         wutils.reset_wifi(self.dut)
@@ -79,10 +81,6 @@
         if "iperf_server_address" in self.user_params:
             self.iperf_server.stop()
 
-    def on_fail(self, test_name, begin_time):
-        self.dut.take_bug_report(test_name, begin_time)
-        self.dut.cat_adb_log(test_name, begin_time)
-
     """Helper Functions"""
 
     def connect_to_wifi_network(self, network):
diff --git a/acts/tests/google/wifi/WifiLinkProbeTest.py b/acts/tests/google/wifi/WifiLinkProbeTest.py
index d50abde..76af4c0 100644
--- a/acts/tests/google/wifi/WifiLinkProbeTest.py
+++ b/acts/tests/google/wifi/WifiLinkProbeTest.py
@@ -56,6 +56,7 @@
         self.attenuators = wutils.group_attenuators(self.attenuators)
 
     def setup_test(self):
+        super().setup_test()
         self.dut.droid.wakeLockAcquireBright()
         self.dut.droid.wakeUpNow()
         wutils.wifi_toggle_state(self.dut, True)
@@ -65,6 +66,7 @@
             self.packet_capture, 'dual', self.test_name)
 
     def teardown_test(self):
+        super().teardown_test()
         self.dut.droid.wakeLockRelease()
         self.dut.droid.goToSleepNow()
         wutils.reset_wifi(self.dut)
@@ -74,8 +76,7 @@
 
     def on_fail(self, test_name, begin_time):
         wutils.stop_pcap(self.packet_capture, self.pcap_procs, False)
-        self.dut.take_bug_report(test_name, begin_time)
-        self.dut.cat_adb_log(test_name, begin_time)
+        super().on_fail(test_name, begin_time)
 
     def teardown_class(self):
         if "AccessPoint" in self.user_params:
diff --git a/acts/tests/google/wifi/WifiMacRandomizationTest.py b/acts/tests/google/wifi/WifiMacRandomizationTest.py
index aba6035..46fcf42 100644
--- a/acts/tests/google/wifi/WifiMacRandomizationTest.py
+++ b/acts/tests/google/wifi/WifiMacRandomizationTest.py
@@ -107,22 +107,20 @@
         self.open_5g = self.open_network[0]["5g"]
 
     def setup_test(self):
+        super().setup_test()
         for ad in self.android_devices:
             ad.droid.wakeLockAcquireBright()
             ad.droid.wakeUpNow()
             wutils.wifi_toggle_state(ad, True)
 
     def teardown_test(self):
+        super().teardown_test()
         for ad in self.android_devices:
             ad.droid.wakeLockRelease()
             ad.droid.goToSleepNow()
         wutils.reset_wifi(self.dut)
         wutils.reset_wifi(self.dut_client)
 
-    def on_fail(self, test_name, begin_time):
-        self.dut.cat_adb_log(test_name, begin_time)
-        self.dut.take_bug_report(test_name, begin_time)
-
     def teardown_class(self):
         if "AccessPoint" in self.user_params:
             del self.user_params["reference_networks"]
diff --git a/acts/tests/google/wifi/WifiManagerTest.py b/acts/tests/google/wifi/WifiManagerTest.py
index 9d7f8a0..f5702fc 100644
--- a/acts/tests/google/wifi/WifiManagerTest.py
+++ b/acts/tests/google/wifi/WifiManagerTest.py
@@ -84,12 +84,14 @@
         self.open_network_5g = self.open_network[0]["5g"]
 
     def setup_test(self):
+        super().setup_test()
         for ad in self.android_devices:
             ad.droid.wakeLockAcquireBright()
             ad.droid.wakeUpNow()
         wutils.wifi_toggle_state(self.dut, True)
 
     def teardown_test(self):
+        super().teardown_test()
         for ad in self.android_devices:
             ad.droid.wakeLockRelease()
             ad.droid.goToSleepNow()
@@ -100,12 +102,6 @@
         if self.dut_client:
             wutils.reset_wifi(self.dut_client)
 
-    def on_fail(self, test_name, begin_time):
-        self.dut.take_bug_report(test_name, begin_time)
-        self.dut.cat_adb_log(test_name, begin_time)
-        if self.dut_client:
-            self.dut_client.take_bug_report(test_name, begin_time)
-
     def teardown_class(self):
         if "AccessPoint" in self.user_params:
             del self.user_params["reference_networks"]
diff --git a/acts/tests/google/wifi/WifiNetworkRequestTest.py b/acts/tests/google/wifi/WifiNetworkRequestTest.py
index 7a1d8bc..4190de4 100644
--- a/acts/tests/google/wifi/WifiNetworkRequestTest.py
+++ b/acts/tests/google/wifi/WifiNetworkRequestTest.py
@@ -75,6 +75,7 @@
         self.open_5g = self.open_network[0]["5g"]
 
     def setup_test(self):
+        super().setup_test()
         self.dut.droid.wakeLockAcquireBright()
         self.dut.droid.wakeUpNow()
         self.remove_approvals()
@@ -83,6 +84,7 @@
         self.dut.ed.clear_all_events()
 
     def teardown_test(self):
+        super().teardown_test()
         self.dut.droid.wakeLockRelease()
         self.dut.droid.goToSleepNow()
         self.dut.droid.wifiReleaseNetworkAll()
@@ -94,10 +96,6 @@
         wutils.wifi_toggle_state(self.dut, False)
         self.dut.ed.clear_all_events()
 
-    def on_fail(self, test_name, begin_time):
-        self.dut.take_bug_report(test_name, begin_time)
-        self.dut.cat_adb_log(test_name, begin_time)
-
     def teardown_class(self):
         if "AccessPoint" in self.user_params:
             del self.user_params["reference_networks"]
diff --git a/acts/tests/google/wifi/WifiNetworkSelectorTest.py b/acts/tests/google/wifi/WifiNetworkSelectorTest.py
index 41f723c..0e38da8 100644
--- a/acts/tests/google/wifi/WifiNetworkSelectorTest.py
+++ b/acts/tests/google/wifi/WifiNetworkSelectorTest.py
@@ -58,6 +58,7 @@
         self.configure_packet_capture()
 
     def setup_test(self):
+        super().setup_test()
         self.dut.droid.wakeLockAcquireBright()
         self.dut.droid.wakeUpNow()
         self.dut.ed.clear_all_events()
@@ -68,6 +69,7 @@
         time.sleep(ATTN_SLEEP)
 
     def teardown_test(self):
+        super().teardown_test()
         for a in self.attenuators:
             a.set_atten(MIN_ATTN)
         wutils.reset_wifi(self.dut)
@@ -79,8 +81,7 @@
 
     def on_fail(self, test_name, begin_time):
         wutils.stop_pcap(self.packet_capture, self.pcap_procs, False)
-        self.dut.take_bug_report(test_name, begin_time)
-        self.dut.cat_adb_log(test_name, begin_time)
+        super().on_fail(test_name, begin_time)
 
     def teardown_class(self):
         if "AccessPoint" in self.user_params:
diff --git a/acts/tests/google/wifi/WifiNetworkSuggestionTest.py b/acts/tests/google/wifi/WifiNetworkSuggestionTest.py
index b3140c6..dc3eee8 100644
--- a/acts/tests/google/wifi/WifiNetworkSuggestionTest.py
+++ b/acts/tests/google/wifi/WifiNetworkSuggestionTest.py
@@ -98,6 +98,7 @@
             "pm disable com.google.android.apps.carrier.carrierwifi")
 
     def setup_test(self):
+        super().setup_test()
         self.dut.droid.wakeLockAcquireBright()
         self.dut.droid.wakeUpNow()
         self.dut.unlock_screen()
@@ -116,6 +117,7 @@
             self.ent_network_5g = self.ent_networks[0]["5g"]
 
     def teardown_test(self):
+        super().teardown_test()
         self.dut.droid.wakeLockRelease()
         self.dut.droid.goToSleepNow()
         self.dut.droid.wifiRemoveNetworkSuggestions([])
@@ -125,10 +127,6 @@
         self.dut.ed.clear_all_events()
         self.clear_carrier_approved(str(self.dut.droid.telephonyGetSimCarrierId()))
 
-    def on_fail(self, test_name, begin_time):
-        self.dut.take_bug_report(test_name, begin_time)
-        self.dut.cat_adb_log(test_name, begin_time)
-
     def teardown_class(self):
         self.dut.adb.shell(
             "pm enable com.google.android.apps.carrier.carrierwifi")
diff --git a/acts/tests/google/wifi/WifiNewSetupAutoJoinTest.py b/acts/tests/google/wifi/WifiNewSetupAutoJoinTest.py
index b5ba899..e419a96 100644
--- a/acts/tests/google/wifi/WifiNewSetupAutoJoinTest.py
+++ b/acts/tests/google/wifi/WifiNewSetupAutoJoinTest.py
@@ -53,7 +53,7 @@
 
         self.dut = self.android_devices[0]
         wutils.wifi_test_device_init(self.dut)
-        req_params = ("atten_val", "ping_addr", "max_bugreports")
+        req_params = ("atten_val", "ping_addr")
         opt_param = ["reference_networks"]
         self.unpack_userparams(
             req_param_names=req_params, opt_param_names=opt_param)
@@ -140,12 +140,6 @@
             self.dut.droid.wifiLockRelease()
             self.dut.droid.goToSleepNow()
 
-    def on_fail(self, test_name, begin_time):
-        if self.max_bugreports > 0:
-            self.dut.take_bug_report(test_name, begin_time)
-            self.max_bugreports -= 1
-        self.dut.cat_adb_log(test_name, begin_time)
-
     def teardown_class(self):
         for ad in self.android_devices:
             wutils.reset_wifi(ad)
diff --git a/acts/tests/google/wifi/WifiPasspointTest.py b/acts/tests/google/wifi/WifiPasspointTest.py
index 006c243..6bb9266 100755
--- a/acts/tests/google/wifi/WifiPasspointTest.py
+++ b/acts/tests/google/wifi/WifiPasspointTest.py
@@ -19,9 +19,9 @@
 import queue
 import time
 
-import acts.base_test
 from acts.test_utils.net import ui_utils as uutils
 import acts.test_utils.wifi.wifi_test_utils as wutils
+from acts.test_utils.wifi.WifiBaseTest import WifiBaseTest
 
 
 from acts import asserts
@@ -54,7 +54,7 @@
 PASSPOINT_BUTTON = "Get Passpoint"
 BOINGO_UI_TEXT = "Online Sign Up"
 
-class WifiPasspointTest(acts.base_test.BaseTestClass):
+class WifiPasspointTest(WifiBaseTest):
     """Tests for APIs in Android's WifiManager class.
 
     Test Bed Requirement:
@@ -64,6 +64,7 @@
     """
 
     def setup_class(self):
+        super().setup_class()
         self.dut = self.android_devices[0]
         wutils.wifi_test_device_init(self.dut)
         req_params = ["passpoint_networks",
@@ -78,12 +79,14 @@
 
 
     def setup_test(self):
+        super().setup_test()
         self.dut.droid.wakeLockAcquireBright()
         self.dut.droid.wakeUpNow()
         self.dut.unlock_screen()
 
 
     def teardown_test(self):
+        super().teardown_test()
         self.dut.droid.wakeLockRelease()
         self.dut.droid.goToSleepNow()
         passpoint_configs = self.dut.droid.getPasspointConfigs()
@@ -91,11 +94,6 @@
             wutils.delete_passpoint(self.dut, config)
         wutils.reset_wifi(self.dut)
 
-
-    def on_fail(self, test_name, begin_time):
-        self.dut.take_bug_report(test_name, begin_time)
-
-
     """Helper Functions"""
 
 
diff --git a/acts/tests/google/wifi/WifiPnoTest.py b/acts/tests/google/wifi/WifiPnoTest.py
index 4bfa1d7..55655f8 100644
--- a/acts/tests/google/wifi/WifiPnoTest.py
+++ b/acts/tests/google/wifi/WifiPnoTest.py
@@ -49,6 +49,7 @@
         self.set_attns("default")
 
     def setup_test(self):
+        super().setup_test()
         self.dut.droid.wifiStartTrackingStateChange()
         self.dut.droid.wakeLockRelease()
         self.dut.droid.goToSleepNow()
@@ -56,15 +57,12 @@
         self.dut.ed.clear_all_events()
 
     def teardown_test(self):
+        super().teardown_test()
         self.dut.droid.wifiStopTrackingStateChange()
         wutils.reset_wifi(self.dut)
         self.dut.ed.clear_all_events()
         self.set_attns("default")
 
-    def on_fail(self, test_name, begin_time):
-        self.dut.take_bug_report(test_name, begin_time)
-        self.dut.cat_adb_log(test_name, begin_time)
-
     def teardown_class(self):
         if "AccessPoint" in self.user_params:
             del self.user_params["reference_networks"]
diff --git a/acts/tests/google/wifi/WifiRoamingTest.py b/acts/tests/google/wifi/WifiRoamingTest.py
index b0f1a71..3183fa4 100644
--- a/acts/tests/google/wifi/WifiRoamingTest.py
+++ b/acts/tests/google/wifi/WifiRoamingTest.py
@@ -72,21 +72,19 @@
             del self.user_params["open_network"]
 
     def setup_test(self):
+        super().setup_test()
         self.dut.ed.clear_all_events()
         self.dut.droid.wakeLockAcquireBright()
         self.dut.droid.wakeUpNow()
 
     def teardown_test(self):
+        super().teardown_test()
         self.dut.droid.wakeLockRelease()
         self.dut.droid.goToSleepNow()
         wutils.reset_wifi(self.dut)
         for a in self.attenuators:
             a.set_atten(0)
 
-    def on_fail(self, test_name, begin_time):
-        self.dut.cat_adb_log(test_name, begin_time)
-        self.dut.take_bug_report(test_name, begin_time)
-
     def roaming_from_AP1_and_AP2(self, AP1_network, AP2_network):
         """Test roaming between two APs.
 
diff --git a/acts/tests/google/wifi/WifiScannerMultiScanTest.py b/acts/tests/google/wifi/WifiScannerMultiScanTest.py
index 0b4d44e..19e19be 100755
--- a/acts/tests/google/wifi/WifiScannerMultiScanTest.py
+++ b/acts/tests/google/wifi/WifiScannerMultiScanTest.py
@@ -226,7 +226,6 @@
         stime_channels: Dwell time plus 2ms.
         dut: Android device(s).
         wifi_chs: WiFi channels according to the device model.
-        max_bugreports: Max number of bug reports allowed.
     """
 
     def __init__(self, controllers):
@@ -241,11 +240,7 @@
             'test_wifi_scans_24GHz_5GHz_full_result',)
 
     def setup_class(self):
-        # If running in a setup with attenuators, set attenuation on all
-        # channels to zero.
-        if getattr(self, "attenuators", []):
-            for a in self.attenuators:
-                a.set_atten(0)
+        super().setup_class()
         self.leeway = 5  # seconds, for event wait time computation
         self.stime_channel = 47  #dwell time plus 2ms
         self.dut = self.android_devices[0]
@@ -256,10 +251,8 @@
         """ Setup the required dependencies and fetch the user params from
         config file.
         """
-        req_params = ["max_bugreports"]
         opt_param = ["reference_networks"]
-        self.unpack_userparams(
-            req_param_names=req_params, opt_param_names=opt_param)
+        self.unpack_userparams(opt_param_names=opt_param)
 
         if "AccessPoint" in self.user_params:
             self.legacy_configure_ap_and_start()
@@ -268,12 +261,6 @@
 
         self.wifi_chs = WifiChannelUS(self.dut.model)
 
-    def on_fail(self, test_name, begin_time):
-        if self.max_bugreports > 0:
-            self.dut.take_bug_report(test_name, begin_time)
-            self.max_bugreports -= 1
-        self.dut.cat_adb_log(test_name, begin_time)
-
     def teardown_class(self):
         if "AccessPoint" in self.user_params:
             del self.user_params["reference_networks"]
diff --git a/acts/tests/google/wifi/WifiScannerScanTest.py b/acts/tests/google/wifi/WifiScannerScanTest.py
index 89ce0d6..23717ea 100755
--- a/acts/tests/google/wifi/WifiScannerScanTest.py
+++ b/acts/tests/google/wifi/WifiScannerScanTest.py
@@ -20,7 +20,6 @@
 import traceback
 
 from acts import asserts
-from acts import base_test
 from acts import utils
 from acts.test_decorators import test_tracker_info
 from acts.test_utils.wifi import wifi_constants
@@ -71,9 +70,10 @@
             "test_wifi_scanner_dual_radio_high_accuracy")
 
     def setup_class(self):
+        super().setup_class()
         self.dut = self.android_devices[0]
         wutils.wifi_test_device_init(self.dut)
-        req_params = ("run_extended_test", "ping_addr", "max_bugreports", "dbs_supported_models")
+        req_params = ("run_extended_test", "ping_addr", "dbs_supported_models")
         opt_param = ["reference_networks"]
         self.unpack_userparams(
             req_param_names=req_params, opt_param_names=opt_param)
@@ -100,16 +100,10 @@
         self.attenuators[1].set_atten(0)
 
     def teardown_test(self):
-        base_test.BaseTestClass.teardown_test(self)
+        super().teardown_test()
         self.log.debug("Shut down all wifi scanner activities.")
         self.dut.droid.wifiScannerShutdown()
 
-    def on_fail(self, test_name, begin_time):
-        if self.max_bugreports > 0:
-            self.dut.take_bug_report(test_name, begin_time)
-            self.max_bugreports -= 1
-        self.dut.cat_adb_log(test_name, begin_time)
-
     def teardown_class(self):
         if "AccessPoint" in self.user_params:
             del self.user_params["reference_networks"]
diff --git a/acts/tests/google/wifi/WifiServiceApiTest.py b/acts/tests/google/wifi/WifiServiceApiTest.py
index b5eed89..afe2a84 100644
--- a/acts/tests/google/wifi/WifiServiceApiTest.py
+++ b/acts/tests/google/wifi/WifiServiceApiTest.py
@@ -19,15 +19,15 @@
 import sys
 import time
 
-from acts import base_test
 from acts import signals
 from acts import utils
 from acts.test_decorators import test_tracker_info
 from acts.test_utils.wifi import wifi_constants
 from acts.test_utils.wifi import wifi_test_utils as wutils
+from acts.test_utils.wifi.WifiBaseTest import WifiBaseTest
 
 
-class WifiServiceApiTest(base_test.BaseTestClass):
+class WifiServiceApiTest(WifiBaseTest):
     """This class tests the API surface of WifiManager in different wifi states.
 
        Attributes:
@@ -48,6 +48,7 @@
             Returns:
             True is successfully configured the requirements for testig.
         """
+        super().setup_class()
         self.dut = self.android_devices[0]
         # Do a simple version of init - mainly just sync the time and enable
         # verbose logging.  We would also like to test with phones in less
@@ -65,9 +66,6 @@
     def teardown_class(self):
         wutils.reset_wifi(self.dut)
 
-    def on_fail(self, test_name, begin_time):
-        self.dut.take_bug_report(test_name, begin_time)
-
     def create_and_save_wifi_network_config(self):
         """ Create a config with random SSID and password.
 
diff --git a/acts/tests/google/wifi/WifiSoftApAcsTest.py b/acts/tests/google/wifi/WifiSoftApAcsTest.py
index 49e6428..a3cbdfe 100644
--- a/acts/tests/google/wifi/WifiSoftApAcsTest.py
+++ b/acts/tests/google/wifi/WifiSoftApAcsTest.py
@@ -15,7 +15,6 @@
 #   limitations under the License.
 
 import itertools
-import os
 import pprint
 import queue
 import sys
@@ -28,7 +27,6 @@
 
 from acts import asserts
 from acts.controllers.ap_lib import hostapd_constants
-from acts.keys import Config
 from acts.test_decorators import test_tracker_info
 from acts.test_utils.tel.tel_test_utils import WIFI_CONFIG_APBAND_2G
 from acts.test_utils.tel.tel_test_utils import WIFI_CONFIG_APBAND_5G
@@ -74,16 +72,9 @@
             req_param_names=req_params, opt_param_names=opt_param)
         self.chan_map = {v: k for k, v in hostapd_constants.CHANNEL_MAP.items()}
         self.pcap_procs = None
-        if "cnss_diag_file" in self.user_params:
-            self.cnss_diag_file = self.user_params.get("cnss_diag_file")
-            if isinstance(self.cnss_diag_file, list):
-                self.cnss_diag_file = self.cnss_diag_file[0]
-            if not os.path.isfile(self.cnss_diag_file):
-                self.cnss_diag_file = os.path.join(
-                    self.user_params[Config.key_config_path.value],
-                    self.cnss_diag_file)
 
     def setup_test(self):
+        super().setup_test()
         if hasattr(self, 'packet_capture'):
             chan = self.test_name.split('_')[-1]
             if chan.isnumeric():
@@ -91,20 +82,16 @@
                 self.packet_capture[0].configure_monitor_mode(band, int(chan))
                 self.pcap_procs = wutils.start_pcap(
                     self.packet_capture[0], band, self.test_name)
-        if hasattr(self, "cnss_diag_file"):
-            wutils.start_cnss_diags(
-                self.android_devices, self.cnss_diag_file, self.pixel_models)
         self.dut.droid.wakeLockAcquireBright()
         self.dut.droid.wakeUpNow()
 
     def teardown_test(self):
+        super().teardown_test()
         self.dut.droid.wakeLockRelease()
         self.dut.droid.goToSleepNow()
         wutils.stop_wifi_tethering(self.dut)
         wutils.reset_wifi(self.dut)
         wutils.reset_wifi(self.dut_client)
-        if hasattr(self, "cnss_diag_file"):
-            wutils.stop_cnss_diags(self.android_devices, self.pixel_models)
         if hasattr(self, 'packet_capture') and self.pcap_procs:
             wutils.stop_pcap(self.packet_capture[0], self.pcap_procs, False)
             self.pcap_procs = None
@@ -116,11 +103,6 @@
             pass
         self.access_points[0].close()
 
-    def on_fail(self, test_name, begin_time):
-        for ad in self.android_devices:
-            ad.take_bug_report(test_name, begin_time)
-            wutils.get_cnss_diag_log(ad, test_name)
-
     """Helper Functions"""
 
     def run_iperf_client(self, params):
diff --git a/acts/tests/google/wifi/WifiSoftApTest.py b/acts/tests/google/wifi/WifiSoftApTest.py
index 78b1306..8498f26 100644
--- a/acts/tests/google/wifi/WifiSoftApTest.py
+++ b/acts/tests/google/wifi/WifiSoftApTest.py
@@ -15,14 +15,12 @@
 #   limitations under the License.
 
 import logging
-import os
 import queue
 import random
 import time
 
 from acts import asserts
 from acts import utils
-from acts.keys import Config
 from acts.test_decorators import test_tracker_info
 from acts.test_utils.net import socket_test_utils as sutils
 from acts.test_utils.tel import tel_defines
@@ -45,9 +43,10 @@
         Returns:
             True if successfully configured the requirements for testing.
         """
+        super().setup_class()
         self.dut = self.android_devices[0]
         self.dut_client = self.android_devices[1]
-        req_params = ["dbs_supported_models", "pixel_models"]
+        req_params = ["dbs_supported_models"]
         opt_param = ["open_network"]
         self.unpack_userparams(
             req_param_names=req_params, opt_param_names=opt_param)
@@ -86,14 +85,6 @@
             asserts.assert_equal(self.android_devices[2].droid.wifiGetVerboseLoggingLevel(), 1,
                 "Failed to enable WiFi verbose logging on the client dut.")
             self.dut_client_2 = self.android_devices[2]
-        if "cnss_diag_file" in self.user_params:
-            self.cnss_diag_file = self.user_params.get("cnss_diag_file")
-            if isinstance(self.cnss_diag_file, list):
-                self.cnss_diag_file = self.cnss_diag_file[0]
-            if not os.path.isfile(self.cnss_diag_file):
-                self.cnss_diag_file = os.path.join(
-                    self.user_params[Config.key_config_path.value],
-                    self.cnss_diag_file)
 
     def teardown_class(self):
         if self.dut.droid.wifiIsApEnabled():
@@ -105,27 +96,18 @@
             del self.user_params["open_network"]
 
     def setup_test(self):
+        super().setup_test()
         for ad in self.android_devices:
             wutils.wifi_toggle_state(ad, True)
-        if hasattr(self, "cnss_diag_file"):
-            wutils.start_cnss_diags(
-                self.android_devices, self.cnss_diag_file, self.pixel_models)
 
     def teardown_test(self):
-        if hasattr(self, "cnss_diag_file"):
-            wutils.stop_cnss_diags(self.android_devices, self.pixel_models)
+        super().teardown_test()
         self.dut.log.debug("Toggling Airplane mode OFF.")
         asserts.assert_true(utils.force_airplane_mode(self.dut, False),
                             "Can not turn off airplane mode: %s" % self.dut.serial)
         if self.dut.droid.wifiIsApEnabled():
             wutils.stop_wifi_tethering(self.dut)
 
-    def on_fail(self, test_name, begin_time):
-        for ad in self.android_devices:
-            ad.take_bug_report(test_name, begin_time)
-            ad.cat_adb_log(test_name, begin_time)
-            wutils.get_cnss_diag_log(ad, test_name)
-
     """ Helper Functions """
     def create_softap_config(self):
         """Create a softap config with ssid and password."""
diff --git a/acts/tests/google/wifi/WifiStaApConcurrencyTest.py b/acts/tests/google/wifi/WifiStaApConcurrencyTest.py
index bf5b6a3..2a1e67f 100644
--- a/acts/tests/google/wifi/WifiStaApConcurrencyTest.py
+++ b/acts/tests/google/wifi/WifiStaApConcurrencyTest.py
@@ -14,7 +14,6 @@
 #   See the License for the specific language governing permissions and
 #   limitations under the License.
 
-import os
 import pprint
 import time
 import re
@@ -22,7 +21,6 @@
 from acts import asserts
 from acts import base_test
 from acts.controllers.ap_lib import hostapd_constants
-from acts.keys import Config
 import acts.signals as signals
 from acts.test_decorators import test_tracker_info
 from acts.test_utils.tel.tel_test_utils import WIFI_CONFIG_APBAND_2G
@@ -71,34 +69,22 @@
             ad.droid.wifiEnableVerboseLogging(1)
 
         req_params = ["dbs_supported_models",
-                      "pixel_models",
                       "iperf_server_address",
                       "iperf_server_port"]
         self.unpack_userparams(req_param_names=req_params,)
         asserts.abort_class_if(
             self.dut.model not in self.dbs_supported_models,
             "Device %s does not support dual interfaces." % self.dut.model)
-        if "cnss_diag_file" in self.user_params:
-            self.cnss_diag_file = self.user_params.get("cnss_diag_file")
-            if isinstance(self.cnss_diag_file, list):
-                self.cnss_diag_file = self.cnss_diag_file[0]
-            if not os.path.isfile(self.cnss_diag_file):
-                self.cnss_diag_file = os.path.join(
-                    self.user_params[Config.key_config_path.value],
-                    self.cnss_diag_file)
 
     def setup_test(self):
+        super().setup_test()
         for ad in self.android_devices:
             ad.droid.wakeLockAcquireBright()
             ad.droid.wakeUpNow()
         self.turn_location_off_and_scan_toggle_off()
-        if hasattr(self, "cnss_diag_file"):
-            wutils.start_cnss_diags(
-                self.android_devices, self.cnss_diag_file, self.pixel_models)
 
     def teardown_test(self):
-        if hasattr(self, "cnss_diag_file"):
-            wutils.stop_cnss_diags(self.android_devices, self.pixel_models)
+        super().teardown_test()
         # Prevent the stop wifi tethering failure to block ap close
         try:
             wutils.stop_wifi_tethering(self.dut)
@@ -119,12 +105,6 @@
                 self.log.warn("There is no 'reference_network' or "
                               "'open_network' to delete")
 
-    def on_fail(self, test_name, begin_time):
-        for ad in self.android_devices:
-            ad.take_bug_report(test_name, begin_time)
-            ad.cat_adb_log(test_name, begin_time)
-            wutils.get_cnss_diag_log(ad, test_name)
-
     ### Helper Functions ###
 
     def configure_ap(self, channel_2g=None, channel_5g=None):
diff --git a/acts/tests/google/wifi/WifiStressTest.py b/acts/tests/google/wifi/WifiStressTest.py
index e31adbb..317c6c1 100644
--- a/acts/tests/google/wifi/WifiStressTest.py
+++ b/acts/tests/google/wifi/WifiStressTest.py
@@ -79,20 +79,18 @@
         self.networks = [self.wpa_2g, self.wpa_5g, self.open_2g, self.open_5g]
 
     def setup_test(self):
+        super().setup_test()
         self.dut.droid.wakeLockAcquireBright()
         self.dut.droid.wakeUpNow()
 
     def teardown_test(self):
+        super().teardown_test()
         if self.dut.droid.wifiIsApEnabled():
             wutils.stop_wifi_tethering(self.dut)
         self.dut.droid.wakeLockRelease()
         self.dut.droid.goToSleepNow()
         wutils.reset_wifi(self.dut)
 
-    def on_fail(self, test_name, begin_time):
-        self.dut.take_bug_report(test_name, begin_time)
-        self.dut.cat_adb_log(test_name, begin_time)
-
     def teardown_class(self):
         wutils.reset_wifi(self.dut)
         if "AccessPoint" in self.user_params:
diff --git a/acts/tests/google/wifi/WifiTetheringTest.py b/acts/tests/google/wifi/WifiTetheringTest.py
index b1c92cc..af61d8c 100644
--- a/acts/tests/google/wifi/WifiTetheringTest.py
+++ b/acts/tests/google/wifi/WifiTetheringTest.py
@@ -19,7 +19,6 @@
 import time
 
 from acts import asserts
-from acts import base_test
 from acts import test_runner
 from acts import utils
 from acts.controllers import adb
@@ -34,15 +33,16 @@
 from acts.test_utils.net import arduino_test_utils as dutils
 from acts.test_utils.net import net_test_utils as nutils
 from acts.test_utils.wifi import wifi_test_utils as wutils
+from acts.test_utils.wifi.WifiBaseTest import WifiBaseTest
 
 WAIT_TIME = 5
 
-class WifiTetheringTest(base_test.BaseTestClass):
+class WifiTetheringTest(WifiBaseTest):
     """ Tests for Wifi Tethering """
 
     def setup_class(self):
         """ Setup devices for tethering and unpack params """
-
+        super().setup_class()
         self.hotspot_device = self.android_devices[0]
         self.tethered_devices = self.android_devices[1:]
         req_params = ("url", "open_network")
@@ -57,11 +57,13 @@
             wutils.wifi_test_device_init(ad)
 
     def setup_test(self):
+        super().setup_test()
         for ad in self.android_devices:
             self.tcpdump_pid.append(nutils.start_tcpdump(ad, self.test_name))
         self.tethered_devices[0].droid.telephonyToggleDataConnection(False)
 
     def teardown_test(self):
+        super().teardown_test()
         if self.hotspot_device.droid.wifiIsApEnabled():
             wutils.stop_wifi_tethering(self.hotspot_device)
         self.tethered_devices[0].droid.telephonyToggleDataConnection(True)
@@ -75,11 +77,6 @@
         for ad in self.tethered_devices:
             wutils.reset_wifi(ad)
 
-    def on_fail(self, test_name, begin_time):
-        """ Collect bug report on failure """
-        for ad in self.android_devices:
-            ad.take_bug_report(test_name, begin_time)
-
     """ Helper functions """
 
     def _is_ipaddress_ipv6(self, ip_address):
diff --git a/acts/tests/google/wifi/WifiWakeTest.py b/acts/tests/google/wifi/WifiWakeTest.py
index 5a49b54..6c3dd36 100644
--- a/acts/tests/google/wifi/WifiWakeTest.py
+++ b/acts/tests/google/wifi/WifiWakeTest.py
@@ -114,6 +114,7 @@
             self.log.info('Turned AP B on')
 
     def setup_test(self):
+        super().setup_test()
         self.dut.droid.wakeLockAcquireBright()
         self.dut.droid.wakeUpNow()
         self.ap_a_on()
@@ -128,13 +129,10 @@
         self.dut.ed.clear_all_events()
 
     def teardown_test(self):
+        super().teardown_test()
         self.dut.droid.wakeLockRelease()
         self.dut.droid.goToSleepNow()
 
-    def on_fail(self, test_name, begin_time):
-        self.dut.take_bug_report(test_name, begin_time)
-        self.dut.cat_adb_log(test_name, begin_time)
-
     def find_ssid_in_scan_results(self, scan_results_batches, ssid):
         scan_results_batch = scan_results_batches[0]
         scan_results = scan_results_batch["ScanResults"]
diff --git a/acts/tests/google/wifi/WifiWpa3EnterpriseTest.py b/acts/tests/google/wifi/WifiWpa3EnterpriseTest.py
index 8e1395b..5257766 100644
--- a/acts/tests/google/wifi/WifiWpa3EnterpriseTest.py
+++ b/acts/tests/google/wifi/WifiWpa3EnterpriseTest.py
@@ -42,21 +42,19 @@
     self.unpack_userparams(req_param_names=req_params,)
 
   def setup_test(self):
+    super().setup_test()
     for ad in self.android_devices:
       ad.droid.wakeLockAcquireBright()
       ad.droid.wakeUpNow()
     wutils.wifi_toggle_state(self.dut, True)
 
   def teardown_test(self):
+    super().teardown_test()
     for ad in self.android_devices:
       ad.droid.wakeLockRelease()
       ad.droid.goToSleepNow()
     wutils.reset_wifi(self.dut)
 
-  def on_fail(self, test_name, begin_time):
-    self.dut.cat_adb_log(test_name, begin_time)
-    self.dut.take_bug_report(test_name, begin_time)
-
   ### Tests ###
 
   @test_tracker_info(uuid="404c6165-6e23-4ec1-bc2c-9dfdd5c7dc87")
diff --git a/acts/tests/google/wifi/WifiWpa3OweTest.py b/acts/tests/google/wifi/WifiWpa3OweTest.py
index ab0f23d..7cd1903 100644
--- a/acts/tests/google/wifi/WifiWpa3OweTest.py
+++ b/acts/tests/google/wifi/WifiWpa3OweTest.py
@@ -58,22 +58,20 @@
         self.wpa3_personal_5g = self.wpa3_personal[0]["5g"]
 
     def setup_test(self):
+        super().setup_test()
         for ad in self.android_devices:
             ad.droid.wakeLockAcquireBright()
             ad.droid.wakeUpNow()
             wutils.wifi_toggle_state(ad, True)
 
     def teardown_test(self):
+        super().teardown_test()
         for ad in self.android_devices:
             ad.droid.wakeLockRelease()
             ad.droid.goToSleepNow()
         wutils.reset_wifi(self.dut)
         wutils.reset_wifi(self.dut_client)
 
-    def on_fail(self, test_name, begin_time):
-        self.dut.cat_adb_log(test_name, begin_time)
-        self.dut.take_bug_report(test_name, begin_time)
-
     """Helper Functions"""
 
     """Tests"""