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 11 12 13class network_WlanDriver(test.test): 14 """ 15 Ensure wireless devices have the expected associated kernel driver. 16 """ 17 version = 1 18 DEVICES = [ 'wlan0', 'mlan0' ] 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 }, 33 'Intel 7265': { 34 '3.8': 'wireless/iwl7000/iwlwifi/iwlwifi.ko', 35 '3.10': 'wireless-3.8/iwl7000/iwlwifi/iwlwifi.ko', 36 '3.14': 'wireless-3.8/iwl7000/iwlwifi/iwlwifi.ko', 37 '3.18': 'wireless/iwl7000/iwlwifi/iwlwifi.ko' 38 }, 39 'Atheros AR9462': { 40 '3.4': 'wireless/ath/ath9k_btcoex/ath9k_btcoex.ko', 41 '3.8': 'wireless-3.4/ath/ath9k_btcoex/ath9k_btcoex.ko' 42 }, 43 'Marvell 88W8797 SDIO': { 44 '3.4': 'wireless/mwifiex/mwifiex_sdio.ko', 45 '3.8': 'wireless-3.4/mwifiex/mwifiex_sdio.ko' 46 }, 47 'Marvell 88W8887 SDIO': { 48 '3.14': 'wireless-3.8/mwifiex/mwifiex_sdio.ko' 49 }, 50 'Marvell 88W8897 PCIE': { 51 '3.8': 'wireless/mwifiex/mwifiex_pcie.ko', 52 '3.10': 'wireless-3.8/mwifiex/mwifiex_pcie.ko' 53 }, 54 'Marvell 88W8897 SDIO': { 55 '3.8': 'wireless/mwifiex/mwifiex_sdio.ko', 56 '3.10': 'wireless-3.8/mwifiex/mwifiex_sdio.ko', 57 '3.14': 'wireless-3.8/mwifiex/mwifiex_sdio.ko' 58 }, 59 'Broadcom BCM4354 SDIO': { 60 '3.8': 'wireless/brcm80211/brcmfmac/brcmfmac.ko', 61 '3.14': 'wireless-3.8/brcm80211/brcmfmac/brcmfmac.ko' 62 }, 63 'Broadcom BCM4356 PCIE': { 64 '3.10': 'wireless-3.8/brcm80211/brcmfmac/brcmfmac.ko' 65 }, 66 } 67 68 69 def run_once(self): 70 """Test main loop""" 71 # full_revision looks like "3.4.0". 72 full_revision = utils.system_output('uname -r') 73 # base_revision looks like "3.4". 74 base_revision = '.'.join(full_revision.split('.')[:2]) 75 logging.info('Kernel base is %s', base_revision) 76 77 found_devices = 0 78 for device in self.DEVICES: 79 net_if = interface.Interface(device) 80 device_description = net_if.device_description 81 82 if not device_description: 83 continue 84 85 device_name, module_path = device_description 86 logging.info('Device name %s, module path %s', 87 device_name, module_path) 88 if not device_name in self.EXPECTED_DRIVER: 89 raise error.TestFail('Unexpected device name %s' % 90 device_name) 91 92 if not base_revision in self.EXPECTED_DRIVER[device_name]: 93 raise error.TestNAError('Unexpected base kernel revision %s ' 94 'with device name %s' % 95 (base_revision, device_name)) 96 97 expected_driver = self.EXPECTED_DRIVER[device_name][base_revision] 98 if module_path != expected_driver: 99 raise error.TestFail('Unexpected driver for %s/%s; ' 100 'got %s but expected %s' % 101 (base_revision, device_name, 102 module_path, expected_driver)) 103 found_devices += 1 104 if not found_devices: 105 raise error.TestNAError('Found no recognized wireless devices?') 106