2013-03-02 05:22:28 -05: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 04:34:49 -04:00
|
|
|
import os
|
2013-03-02 05:22:28 -05:00
|
|
|
import subprocess
|
|
|
|
import logging
|
2013-10-31 06:46:42 -04:00
|
|
|
logger = logging.getLogger()
|
2013-03-02 05:22:28 -05:00
|
|
|
|
|
|
|
def test_connectivity(ifname1, ifname2):
|
2013-05-11 04:34:49 -04: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 05:22:28 -05:00
|
|
|
cmd = ["sudo",
|
2013-05-11 04:34:49 -04:00
|
|
|
hwsim_test,
|
2013-03-02 05:22:28 -05:00
|
|
|
ifname1,
|
|
|
|
ifname2]
|
|
|
|
try:
|
|
|
|
s = subprocess.check_output(cmd)
|
|
|
|
logger.debug(s)
|
|
|
|
except subprocess.CalledProcessError, e:
|
2013-08-24 12:48:04 -04:00
|
|
|
logger.info("hwsim failed: " + str(e.returncode))
|
|
|
|
logger.info(e.output)
|
2013-03-02 05:22:28 -05:00
|
|
|
raise
|
|
|
|
|
|
|
|
def test_connectivity_p2p(dev1, dev2):
|
2013-03-09 10:34:08 -05: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 07:57:48 -04:00
|
|
|
|
2013-09-01 04:56:55 -04: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 07:57:48 -04:00
|
|
|
def test_connectivity_sta(dev1, dev2):
|
|
|
|
ifname1 = dev1.ifname
|
|
|
|
ifname2 = dev2.ifname
|
|
|
|
test_connectivity(ifname1, ifname2)
|