1# Copyright (c) 2013 The Chromium Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import logging 6 7from autotest_lib.client.bin import test 8from autotest_lib.client.bin import utils 9from autotest_lib.client.common_lib import error 10from autotest_lib.client.common_lib.cros.network import interface 11from autotest_lib.client.cros.networking import shill_proxy 12 13 14class network_WlanDriver(test.test): 15 """ 16 Ensure wireless devices have the expected associated kernel driver. 17 """ 18 version = 1 19 EXPECTED_DRIVER = { 20 'Atheros AR9280': { 21 '3.4': 'wireless/ath/ath9k/ath9k.ko', 22 '3.8': 'wireless-3.4/ath/ath9k/ath9k.ko' 23 }, 24 'Atheros AR9382': { 25 '3.4': 'wireless/ath/ath9k/ath9k.ko', 26 '3.8': 'wireless-3.4/ath/ath9k/ath9k.ko' 27 }, 28 'Intel 7260': { 29 '3.8': 'wireless/iwl7000/iwlwifi/iwlwifi.ko', 30 '3.10': 'wireless-3.8/iwl7000/iwlwifi/iwlwifi.ko', 31 '3.14': 'wireless-3.8/iwl7000/iwlwifi/iwlwifi.ko', 32 '4.4': 'wireless/iwl7000/iwlwifi/iwlwifi.ko' 33 }, 34 'Intel 7265': { 35 '3.8': 'wireless/iwl7000/iwlwifi/iwlwifi.ko', 36 '3.10': 'wireless-3.8/iwl7000/iwlwifi/iwlwifi.ko', 37 '3.14': 'wireless-3.8/iwl7000/iwlwifi/iwlwifi.ko', 38 '3.18': 'wireless/iwl7000/iwlwifi/iwlwifi.ko' 39 }, 40 'Atheros AR9462': { 41 '3.4': 'wireless/ath/ath9k_btcoex/ath9k_btcoex.ko', 42 '3.8': 'wireless-3.4/ath/ath9k_btcoex/ath9k_btcoex.ko' 43 }, 44 'Qualcomm Atheros QCA6174': { 45 '3.18': 'wireless/ar10k/ath/ath10k/ath10k_core.ko', 46 '3.18': 'wireless/ar10k/ath/ath10k/ath10k_pci.ko' 47 }, 48 'Qualcomm Atheros NFA344A/QCA6174': { 49 '3.18': 'wireless/ar10k/ath/ath10k/ath10k_core.ko', 50 '3.18': 'wireless/ar10k/ath/ath10k/ath10k_pci.ko' 51 }, 52 'Marvell 88W8797 SDIO': { 53 '3.4': 'wireless/mwifiex/mwifiex_sdio.ko', 54 '3.8': 'wireless-3.4/mwifiex/mwifiex_sdio.ko' 55 }, 56 'Marvell 88W8887 SDIO': { 57 '3.14': 'wireless-3.8/mwifiex/mwifiex_sdio.ko' 58 }, 59 'Marvell 88W8897 PCIE': { 60 '3.8': 'wireless/mwifiex/mwifiex_pcie.ko', 61 '3.10': 'wireless-3.8/mwifiex/mwifiex_pcie.ko' 62 }, 63 'Marvell 88W8897 SDIO': { 64 '3.8': 'wireless/mwifiex/mwifiex_sdio.ko', 65 '3.10': 'wireless-3.8/mwifiex/mwifiex_sdio.ko', 66 '3.14': 'wireless-3.8/mwifiex/mwifiex_sdio.ko', 67 '3.18': 'wireless/mwifiex/mwifiex_sdio.ko' 68 }, 69 'Broadcom BCM4354 SDIO': { 70 '3.8': 'wireless/brcm80211/brcmfmac/brcmfmac.ko', 71 '3.14': 'wireless-3.8/brcm80211/brcmfmac/brcmfmac.ko' 72 }, 73 'Broadcom BCM4356 PCIE': { 74 '3.10': 'wireless-3.8/brcm80211/brcmfmac/brcmfmac.ko' 75 }, 76 'Marvell 88W8997 PCIE': { 77 '4.4': 'wireless/marvell/mwifiex/mwifiex_pcie.ko', 78 }, 79 } 80 81 82 def run_once(self): 83 """Test main loop""" 84 # full_revision looks like "3.4.0". 85 full_revision = utils.system_output('uname -r') 86 # base_revision looks like "3.4". 87 base_revision = '.'.join(full_revision.split('.')[:2]) 88 logging.info('Kernel base is %s', base_revision) 89 90 proxy = shill_proxy.ShillProxy() 91 device_obj = proxy.find_object('Device', 92 {'Type': proxy.TECHNOLOGY_WIFI}) 93 if device_obj is None: 94 raise error.TestNAError('Found no recognized wireless device') 95 96 device = device_obj.GetProperties()['Interface'] 97 net_if = interface.Interface(device) 98 device_description = net_if.device_description 99 if not device_description: 100 raise error.TestFail('Device %s is not supported' % device) 101 102 device_name, module_path = device_description 103 logging.info('Device name %s, module path %s', device_name, module_path) 104 if not device_name in self.EXPECTED_DRIVER: 105 raise error.TestFail('Unexpected device name %s' % 106 device_name) 107 108 if not base_revision in self.EXPECTED_DRIVER[device_name]: 109 raise error.TestNAError('Unexpected base kernel revision %s with device name %s' % 110 (base_revision, device_name)) 111 112 expected_driver = self.EXPECTED_DRIVER[device_name][base_revision] 113 if module_path != expected_driver: 114 raise error.TestFail('Unexpected driver for %s/%s; got %s but expected %s' % 115 (base_revision, device_name, 116 module_path, expected_driver)) 117