• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_contrib.test_utils.wifi import wifi_performance_test_utils as wputils
20from acts_contrib.test_utils.wifi import wifi_retail_ap as retail_ap
21from acts_contrib.test_utils.wifi import wifi_test_utils as wutils
22
23
24class WifiPerformancePreflightTest(base_test.BaseTestClass):
25    """Class for Wifi performance preflight tests.
26
27    This class implements WiFi performance tests to perform before any other
28    test suite. Currently, the preflight checklist checks the wifi firmware and
29    config files, i.e., bdf files for any changes by retrieving their version
30    number and checksum.
31    """
32    def __init__(self, controllers):
33        base_test.BaseTestClass.__init__(self, controllers)
34        self.testcase_metric_logger = (
35            BlackboxMappedMetricLogger.for_test_case())
36
37    def setup_class(self):
38        self.dut = self.android_devices[-1]
39        # Initialize AP to ensure that tests can be run in later suites
40        req_params = ['RetailAccessPoints']
41        opt_params = ['bdf', 'firmware']
42        self.unpack_userparams(req_params, opt_params)
43        self.access_point = retail_ap.create(self.RetailAccessPoints)[0]
44        # Load BDF and firmware if needed
45        if hasattr(self, 'bdf'):
46            self.log.info('Pushing WiFi BDF to DUT.')
47            wputils.push_config(self.dut, self.bdf[0])
48        if hasattr(self, 'firmware'):
49            self.log.info('Pushing WiFi firmware to DUT.')
50            wputils.push_firmware(self.dut, self.firmware)
51
52        for ad in self.android_devices:
53            wutils.wifi_toggle_state(ad, True)
54            ad.droid.wifiEnableVerboseLogging(1)
55            try:
56                ad.adb.shell("wpa_cli -i wlan0 -p -g@android:wpa_wlan0 IFNAME="
57                             "wlan0 log_level EXCESSIVE")
58            except:
59                self.log.warning('Could not set log level.')
60
61    def test_wifi_sw_signature(self):
62        sw_signature = wputils.get_sw_signature(self.dut)
63        self.testcase_metric_logger.add_metric(
64            'config_signature', sw_signature['config_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()
73