1#!/usr/bin/env python3.4 2# 3# Copyright 2018 - 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 17import itertools 18import time 19 20import acts.base_test 21import acts.signals as signals 22import acts_contrib.test_utils.wifi.wifi_test_utils as wutils 23import acts.utils 24 25from acts import asserts 26from acts.test_decorators import test_tracker_info 27from acts_contrib.test_utils.wifi.WifiBaseTest import WifiBaseTest 28 29WifiEnums = wutils.WifiEnums 30 31DEFAULT_WAIT_TIME = 2 32 33 34class WifiDiagnosticsTest(WifiBaseTest): 35 """ 36 Test Bed Requirement: 37 * One Android device 38 * An open Wi-Fi network. 39 * Verbose logging is on. 40 """ 41 42 def setup_class(self): 43 super().setup_class() 44 45 self.dut = self.android_devices[0] 46 wutils.wifi_test_device_init(self.dut) 47 req_params = [] 48 opt_param = ["open_network"] 49 self.unpack_userparams(req_param_names=req_params, 50 opt_param_names=opt_param) 51 52 if "AccessPoint" in self.user_params: 53 self.legacy_configure_ap_and_start() 54 wutils.wifi_toggle_state(self.dut, True) 55 asserts.assert_true( 56 len(self.open_network) > 0, "Need at least one open network.") 57 self.open_network = self.open_network[0]["2g"] 58 59 def setup_test(self): 60 super().setup_test() 61 self.dut.droid.wakeLockAcquireBright() 62 self.dut.droid.wakeUpNow() 63 64 def teardown_test(self): 65 super().teardown_test() 66 self.dut.droid.wakeLockRelease() 67 self.dut.droid.goToSleepNow() 68 wutils.reset_wifi(self.dut) 69 70 def teardown_class(self): 71 if "AccessPoint" in self.user_params: 72 del self.user_params["open_network"] 73 74 """Tests""" 75 76 @test_tracker_info(uuid="d6f1661b-6732-4939-8c28-f20917774ec0") 77 def test_ringbuffers_are_dumped_during_lsdebug(self): 78 """Steps: 79 1. Connect to a open network. 80 2. Delete old files under data/vendor/tombstones/wifi 81 3. Call lshal debug on wifi hal component 82 4. Verify that files are created under data/vender/tombstones/wifi 83 """ 84 wutils.connect_to_wifi_network(self.dut, self.open_network) 85 time.sleep(DEFAULT_WAIT_TIME) 86 self.dut.adb.shell("rm data/vendor/tombstones/wifi/*") 87 try: 88 self.dut.adb.shell("lshal debug [email protected]::IWifi") 89 except UnicodeDecodeError: 90 """ Gets this error because adb.shell trys to parse the output to a string 91 but ringbuffer dumps should already be generated """ 92 self.log.info("Unicode decode error occurred, but this is ok") 93 file_count_plus_one = self.dut.adb.shell( 94 "ls -l data/vendor/tombstones/wifi | wc -l") 95 if int(file_count_plus_one) <= 1: 96 raise signals.TestFailure( 97 "Failed to create ringbuffer debug files.") 98