1#!/usr/bin/env python3.4 2# 3# Copyright 2020 - The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the 'License'); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an 'AS IS' BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17from acts import base_test 18from acts.metrics.loggers.blackbox import BlackboxMappedMetricLogger 19from acts.test_utils.wifi import wifi_performance_test_utils as wputils 20from acts.test_utils.wifi import wifi_retail_ap as retail_ap 21 22 23class WifiPerformancePreflightTest(base_test.BaseTestClass): 24 """Class for Wifi performance preflight tests. 25 26 This class implements WiFi performance tests to perform before any other 27 test suite. Currently, the preflight checklist checks the wifi firmware and 28 config files, i.e., bdf files for any changes by retrieving their version 29 number and checksum. 30 """ 31 def __init__(self, controllers): 32 base_test.BaseTestClass.__init__(self, controllers) 33 self.testcase_metric_logger = ( 34 BlackboxMappedMetricLogger.for_test_case()) 35 36 def setup_class(self): 37 self.dut = self.android_devices[-1] 38 # Initialize AP to ensure that tests can be run in later suites 39 req_params = ['RetailAccessPoints'] 40 opt_params = ['bdf', 'firmware'] 41 self.unpack_userparams(req_params, opt_params) 42 self.access_point = retail_ap.create(self.RetailAccessPoints)[0] 43 # Load BDF and firmware if needed 44 if hasattr(self, 'bdf'): 45 self.log.info('Pushing WiFi BDF to DUT.') 46 wputils.push_bdf(self.dut, self.bdf[0]) 47 if hasattr(self, 'firmware'): 48 self.log.info('Pushing WiFi firmware to DUT.') 49 wlanmdsp = [ 50 file for file in self.firmware if "wlanmdsp.mbn" in file 51 ][0] 52 data_msc = [file for file in self.firmware 53 if "Data.msc" in file][0] 54 wputils.push_firmware(self.dut, wlanmdsp, data_msc) 55 56 for ad in self.android_devices: 57 ad.droid.wifiEnableVerboseLogging(1) 58 ad.adb.shell("wpa_cli -i wlan0 -p -g@android:wpa_wlan0 IFNAME=" 59 "wlan0 log_level EXCESSIVE") 60 61 def test_wifi_sw_signature(self): 62 sw_signature = wputils.get_sw_signature(self.dut) 63 self.testcase_metric_logger.add_metric('bdf_signature', 64 sw_signature['bdf_signature']) 65 self.testcase_metric_logger.add_metric('fw_signature', 66 sw_signature['fw_signature']) 67 self.testcase_metric_logger.add_metric('serial_hash', 68 sw_signature['serial_hash']) 69 70 def teardown_class(self): 71 # Teardown AP and release its lockfile 72 self.access_point.teardown()