tests: Replace last remaining hwsim_test uses with DATA_TEST

External tool is not needed anymore to run the data connectivity tests
since hostapd test mode now allows the possible bridge or VLAN interface
to be specified.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2014-11-27 14:04:51 +02:00 committed by Jouni Malinen
parent 527d2378ac
commit 1131a1c8d2
6 changed files with 41 additions and 64 deletions

View File

@ -15,14 +15,15 @@ captured through the hwsim0 monitor interface that capture all frames
sent on all channels. wlantest is used to store the frames for sent on all channels. wlantest is used to store the frames for
analysis. Three wpa_supplicant processes are used to control three analysis. Three wpa_supplicant processes are used to control three
virtual radios and one hostapd process is used to dynamically control virtual radios and one hostapd process is used to dynamically control
the other two virtual radios. hwsim_test is used to verify that data the other two virtual radios. wpa_supplicant/hostapd test functionality
connection (both unicast and broadcast) works between two netdevs. is used to verify that data connection (both unicast and broadcast)
works between two netdevs.
The python scripts and tools in this directory control test case The python scripts and tools in this directory control test case
execution. They interact wpa_supplicant and hostapd through control execution. They interact wpa_supplicant and hostapd through control
interfaces to perform the operations. In addition, wlantest_cli and interfaces to perform the operations. In addition, wlantest_cli is used
hwsim_test are used to verify that operations have been performed to verify that operations have been performed correctly and that the
correctly and that the network connection works in the expected way. network connection works in the expected way.
These test cases are run automatically against the hostap.git commits These test cases are run automatically against the hostap.git commits
for regression testing and to help in keeping the hostap.git master for regression testing and to help in keeping the hostap.git master
@ -48,15 +49,13 @@ make hostapd hlr_auc_gw
cd ../wlantest cd ../wlantest
make clean make clean
make make
cd ../mac80211_hwsim/tools
make
Alternatively, the build.sh script here can be used to run these steps Alternatively, the build.sh script here can be used to run these steps
with conditional creation of .config files only if they do not exist. with conditional creation of .config files only if they do not exist.
The test scripts can find the binaries in the locations where they were The test scripts can find the binaries in the locations where they were
built. It is also possible to install hwsim_test and wlantest_cli built. It is also possible to install wlantest_cli somewhere on the path
somewhat on the path to use pre-built tools. to use pre-built tools.
Please note that some of the configuration parameters used to enable Please note that some of the configuration parameters used to enable
more testing coverage may require development packages that may not be more testing coverage may require development packages that may not be

View File

@ -64,10 +64,7 @@ make -j8 hostapd hlr_auc_gw
cd ../wlantest cd ../wlantest
make clean make clean
make -j8 make -j8
cd ../mac80211_hwsim/tools cd ../tests/hwsim/tnc
make clean
make -j8
cd ../../tests/hwsim/tnc
make clean make clean
make -j8 make -j8
cd .. cd ..

View File

@ -12,37 +12,8 @@ logger = logging.getLogger()
from wpasupplicant import WpaSupplicant from wpasupplicant import WpaSupplicant
def test_connectivity_run(ifname1, ifname2, dscp=None, tos=None, max_tries=1): def run_connectivity_test(dev1, dev2, tos, dev1group=False, dev2group=False,
if os.path.isfile("../../mac80211_hwsim/tools/hwsim_test"): ifname1=None, ifname2=None):
hwsim_test = "../../mac80211_hwsim/tools/hwsim_test"
else:
hwsim_test = "hwsim_test"
cmd = ["sudo",
hwsim_test,
ifname1,
ifname2]
if dscp:
cmd.append('-D')
cmd.append(str(dscp))
elif tos:
cmd.append('-t')
cmd.append(str(tos))
success = False
for i in range(0, max_tries):
try:
s = subprocess.check_output(cmd)
logger.debug(s)
success = True
break
except subprocess.CalledProcessError, e:
logger.info("hwsim failed: " + str(e.returncode))
logger.info(e.output)
if i + 1 < max_tries:
time.sleep(1)
if not success:
raise Exception("hwsim_test failed")
def run_connectivity_test(dev1, dev2, tos, dev1group=False, dev2group=False):
addr1 = dev1.own_addr() addr1 = dev1.own_addr()
if not dev1group and isinstance(dev1, WpaSupplicant): if not dev1group and isinstance(dev1, WpaSupplicant):
addr1 = dev1.get_driver_status_field('addr') addr1 = dev1.get_driver_status_field('addr')
@ -53,6 +24,8 @@ def run_connectivity_test(dev1, dev2, tos, dev1group=False, dev2group=False):
try: try:
cmd = "DATA_TEST_CONFIG 1" cmd = "DATA_TEST_CONFIG 1"
if ifname1:
cmd = cmd + " ifname=" + ifname1
if dev1group: if dev1group:
res = dev1.group_request(cmd) res = dev1.group_request(cmd)
else: else:
@ -60,6 +33,9 @@ def run_connectivity_test(dev1, dev2, tos, dev1group=False, dev2group=False):
if "OK" not in res: if "OK" not in res:
raise Exception("Failed to enable data test functionality") raise Exception("Failed to enable data test functionality")
cmd = "DATA_TEST_CONFIG 1"
if ifname2:
cmd = cmd + " ifname=" + ifname2
if dev2group: if dev2group:
res = dev2.group_request(cmd) res = dev2.group_request(cmd)
else: else:
@ -132,7 +108,9 @@ def run_connectivity_test(dev1, dev2, tos, dev1group=False, dev2group=False):
else: else:
dev2.request("DATA_TEST_CONFIG 0") dev2.request("DATA_TEST_CONFIG 0")
def test_connectivity(dev1, dev2, dscp=None, tos=None, max_tries=1, dev1group=False, dev2group=False): def test_connectivity(dev1, dev2, dscp=None, tos=None, max_tries=1,
dev1group=False, dev2group=False,
ifname1=None, ifname2=None):
if dscp: if dscp:
tos = dscp << 2 tos = dscp << 2
if not tos: if not tos:
@ -142,7 +120,8 @@ def test_connectivity(dev1, dev2, dscp=None, tos=None, max_tries=1, dev1group=Fa
last_err = None last_err = None
for i in range(0, max_tries): for i in range(0, max_tries):
try: try:
run_connectivity_test(dev1, dev2, tos, dev1group, dev2group) run_connectivity_test(dev1, dev2, tos, dev1group, dev2group,
ifname1, ifname2)
success = True success = True
break break
except Exception, e: except Exception, e:
@ -152,9 +131,10 @@ def test_connectivity(dev1, dev2, dscp=None, tos=None, max_tries=1, dev1group=Fa
if not success: if not success:
raise Exception(last_err) raise Exception(last_err)
def test_connectivity_iface(dev1, ifname, dscp=None, tos=None, max_tries=1): def test_connectivity_iface(dev1, dev2, ifname, dscp=None, tos=None,
test_connectivity_run(dev1.ifname, ifname, dscp=dscp, tos=tos, max_tries=1):
max_tries=max_tries) test_connectivity(dev1, dev2, dscp, tos, ifname2=ifname,
max_tries=max_tries)
def test_connectivity_p2p(dev1, dev2, dscp=None, tos=None): def test_connectivity_p2p(dev1, dev2, dscp=None, tos=None):
test_connectivity(dev1, dev2, dscp, tos, dev1group=True, dev2group=True) test_connectivity(dev1, dev2, dscp, tos, dev1group=True, dev2group=True)

View File

@ -115,7 +115,7 @@ def test_ap_wds_sta(dev, apdev):
params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
params['wds_sta'] = "1" params['wds_sta'] = "1"
params['wds_bridge'] = "wds-br0" params['wds_bridge'] = "wds-br0"
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
try: try:
subprocess.call(['sudo', 'brctl', 'addbr', 'wds-br0']) subprocess.call(['sudo', 'brctl', 'addbr', 'wds-br0'])
@ -123,7 +123,8 @@ def test_ap_wds_sta(dev, apdev):
subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', 'wds-br0', 'up']) subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', 'wds-br0', 'up'])
subprocess.call(['sudo', 'iw', dev[0].ifname, 'set', '4addr', 'on']) subprocess.call(['sudo', 'iw', dev[0].ifname, 'set', '4addr', 'on'])
dev[0].connect(ssid, psk=passphrase, scan_freq="2412") dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
hwsim_utils.test_connectivity_iface(dev[0], "wds-br0", max_tries=15) hwsim_utils.test_connectivity_iface(dev[0], hapd, "wds-br0",
max_tries=15)
finally: finally:
subprocess.call(['sudo', 'iw', dev[0].ifname, 'set', '4addr', 'off']) subprocess.call(['sudo', 'iw', dev[0].ifname, 'set', '4addr', 'off'])
subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', 'wds-br0', 'down']) subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', 'wds-br0', 'down'])

View File

@ -298,7 +298,7 @@ def test_ap_wpa2_tdls_bssid_mismatch(dev, apdev):
passphrase = "12345678" passphrase = "12345678"
params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
params['bridge'] = 'ap-br0' params['bridge'] = 'ap-br0'
hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
hostapd.add_ap(apdev[1]['ifname'], params) hostapd.add_ap(apdev[1]['ifname'], params)
wlantest_setup() wlantest_setup()
subprocess.call(['sudo', 'brctl', 'setfd', 'ap-br0', '0']) subprocess.call(['sudo', 'brctl', 'setfd', 'ap-br0', '0'])
@ -308,8 +308,8 @@ def test_ap_wpa2_tdls_bssid_mismatch(dev, apdev):
dev[1].connect(ssid, psk=passphrase, scan_freq="2412", dev[1].connect(ssid, psk=passphrase, scan_freq="2412",
bssid=apdev[1]['bssid']) bssid=apdev[1]['bssid'])
hwsim_utils.test_connectivity_sta(dev[0], dev[1]) hwsim_utils.test_connectivity_sta(dev[0], dev[1])
hwsim_utils.test_connectivity_iface(dev[0], "ap-br0") hwsim_utils.test_connectivity_iface(dev[0], hapd, "ap-br0")
hwsim_utils.test_connectivity_iface(dev[1], "ap-br0") hwsim_utils.test_connectivity_iface(dev[1], hapd, "ap-br0")
addr0 = dev[0].p2p_interface_addr() addr0 = dev[0].p2p_interface_addr()
dev[1].tdls_setup(addr0) dev[1].tdls_setup(addr0)

View File

@ -24,8 +24,8 @@ def test_ap_vlan_open(dev, apdev):
dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412") dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
dev[1].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412") dev[1].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
dev[2].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412") dev[2].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
hwsim_utils.test_connectivity_iface(dev[0], "brvlan1") hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1")
hwsim_utils.test_connectivity_iface(dev[1], "brvlan2") hwsim_utils.test_connectivity_iface(dev[1], hapd, "brvlan2")
hwsim_utils.test_connectivity(dev[2], hapd) hwsim_utils.test_connectivity(dev[2], hapd)
def test_ap_vlan_file_open(dev, apdev): def test_ap_vlan_file_open(dev, apdev):
@ -39,8 +39,8 @@ def test_ap_vlan_file_open(dev, apdev):
dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412") dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
dev[1].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412") dev[1].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
dev[2].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412") dev[2].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
hwsim_utils.test_connectivity_iface(dev[0], "brvlan1") hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1")
hwsim_utils.test_connectivity_iface(dev[1], "brvlan2") hwsim_utils.test_connectivity_iface(dev[1], hapd, "brvlan2")
hwsim_utils.test_connectivity(dev[2], hapd) hwsim_utils.test_connectivity(dev[2], hapd)
def test_ap_vlan_wpa2(dev, apdev): def test_ap_vlan_wpa2(dev, apdev):
@ -54,8 +54,8 @@ def test_ap_vlan_wpa2(dev, apdev):
dev[0].connect("test-vlan", psk="12345678", scan_freq="2412") dev[0].connect("test-vlan", psk="12345678", scan_freq="2412")
dev[1].connect("test-vlan", psk="12345678", scan_freq="2412") dev[1].connect("test-vlan", psk="12345678", scan_freq="2412")
dev[2].connect("test-vlan", psk="12345678", scan_freq="2412") dev[2].connect("test-vlan", psk="12345678", scan_freq="2412")
hwsim_utils.test_connectivity_iface(dev[0], "brvlan1") hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1")
hwsim_utils.test_connectivity_iface(dev[1], "brvlan2") hwsim_utils.test_connectivity_iface(dev[1], hapd, "brvlan2")
hwsim_utils.test_connectivity(dev[2], hapd) hwsim_utils.test_connectivity(dev[2], hapd)
def test_ap_vlan_wpa2_radius(dev, apdev): def test_ap_vlan_wpa2_radius(dev, apdev):
@ -76,8 +76,8 @@ def test_ap_vlan_wpa2_radius(dev, apdev):
identity="pax.user@example.com", identity="pax.user@example.com",
password_hex="0123456789abcdef0123456789abcdef", password_hex="0123456789abcdef0123456789abcdef",
scan_freq="2412") scan_freq="2412")
hwsim_utils.test_connectivity_iface(dev[0], "brvlan1") hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1")
hwsim_utils.test_connectivity_iface(dev[1], "brvlan2") hwsim_utils.test_connectivity_iface(dev[1], hapd, "brvlan2")
hwsim_utils.test_connectivity(dev[2], hapd) hwsim_utils.test_connectivity(dev[2], hapd)
def test_ap_vlan_wpa2_radius_required(dev, apdev): def test_ap_vlan_wpa2_radius_required(dev, apdev):
@ -112,6 +112,6 @@ def test_ap_vlan_tagged(dev, apdev):
dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412") dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
dev[1].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412") dev[1].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
dev[2].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412") dev[2].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
hwsim_utils.test_connectivity_iface(dev[0], "brlo.1") hwsim_utils.test_connectivity_iface(dev[0], hapd, "brlo.1")
hwsim_utils.test_connectivity_iface(dev[1], "brlo.2") hwsim_utils.test_connectivity_iface(dev[1], hapd, "brlo.2")
hwsim_utils.test_connectivity(dev[2], hapd) hwsim_utils.test_connectivity(dev[2], hapd)