[WifiSoftApTest] Add cnss diag support to Soft AP tests
Adding cnss diag support for WifiSoftApTest and
WifiStaApConcurrencyTest.
Cherry picked changes from git_master
Bug: 160029496
Test: None
Merged-In: I492173783f18468607a6f8ea6f28f43d8db739a3
Change-Id: Ief91c43d7add3d51fe52e492ec07021d4c65f76b
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 5aaade1..360c301 100755
--- a/acts/framework/acts/test_utils/wifi/wifi_test_utils.py
+++ b/acts/framework/acts/test_utils/wifi/wifi_test_utils.py
@@ -50,6 +50,9 @@
DEFAULT_PING_ADDR = "https://www.google.com/robots.txt"
+CNSS_DIAG_CONFIG_PATH = "/data/vendor/wifi/cnss_diag/"
+CNSS_DIAG_CONFIG_FILE = "cnss_diag.conf"
+
ROAMING_ATTN = {
"AP1_on_AP2_off": [
0,
@@ -2392,37 +2395,50 @@
asserts.fail("Did not find MAC = %s in packet sniffer."
"for device %s" % (mac, ad.serial))
-def start_cnss_diags(ads):
+def start_cnss_diags(ads, cnss_diag_file, pixel_models):
for ad in ads:
- start_cnss_diag(ad)
+ start_cnss_diag(ad, cnss_diag_file, pixel_models)
-def start_cnss_diag(ad):
+def start_cnss_diag(ad, cnss_diag_file, pixel_models):
"""Start cnss_diag to record extra wifi logs
Args:
ad: android device object.
+ cnss_diag_file: cnss diag config file to push to device.
+ pixel_models: pixel devices.
"""
+ if ad.model not in pixel_models:
+ ad.log.info("Device not supported to collect pixel logger")
+ return
if ad.model in wifi_constants.DEVICES_USING_LEGACY_PROP:
prop = wifi_constants.LEGACY_CNSS_DIAG_PROP
else:
prop = wifi_constants.CNSS_DIAG_PROP
if ad.adb.getprop(prop) != 'true':
+ if not int(ad.adb.shell("ls -l %s%s | wc -l" %
+ (CNSS_DIAG_CONFIG_PATH,
+ CNSS_DIAG_CONFIG_FILE))):
+ ad.adb.push("%s %s" % (cnss_diag_file, CNSS_DIAG_CONFIG_PATH))
ad.adb.shell("find /data/vendor/wifi/cnss_diag/wlan_logs/ -type f -delete")
ad.adb.shell("setprop %s true" % prop, ignore_status=True)
-def stop_cnss_diags(ads):
+def stop_cnss_diags(ads, pixel_models):
for ad in ads:
- stop_cnss_diag(ad)
+ stop_cnss_diag(ad, pixel_models)
-def stop_cnss_diag(ad):
+def stop_cnss_diag(ad, pixel_models):
"""Stops cnss_diag
Args:
ad: android device object.
+ pixel_models: pixel devices.
"""
+ if ad.model not in pixel_models:
+ ad.log.info("Device not supported to collect pixel logger")
+ return
if ad.model in wifi_constants.DEVICES_USING_LEGACY_PROP:
prop = wifi_constants.LEGACY_CNSS_DIAG_PROP
else:
diff --git a/acts/tests/google/wifi/WifiSoftApAcsTest.py b/acts/tests/google/wifi/WifiSoftApAcsTest.py
index 22d08b1..49e6428 100644
--- a/acts/tests/google/wifi/WifiSoftApAcsTest.py
+++ b/acts/tests/google/wifi/WifiSoftApAcsTest.py
@@ -15,6 +15,7 @@
# limitations under the License.
import itertools
+import os
import pprint
import queue
import sys
@@ -27,6 +28,7 @@
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
@@ -67,11 +69,19 @@
"Failed to enable WiFi verbose logging on the client dut.")
req_params = []
opt_param = ["iperf_server_address", "reference_networks",
- "iperf_server_port"]
+ "iperf_server_port", "pixel_models"]
self.unpack_userparams(
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):
if hasattr(self, 'packet_capture'):
@@ -81,7 +91,9 @@
self.packet_capture[0].configure_monitor_mode(band, int(chan))
self.pcap_procs = wutils.start_pcap(
self.packet_capture[0], band, self.test_name)
- wutils.start_cnss_diags(self.android_devices)
+ 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()
@@ -91,7 +103,8 @@
wutils.stop_wifi_tethering(self.dut)
wutils.reset_wifi(self.dut)
wutils.reset_wifi(self.dut_client)
- wutils.stop_cnss_diags(self.android_devices)
+ 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
diff --git a/acts/tests/google/wifi/WifiSoftApTest.py b/acts/tests/google/wifi/WifiSoftApTest.py
index 7c7840d..acd4564 100644
--- a/acts/tests/google/wifi/WifiSoftApTest.py
+++ b/acts/tests/google/wifi/WifiSoftApTest.py
@@ -15,12 +15,14 @@
# 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 arduino_test_utils as dutils
from acts.test_utils.net import socket_test_utils as sutils
@@ -46,7 +48,7 @@
"""
self.dut = self.android_devices[0]
self.dut_client = self.android_devices[1]
- req_params = ["dbs_supported_models"]
+ req_params = ["dbs_supported_models", "pixel_models"]
opt_param = ["open_network"]
self.unpack_userparams(
req_param_names=req_params, opt_param_names=opt_param)
@@ -85,6 +87,14 @@
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():
@@ -98,8 +108,13 @@
def setup_test(self):
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)
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)
@@ -107,8 +122,10 @@
wutils.stop_wifi_tethering(self.dut)
def on_fail(self, test_name, begin_time):
- self.dut.take_bug_report(test_name, begin_time)
- self.dut_client.take_bug_report(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):
diff --git a/acts/tests/google/wifi/WifiStaApConcurrencyTest.py b/acts/tests/google/wifi/WifiStaApConcurrencyTest.py
index fc4f69a..bf5b6a3 100644
--- a/acts/tests/google/wifi/WifiStaApConcurrencyTest.py
+++ b/acts/tests/google/wifi/WifiStaApConcurrencyTest.py
@@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import os
import pprint
import time
import re
@@ -21,6 +22,7 @@
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
@@ -69,20 +71,34 @@
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):
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)
# Prevent the stop wifi tethering failure to block ap close
try:
wutils.stop_wifi_tethering(self.dut)
@@ -107,6 +123,7 @@
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 ###