2013-03-02 11:22:28 +01:00
|
|
|
#!/usr/bin/python
|
|
|
|
#
|
|
|
|
# hwsim testing utilities
|
|
|
|
# Copyright (c) 2013, Jouni Malinen <j@w1.fi>
|
|
|
|
#
|
|
|
|
# This software may be distributed under the terms of the BSD license.
|
|
|
|
# See README for more details.
|
|
|
|
|
2013-05-11 10:34:49 +02:00
|
|
|
import os
|
2013-03-02 11:22:28 +01:00
|
|
|
import subprocess
|
|
|
|
import logging
|
2013-10-31 11:46:42 +01:00
|
|
|
logger = logging.getLogger()
|
2013-03-02 11:22:28 +01:00
|
|
|
|
|
|
|
def test_connectivity(ifname1, ifname2):
|
2013-05-11 10:34:49 +02:00
|
|
|
if os.path.isfile("../../mac80211_hwsim/tools/hwsim_test"):
|
|
|
|
hwsim_test = "../../mac80211_hwsim/tools/hwsim_test"
|
|
|
|
else:
|
|
|
|
hwsim_test = "hwsim_test"
|
2013-03-02 11:22:28 +01:00
|
|
|
cmd = ["sudo",
|
2013-05-11 10:34:49 +02:00
|
|
|
hwsim_test,
|
2013-03-02 11:22:28 +01:00
|
|
|
ifname1,
|
|
|
|
ifname2]
|
|
|
|
try:
|
|
|
|
s = subprocess.check_output(cmd)
|
|
|
|
logger.debug(s)
|
|
|
|
except subprocess.CalledProcessError, e:
|
2013-08-24 18:48:04 +02:00
|
|
|
logger.info("hwsim failed: " + str(e.returncode))
|
|
|
|
logger.info(e.output)
|
2013-03-02 11:22:28 +01:00
|
|
|
raise
|
|
|
|
|
|
|
|
def test_connectivity_p2p(dev1, dev2):
|
2013-03-09 16:34:08 +01:00
|
|
|
ifname1 = dev1.group_ifname if dev1.group_ifname else dev1.ifname
|
|
|
|
ifname2 = dev2.group_ifname if dev2.group_ifname else dev2.ifname
|
|
|
|
test_connectivity(ifname1, ifname2)
|
2013-03-27 12:57:48 +01:00
|
|
|
|
2013-09-01 10:56:55 +02:00
|
|
|
def test_connectivity_p2p_sta(dev1, dev2):
|
|
|
|
ifname1 = dev1.group_ifname if dev1.group_ifname else dev1.ifname
|
|
|
|
ifname2 = dev2.ifname
|
|
|
|
test_connectivity(ifname1, ifname2)
|
|
|
|
|
2013-03-27 12:57:48 +01:00
|
|
|
def test_connectivity_sta(dev1, dev2):
|
|
|
|
ifname1 = dev1.ifname
|
|
|
|
ifname2 = dev2.ifname
|
|
|
|
test_connectivity(ifname1, ifname2)
|