blob: 7388ad0451c31d728e804262b282c9b347fe0d85 [file] [log] [blame]
# Copyright (c) 2010 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
__author__ = ' (Kelly Lucas)'
import fcntl, socket, struct
from autotest_lib.client.bin import test
from autotest_lib.client.common_lib import error
class network_WlanHasIP(test.test):
Ensure wlan0 has a valid IP address.
version = 1
def get_ip(self, device):
Get the ip address of device. If no IP address is found it will return
None, since socket.inet_ntoa will fail with IOError.
device: string, should be a valid network device name.
string, represents the IP address.
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
ipaddress = socket.inet_ntoa(fcntl.ioctl(
struct.pack('256s', device[:15])
except IOError:
ipaddress = None
return ipaddress
def run_once(self):
WDEV = 'wlan0'
wlanip = self.get_ip(WDEV)
if not wlanip:
raise error.TestFail('%s does not have an assigned IP!' % WDEV)