tests: Convert test skipping to use exception

Instead of returning "skip" from the test function, raise the new
HwsimSkip exception to indicate a test case was skipped.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2015-01-07 14:19:30 +02:00
parent 9c8779daf6
commit 81e787b750
26 changed files with 164 additions and 321 deletions

View file

@ -433,15 +433,12 @@ def main():
params = {} params = {}
params['logdir'] = args.logdir params['logdir'] = args.logdir
params['long'] = args.long params['long'] = args.long
res = t(dev, apdev, params) t(dev, apdev, params)
elif t.func_code.co_argcount > 1: elif t.func_code.co_argcount > 1:
res = t(dev, apdev) t(dev, apdev)
else: else:
res = t(dev) t(dev)
if res == "skip": result = "PASS"
result = "SKIP"
else:
result = "PASS"
except HwsimSkip, e: except HwsimSkip, e:
logger.info("Skip test case: %s" % e) logger.info("Skip test case: %s" % e)
result = "SKIP" result = "SKIP"

View file

@ -11,10 +11,11 @@ import os.path
import hwsim_utils import hwsim_utils
import hostapd import hostapd
from utils import HwsimSkip
def check_cipher(dev, ap, cipher): def check_cipher(dev, ap, cipher):
if cipher not in dev.get_capability("pairwise"): if cipher not in dev.get_capability("pairwise"):
return "skip" raise HwsimSkip("Cipher %s not supported" % cipher)
params = { "ssid": "test-wpa2-psk", params = { "ssid": "test-wpa2-psk",
"wpa_passphrase": "12345678", "wpa_passphrase": "12345678",
"wpa": "2", "wpa": "2",
@ -27,13 +28,13 @@ def check_cipher(dev, ap, cipher):
def test_ap_cipher_tkip(dev, apdev): def test_ap_cipher_tkip(dev, apdev):
"""WPA2-PSK/TKIP connection""" """WPA2-PSK/TKIP connection"""
return check_cipher(dev[0], apdev[0], "TKIP") check_cipher(dev[0], apdev[0], "TKIP")
def test_ap_cipher_tkip_countermeasures_ap(dev, apdev): def test_ap_cipher_tkip_countermeasures_ap(dev, apdev):
"""WPA-PSK/TKIP countermeasures (detected by AP)""" """WPA-PSK/TKIP countermeasures (detected by AP)"""
testfile = "/sys/kernel/debug/ieee80211/%s/netdev:%s/tkip_mic_test" % (dev[0].get_driver_status_field("phyname"), dev[0].ifname) testfile = "/sys/kernel/debug/ieee80211/%s/netdev:%s/tkip_mic_test" % (dev[0].get_driver_status_field("phyname"), dev[0].ifname)
if not os.path.exists(testfile): if not os.path.exists(testfile):
return "skip" raise HwsimSkip("tkip_mic_test not supported in mac80211")
params = { "ssid": "tkip-countermeasures", params = { "ssid": "tkip-countermeasures",
"wpa_passphrase": "12345678", "wpa_passphrase": "12345678",
@ -73,7 +74,7 @@ def test_ap_cipher_tkip_countermeasures_sta(dev, apdev):
testfile = "/sys/kernel/debug/ieee80211/%s/netdev:%s/tkip_mic_test" % (hapd.get_driver_status_field("phyname"), apdev[0]['ifname']) testfile = "/sys/kernel/debug/ieee80211/%s/netdev:%s/tkip_mic_test" % (hapd.get_driver_status_field("phyname"), apdev[0]['ifname'])
if not os.path.exists(testfile): if not os.path.exists(testfile):
return "skip" raise HwsimSkip("tkip_mic_test not supported in mac80211")
dev[0].connect("tkip-countermeasures", psk="12345678", dev[0].connect("tkip-countermeasures", psk="12345678",
pairwise="TKIP", group="TKIP", scan_freq="2412") pairwise="TKIP", group="TKIP", scan_freq="2412")
@ -97,19 +98,19 @@ def test_ap_cipher_tkip_countermeasures_sta(dev, apdev):
def test_ap_cipher_ccmp(dev, apdev): def test_ap_cipher_ccmp(dev, apdev):
"""WPA2-PSK/CCMP connection""" """WPA2-PSK/CCMP connection"""
return check_cipher(dev[0], apdev[0], "CCMP") check_cipher(dev[0], apdev[0], "CCMP")
def test_ap_cipher_gcmp(dev, apdev): def test_ap_cipher_gcmp(dev, apdev):
"""WPA2-PSK/GCMP connection""" """WPA2-PSK/GCMP connection"""
return check_cipher(dev[0], apdev[0], "GCMP") check_cipher(dev[0], apdev[0], "GCMP")
def test_ap_cipher_ccmp_256(dev, apdev): def test_ap_cipher_ccmp_256(dev, apdev):
"""WPA2-PSK/CCMP-256 connection""" """WPA2-PSK/CCMP-256 connection"""
return check_cipher(dev[0], apdev[0], "CCMP-256") check_cipher(dev[0], apdev[0], "CCMP-256")
def test_ap_cipher_gcmp_256(dev, apdev): def test_ap_cipher_gcmp_256(dev, apdev):
"""WPA2-PSK/GCMP-256 connection""" """WPA2-PSK/GCMP-256 connection"""
return check_cipher(dev[0], apdev[0], "GCMP-256") check_cipher(dev[0], apdev[0], "GCMP-256")
def test_ap_cipher_mixed_wpa_wpa2(dev, apdev): def test_ap_cipher_mixed_wpa_wpa2(dev, apdev):
"""WPA2-PSK/CCMP/ and WPA-PSK/TKIP mixed configuration""" """WPA2-PSK/CCMP/ and WPA-PSK/TKIP mixed configuration"""

View file

@ -10,6 +10,7 @@ logger = logging.getLogger()
import hwsim_utils import hwsim_utils
import hostapd import hostapd
from utils import HwsimSkip
def connect(dev, apdev): def connect(dev, apdev):
params = { "ssid": "ap-csa", params = { "ssid": "ap-csa",
@ -31,12 +32,12 @@ def switch_channel(ap, count, freq):
# WpaSupplicant or Hostapd supports CSA. # WpaSupplicant or Hostapd supports CSA.
def csa_supported(dev): def csa_supported(dev):
res = dev.get_driver_status() res = dev.get_driver_status()
return (int(res['capa.flags'], 0) & 0x80000000) != 0 if (int(res['capa.flags'], 0) & 0x80000000) == 0:
raise HwsimSkip("CSA not supported")
def test_ap_csa_1_switch(dev, apdev): def test_ap_csa_1_switch(dev, apdev):
"""AP Channel Switch, one switch""" """AP Channel Switch, one switch"""
if not csa_supported(dev[0]): csa_supported(dev[0])
return "skip"
ap = connect(dev[0], apdev) ap = connect(dev[0], apdev)
hwsim_utils.test_connectivity(dev[0], ap) hwsim_utils.test_connectivity(dev[0], ap)
@ -45,8 +46,7 @@ def test_ap_csa_1_switch(dev, apdev):
def test_ap_csa_2_switches(dev, apdev): def test_ap_csa_2_switches(dev, apdev):
"""AP Channel Switch, two switches""" """AP Channel Switch, two switches"""
if not csa_supported(dev[0]): csa_supported(dev[0])
return "skip"
ap = connect(dev[0], apdev) ap = connect(dev[0], apdev)
hwsim_utils.test_connectivity(dev[0], ap) hwsim_utils.test_connectivity(dev[0], ap)
@ -57,8 +57,7 @@ def test_ap_csa_2_switches(dev, apdev):
def test_ap_csa_1_switch_count_0(dev, apdev): def test_ap_csa_1_switch_count_0(dev, apdev):
"""AP Channel Switch, one switch with count 0""" """AP Channel Switch, one switch with count 0"""
if not csa_supported(dev[0]): csa_supported(dev[0])
return "skip"
ap = connect(dev[0], apdev) ap = connect(dev[0], apdev)
hwsim_utils.test_connectivity(dev[0], ap) hwsim_utils.test_connectivity(dev[0], ap)
@ -68,8 +67,7 @@ def test_ap_csa_1_switch_count_0(dev, apdev):
def test_ap_csa_2_switches_count_0(dev, apdev): def test_ap_csa_2_switches_count_0(dev, apdev):
"""AP Channel Switch, two switches with count 0""" """AP Channel Switch, two switches with count 0"""
if not csa_supported(dev[0]): csa_supported(dev[0])
return "skip"
ap = connect(dev[0], apdev) ap = connect(dev[0], apdev)
hwsim_utils.test_connectivity(dev[0], ap) hwsim_utils.test_connectivity(dev[0], ap)
@ -82,8 +80,7 @@ def test_ap_csa_2_switches_count_0(dev, apdev):
def test_ap_csa_1_switch_count_1(dev, apdev): def test_ap_csa_1_switch_count_1(dev, apdev):
"""AP Channel Switch, one switch with count 1""" """AP Channel Switch, one switch with count 1"""
if not csa_supported(dev[0]): csa_supported(dev[0])
return "skip"
ap = connect(dev[0], apdev) ap = connect(dev[0], apdev)
hwsim_utils.test_connectivity(dev[0], ap) hwsim_utils.test_connectivity(dev[0], ap)
@ -93,8 +90,7 @@ def test_ap_csa_1_switch_count_1(dev, apdev):
def test_ap_csa_2_switches_count_1(dev, apdev): def test_ap_csa_2_switches_count_1(dev, apdev):
"""AP Channel Switch, two switches with count 1""" """AP Channel Switch, two switches with count 1"""
if not csa_supported(dev[0]): csa_supported(dev[0])
return "skip"
ap = connect(dev[0], apdev) ap = connect(dev[0], apdev)
hwsim_utils.test_connectivity(dev[0], ap) hwsim_utils.test_connectivity(dev[0], ap)
@ -107,8 +103,7 @@ def test_ap_csa_2_switches_count_1(dev, apdev):
def test_ap_csa_1_switch_count_2(dev, apdev): def test_ap_csa_1_switch_count_2(dev, apdev):
"""AP Channel Switch, one switch with count 2""" """AP Channel Switch, one switch with count 2"""
if not csa_supported(dev[0]): csa_supported(dev[0])
return "skip"
ap = connect(dev[0], apdev) ap = connect(dev[0], apdev)
hwsim_utils.test_connectivity(dev[0], ap) hwsim_utils.test_connectivity(dev[0], ap)

View file

@ -15,8 +15,13 @@ import os
import hwsim_utils import hwsim_utils
import hostapd import hostapd
from utils import HwsimSkip
from test_ap_psk import check_mib, find_wpas_process, read_process_memory, verify_not_present, get_key_locations from test_ap_psk import check_mib, find_wpas_process, read_process_memory, verify_not_present, get_key_locations
def check_hlr_auc_gw_support():
if not os.path.exists("/tmp/hlr_auc_gw.sock"):
raise HwsimSkip("No hlr_auc_gw available")
def read_pem(fname): def read_pem(fname):
with open(fname, "r") as f: with open(fname, "r") as f:
lines = f.readlines() lines = f.readlines()
@ -103,9 +108,7 @@ def eap_reauth(dev, method, rsn=True, sha256=False, expect_failure=False):
def test_ap_wpa2_eap_sim(dev, apdev): def test_ap_wpa2_eap_sim(dev, apdev):
"""WPA2-Enterprise connection using EAP-SIM""" """WPA2-Enterprise connection using EAP-SIM"""
if not os.path.exists("/tmp/hlr_auc_gw.sock"): check_hlr_auc_gw_support()
logger.info("No hlr_auc_gw available");
return "skip"
params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
hapd = hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
eap_connect(dev[0], apdev[0], "SIM", "1232010000000000", eap_connect(dev[0], apdev[0], "SIM", "1232010000000000",
@ -156,13 +159,11 @@ def test_ap_wpa2_eap_sim(dev, apdev):
def test_ap_wpa2_eap_sim_sql(dev, apdev, params): def test_ap_wpa2_eap_sim_sql(dev, apdev, params):
"""WPA2-Enterprise connection using EAP-SIM (SQL)""" """WPA2-Enterprise connection using EAP-SIM (SQL)"""
if not os.path.exists("/tmp/hlr_auc_gw.sock"): check_hlr_auc_gw_support()
logger.info("No hlr_auc_gw available");
return "skip"
try: try:
import sqlite3 import sqlite3
except ImportError: except ImportError:
return "skip" raise HwsimSkip("No sqlite3 module available")
con = sqlite3.connect(os.path.join(params['logdir'], "hostapd.db")) con = sqlite3.connect(os.path.join(params['logdir'], "hostapd.db"))
params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
params['auth_server_port'] = "1814" params['auth_server_port'] = "1814"
@ -248,14 +249,12 @@ def test_ap_wpa2_eap_sim_config(dev, apdev):
def test_ap_wpa2_eap_sim_ext(dev, apdev): def test_ap_wpa2_eap_sim_ext(dev, apdev):
"""WPA2-Enterprise connection using EAP-SIM and external GSM auth""" """WPA2-Enterprise connection using EAP-SIM and external GSM auth"""
try: try:
return _test_ap_wpa2_eap_sim_ext(dev, apdev) _test_ap_wpa2_eap_sim_ext(dev, apdev)
finally: finally:
dev[0].request("SET external_sim 0") dev[0].request("SET external_sim 0")
def _test_ap_wpa2_eap_sim_ext(dev, apdev): def _test_ap_wpa2_eap_sim_ext(dev, apdev):
if not os.path.exists("/tmp/hlr_auc_gw.sock"): check_hlr_auc_gw_support()
logger.info("No hlr_auc_gw available");
return "skip"
params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
hostapd.add_ap(apdev[0]['ifname'], params) hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].request("SET external_sim 1") dev[0].request("SET external_sim 1")
@ -380,9 +379,7 @@ def _test_ap_wpa2_eap_sim_ext(dev, apdev):
def test_ap_wpa2_eap_aka(dev, apdev): def test_ap_wpa2_eap_aka(dev, apdev):
"""WPA2-Enterprise connection using EAP-AKA""" """WPA2-Enterprise connection using EAP-AKA"""
if not os.path.exists("/tmp/hlr_auc_gw.sock"): check_hlr_auc_gw_support()
logger.info("No hlr_auc_gw available");
return "skip"
params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
hapd = hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
eap_connect(dev[0], apdev[0], "AKA", "0232010000000000", eap_connect(dev[0], apdev[0], "AKA", "0232010000000000",
@ -436,13 +433,11 @@ def test_ap_wpa2_eap_aka(dev, apdev):
def test_ap_wpa2_eap_aka_sql(dev, apdev, params): def test_ap_wpa2_eap_aka_sql(dev, apdev, params):
"""WPA2-Enterprise connection using EAP-AKA (SQL)""" """WPA2-Enterprise connection using EAP-AKA (SQL)"""
if not os.path.exists("/tmp/hlr_auc_gw.sock"): check_hlr_auc_gw_support()
logger.info("No hlr_auc_gw available");
return "skip"
try: try:
import sqlite3 import sqlite3
except ImportError: except ImportError:
return "skip" raise HwsimSkip("No sqlite3 module available")
con = sqlite3.connect(os.path.join(params['logdir'], "hostapd.db")) con = sqlite3.connect(os.path.join(params['logdir'], "hostapd.db"))
params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
params['auth_server_port'] = "1814" params['auth_server_port'] = "1814"
@ -505,14 +500,12 @@ def test_ap_wpa2_eap_aka_config(dev, apdev):
def test_ap_wpa2_eap_aka_ext(dev, apdev): def test_ap_wpa2_eap_aka_ext(dev, apdev):
"""WPA2-Enterprise connection using EAP-AKA and external UMTS auth""" """WPA2-Enterprise connection using EAP-AKA and external UMTS auth"""
try: try:
return _test_ap_wpa2_eap_aka_ext(dev, apdev) _test_ap_wpa2_eap_aka_ext(dev, apdev)
finally: finally:
dev[0].request("SET external_sim 0") dev[0].request("SET external_sim 0")
def _test_ap_wpa2_eap_aka_ext(dev, apdev): def _test_ap_wpa2_eap_aka_ext(dev, apdev):
if not os.path.exists("/tmp/hlr_auc_gw.sock"): check_hlr_auc_gw_support()
logger.info("No hlr_auc_gw available");
return "skip"
params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
hostapd.add_ap(apdev[0]['ifname'], params) hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].request("SET external_sim 1") dev[0].request("SET external_sim 1")
@ -680,9 +673,7 @@ def _test_ap_wpa2_eap_aka_ext(dev, apdev):
def test_ap_wpa2_eap_aka_prime(dev, apdev): def test_ap_wpa2_eap_aka_prime(dev, apdev):
"""WPA2-Enterprise connection using EAP-AKA'""" """WPA2-Enterprise connection using EAP-AKA'"""
if not os.path.exists("/tmp/hlr_auc_gw.sock"): check_hlr_auc_gw_support()
logger.info("No hlr_auc_gw available");
return "skip"
params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
hapd = hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
eap_connect(dev[0], apdev[0], "AKA'", "6555444333222111", eap_connect(dev[0], apdev[0], "AKA'", "6555444333222111",
@ -705,13 +696,11 @@ def test_ap_wpa2_eap_aka_prime(dev, apdev):
def test_ap_wpa2_eap_aka_prime_sql(dev, apdev, params): def test_ap_wpa2_eap_aka_prime_sql(dev, apdev, params):
"""WPA2-Enterprise connection using EAP-AKA' (SQL)""" """WPA2-Enterprise connection using EAP-AKA' (SQL)"""
if not os.path.exists("/tmp/hlr_auc_gw.sock"): check_hlr_auc_gw_support()
logger.info("No hlr_auc_gw available");
return "skip"
try: try:
import sqlite3 import sqlite3
except ImportError: except ImportError:
return "skip" raise HwsimSkip("No sqlite3 module available")
con = sqlite3.connect(os.path.join(params['logdir'], "hostapd.db")) con = sqlite3.connect(os.path.join(params['logdir'], "hostapd.db"))
params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
params['auth_server_port'] = "1814" params['auth_server_port'] = "1814"
@ -2064,9 +2053,7 @@ def test_ap_wpa2_eap_request_identity_message(dev, apdev):
def test_ap_wpa2_eap_sim_aka_result_ind(dev, apdev): def test_ap_wpa2_eap_sim_aka_result_ind(dev, apdev):
"""WPA2-Enterprise using EAP-SIM/AKA and protected result indication""" """WPA2-Enterprise using EAP-SIM/AKA and protected result indication"""
if not os.path.exists("/tmp/hlr_auc_gw.sock"): check_hlr_auc_gw_support()
logger.info("No hlr_auc_gw available");
return "skip"
params = int_eap_server_params() params = int_eap_server_params()
params['eap_sim_db'] = "unix:/tmp/hlr_auc_gw.sock" params['eap_sim_db'] = "unix:/tmp/hlr_auc_gw.sock"
params['eap_sim_aka_result_ind'] = "1" params['eap_sim_aka_result_ind'] = "1"
@ -2142,7 +2129,7 @@ def test_ap_wpa2_eap_sql(dev, apdev, params):
try: try:
import sqlite3 import sqlite3
except ImportError: except ImportError:
return "skip" raise HwsimSkip("No sqlite3 module available")
dbfile = os.path.join(params['logdir'], "eap-user.db") dbfile = os.path.join(params['logdir'], "eap-user.db")
try: try:
os.remove(dbfile) os.remove(dbfile)
@ -2301,11 +2288,9 @@ def test_wpa2_eap_ttls_pap_key_lifetime_in_memory(dev, apdev, params):
get_key_locations(buf, msk, "MSK") get_key_locations(buf, msk, "MSK")
get_key_locations(buf, emsk, "EMSK") get_key_locations(buf, emsk, "EMSK")
if password not in buf: if password not in buf:
print("Password not found while associated") raise HwsimSkip("Password not found while associated")
return "skip"
if pmk not in buf: if pmk not in buf:
print("PMK not found while associated") raise HwsimSkip("PMK not found while associated")
return "skip"
if kck not in buf: if kck not in buf:
raise Exception("KCK not found while associated") raise Exception("KCK not found while associated")
if kek not in buf: if kek not in buf:

View file

@ -13,6 +13,7 @@ logger = logging.getLogger()
import hwsim_utils import hwsim_utils
import hostapd import hostapd
from utils import HwsimSkip
from wlantest import Wlantest from wlantest import Wlantest
from test_ap_psk import check_mib, find_wpas_process, read_process_memory, verify_not_present, get_key_locations from test_ap_psk import check_mib, find_wpas_process, read_process_memory, verify_not_present, get_key_locations
@ -514,14 +515,11 @@ def test_ft_psk_key_lifetime_in_memory(dev, apdev, params):
get_key_locations(buf, pmkr0, "PMK-R0") get_key_locations(buf, pmkr0, "PMK-R0")
get_key_locations(buf, pmkr1, "PMK-R1") get_key_locations(buf, pmkr1, "PMK-R1")
if pmk not in buf: if pmk not in buf:
print("PMK not found while associated") raise HwsimSkip("PMK not found while associated")
return "skip"
if pmkr0 not in buf: if pmkr0 not in buf:
print("PMK-R0 not found while associated") raise HwsimSkip("PMK-R0 not found while associated")
return "skip"
if pmkr1 not in buf: if pmkr1 not in buf:
print("PMK-R1 not found while associated") raise HwsimSkip("PMK-R1 not found while associated")
return "skip"
if kck not in buf: if kck not in buf:
raise Exception("KCK not found while associated") raise Exception("KCK not found while associated")
if kek not in buf: if kek not in buf:

View file

@ -16,6 +16,7 @@ import socket
import subprocess import subprocess
import hostapd import hostapd
from utils import HwsimSkip
import hwsim_utils import hwsim_utils
from wlantest import Wlantest from wlantest import Wlantest
from wpasupplicant import WpaSupplicant from wpasupplicant import WpaSupplicant
@ -95,12 +96,9 @@ def check_sp_type(dev, sp_type):
def hlr_auc_gw_available(): def hlr_auc_gw_available():
if not os.path.exists("/tmp/hlr_auc_gw.sock"): if not os.path.exists("/tmp/hlr_auc_gw.sock"):
logger.info("No hlr_auc_gw available"); raise HwsimSkip("No hlr_auc_gw socket available")
return False
if not os.path.exists("../../hostapd/hlr_auc_gw"): if not os.path.exists("../../hostapd/hlr_auc_gw"):
logger.info("No hlr_auc_gw available"); raise HwsimSkip("No hlr_auc_gw available")
return False
return True
def interworking_ext_sim_connect(dev, bssid, method): def interworking_ext_sim_connect(dev, bssid, method):
dev.request("INTERWORKING_CONNECT " + bssid) dev.request("INTERWORKING_CONNECT " + bssid)
@ -275,7 +273,7 @@ def test_ap_nai_home_realm_query(dev, apdev):
def test_ap_interworking_scan_filtering(dev, apdev): def test_ap_interworking_scan_filtering(dev, apdev):
"""Interworking scan filtering with HESSID and access network type""" """Interworking scan filtering with HESSID and access network type"""
try: try:
return _test_ap_interworking_scan_filtering(dev, apdev) _test_ap_interworking_scan_filtering(dev, apdev)
finally: finally:
dev[0].request("SET hessid 00:00:00:00:00:00") dev[0].request("SET hessid 00:00:00:00:00:00")
dev[0].request("SET access_network_type 15") dev[0].request("SET access_network_type 15")
@ -411,8 +409,7 @@ def hs20_simulated_sim(dev, ap, method):
def test_ap_hs20_sim(dev, apdev): def test_ap_hs20_sim(dev, apdev):
"""Hotspot 2.0 with simulated SIM and EAP-SIM""" """Hotspot 2.0 with simulated SIM and EAP-SIM"""
if not hlr_auc_gw_available(): hlr_auc_gw_available()
return "skip"
hs20_simulated_sim(dev[0], apdev[0], "SIM") hs20_simulated_sim(dev[0], apdev[0], "SIM")
dev[0].request("INTERWORKING_SELECT auto freq=2412") dev[0].request("INTERWORKING_SELECT auto freq=2412")
ev = dev[0].wait_event(["INTERWORKING-ALREADY-CONNECTED"], timeout=15) ev = dev[0].wait_event(["INTERWORKING-ALREADY-CONNECTED"], timeout=15)
@ -421,20 +418,17 @@ def test_ap_hs20_sim(dev, apdev):
def test_ap_hs20_aka(dev, apdev): def test_ap_hs20_aka(dev, apdev):
"""Hotspot 2.0 with simulated USIM and EAP-AKA""" """Hotspot 2.0 with simulated USIM and EAP-AKA"""
if not hlr_auc_gw_available(): hlr_auc_gw_available()
return "skip"
hs20_simulated_sim(dev[0], apdev[0], "AKA") hs20_simulated_sim(dev[0], apdev[0], "AKA")
def test_ap_hs20_aka_prime(dev, apdev): def test_ap_hs20_aka_prime(dev, apdev):
"""Hotspot 2.0 with simulated USIM and EAP-AKA'""" """Hotspot 2.0 with simulated USIM and EAP-AKA'"""
if not hlr_auc_gw_available(): hlr_auc_gw_available()
return "skip"
hs20_simulated_sim(dev[0], apdev[0], "AKA'") hs20_simulated_sim(dev[0], apdev[0], "AKA'")
def test_ap_hs20_ext_sim(dev, apdev): def test_ap_hs20_ext_sim(dev, apdev):
"""Hotspot 2.0 with external SIM processing""" """Hotspot 2.0 with external SIM processing"""
if not hlr_auc_gw_available(): hlr_auc_gw_available()
return "skip"
bssid = apdev[0]['bssid'] bssid = apdev[0]['bssid']
params = hs20_ap_params() params = hs20_ap_params()
params['hessid'] = bssid params['hessid'] = bssid
@ -454,8 +448,7 @@ def test_ap_hs20_ext_sim(dev, apdev):
def test_ap_hs20_ext_sim_roaming(dev, apdev): def test_ap_hs20_ext_sim_roaming(dev, apdev):
"""Hotspot 2.0 with external SIM processing in roaming network""" """Hotspot 2.0 with external SIM processing in roaming network"""
if not hlr_auc_gw_available(): hlr_auc_gw_available()
return "skip"
bssid = apdev[0]['bssid'] bssid = apdev[0]['bssid']
params = hs20_ap_params() params = hs20_ap_params()
params['hessid'] = bssid params['hessid'] = bssid
@ -1274,13 +1267,12 @@ def test_ap_hs20_max_bss_load2(dev, apdev):
def test_ap_hs20_multi_cred_sp_prio(dev, apdev): def test_ap_hs20_multi_cred_sp_prio(dev, apdev):
"""Hotspot 2.0 multi-cred sp_priority""" """Hotspot 2.0 multi-cred sp_priority"""
try: try:
return _test_ap_hs20_multi_cred_sp_prio(dev, apdev) _test_ap_hs20_multi_cred_sp_prio(dev, apdev)
finally: finally:
dev[0].request("SET external_sim 0") dev[0].request("SET external_sim 0")
def _test_ap_hs20_multi_cred_sp_prio(dev, apdev): def _test_ap_hs20_multi_cred_sp_prio(dev, apdev):
if not hlr_auc_gw_available(): hlr_auc_gw_available()
return "skip"
bssid = apdev[0]['bssid'] bssid = apdev[0]['bssid']
params = hs20_ap_params() params = hs20_ap_params()
params['hessid'] = bssid params['hessid'] = bssid
@ -1317,13 +1309,12 @@ def _test_ap_hs20_multi_cred_sp_prio(dev, apdev):
def test_ap_hs20_multi_cred_sp_prio2(dev, apdev): def test_ap_hs20_multi_cred_sp_prio2(dev, apdev):
"""Hotspot 2.0 multi-cred sp_priority with two BSSes""" """Hotspot 2.0 multi-cred sp_priority with two BSSes"""
try: try:
return _test_ap_hs20_multi_cred_sp_prio2(dev, apdev) _test_ap_hs20_multi_cred_sp_prio2(dev, apdev)
finally: finally:
dev[0].request("SET external_sim 0") dev[0].request("SET external_sim 0")
def _test_ap_hs20_multi_cred_sp_prio2(dev, apdev): def _test_ap_hs20_multi_cred_sp_prio2(dev, apdev):
if not hlr_auc_gw_available(): hlr_auc_gw_available()
return "skip"
bssid = apdev[0]['bssid'] bssid = apdev[0]['bssid']
params = hs20_ap_params() params = hs20_ap_params()
params['hessid'] = bssid params['hessid'] = bssid
@ -2180,7 +2171,7 @@ def test_ap_hs20_remediation_sql(dev, apdev, params):
try: try:
import sqlite3 import sqlite3
except ImportError: except ImportError:
return "skip" raise HwsimSkip("No sqlite3 module available")
dbfile = os.path.join(params['logdir'], "eap-user.db") dbfile = os.path.join(params['logdir'], "eap-user.db")
try: try:
os.remove(dbfile) os.remove(dbfile)
@ -2342,8 +2333,7 @@ def _test_ap_hs20_proxyarp(dev, apdev):
hapd.enable() hapd.enable()
except: except:
# For now, do not report failures due to missing kernel support # For now, do not report failures due to missing kernel support
logger.info("Could not start hostapd - assume proxyarp not supported in kernel version") raise HwsimSkip("Could not start hostapd - assume proxyarp not supported in kernel version")
return "skip"
ev = hapd.wait_event(["AP-ENABLED", "AP-DISABLED"], timeout=10) ev = hapd.wait_event(["AP-ENABLED", "AP-DISABLED"], timeout=10)
if ev is None: if ev is None:
raise Exception("AP startup timed out") raise Exception("AP startup timed out")
@ -2413,17 +2403,14 @@ def _test_ap_hs20_proxyarp(dev, apdev):
def test_ap_hs20_proxyarp(dev, apdev): def test_ap_hs20_proxyarp(dev, apdev):
"""Hotspot 2.0 and ProxyARP""" """Hotspot 2.0 and ProxyARP"""
res = None
try: try:
res = _test_ap_hs20_proxyarp(dev, apdev) _test_ap_hs20_proxyarp(dev, apdev)
finally: finally:
subprocess.call(['ip', 'link', 'set', 'dev', 'ap-br0', 'down'], subprocess.call(['ip', 'link', 'set', 'dev', 'ap-br0', 'down'],
stderr=open('/dev/null', 'w')) stderr=open('/dev/null', 'w'))
subprocess.call(['brctl', 'delbr', 'ap-br0'], subprocess.call(['brctl', 'delbr', 'ap-br0'],
stderr=open('/dev/null', 'w')) stderr=open('/dev/null', 'w'))
return res
def _test_ap_hs20_proxyarp_dgaf(dev, apdev, disabled): def _test_ap_hs20_proxyarp_dgaf(dev, apdev, disabled):
bssid = apdev[0]['bssid'] bssid = apdev[0]['bssid']
params = hs20_ap_params() params = hs20_ap_params()
@ -2437,8 +2424,7 @@ def _test_ap_hs20_proxyarp_dgaf(dev, apdev, disabled):
hapd.enable() hapd.enable()
except: except:
# For now, do not report failures due to missing kernel support # For now, do not report failures due to missing kernel support
logger.info("Could not start hostapd - assume proxyarp not supported in kernel version") raise HwsimSkip("Could not start hostapd - assume proxyarp not supported in kernel version")
return "skip"
ev = hapd.wait_event(["AP-ENABLED"], timeout=10) ev = hapd.wait_event(["AP-ENABLED"], timeout=10)
if ev is None: if ev is None:
raise Exception("AP startup timed out") raise Exception("AP startup timed out")
@ -2512,30 +2498,24 @@ def _test_ap_hs20_proxyarp_dgaf(dev, apdev, disabled):
def test_ap_hs20_proxyarp_disable_dgaf(dev, apdev): def test_ap_hs20_proxyarp_disable_dgaf(dev, apdev):
"""Hotspot 2.0 and ProxyARP with DGAF disabled""" """Hotspot 2.0 and ProxyARP with DGAF disabled"""
res = None
try: try:
res = _test_ap_hs20_proxyarp_dgaf(dev, apdev, True) _test_ap_hs20_proxyarp_dgaf(dev, apdev, True)
finally: finally:
subprocess.call(['ip', 'link', 'set', 'dev', 'ap-br0', 'down'], subprocess.call(['ip', 'link', 'set', 'dev', 'ap-br0', 'down'],
stderr=open('/dev/null', 'w')) stderr=open('/dev/null', 'w'))
subprocess.call(['brctl', 'delbr', 'ap-br0'], subprocess.call(['brctl', 'delbr', 'ap-br0'],
stderr=open('/dev/null', 'w')) stderr=open('/dev/null', 'w'))
return res
def test_ap_hs20_proxyarp_enable_dgaf(dev, apdev): def test_ap_hs20_proxyarp_enable_dgaf(dev, apdev):
"""Hotspot 2.0 and ProxyARP with DGAF enabled""" """Hotspot 2.0 and ProxyARP with DGAF enabled"""
res = None
try: try:
res = _test_ap_hs20_proxyarp_dgaf(dev, apdev, False) _test_ap_hs20_proxyarp_dgaf(dev, apdev, False)
finally: finally:
subprocess.call(['ip', 'link', 'set', 'dev', 'ap-br0', 'down'], subprocess.call(['ip', 'link', 'set', 'dev', 'ap-br0', 'down'],
stderr=open('/dev/null', 'w')) stderr=open('/dev/null', 'w'))
subprocess.call(['brctl', 'delbr', 'ap-br0'], subprocess.call(['brctl', 'delbr', 'ap-br0'],
stderr=open('/dev/null', 'w')) stderr=open('/dev/null', 'w'))
return res
def ip_checksum(buf): def ip_checksum(buf):
sum = 0 sum = 0
if len(buf) & 0x01: if len(buf) & 0x01:
@ -2787,8 +2767,7 @@ def _test_proxyarp_open(dev, apdev, params):
hapd.enable() hapd.enable()
except: except:
# For now, do not report failures due to missing kernel support # For now, do not report failures due to missing kernel support
logger.info("Could not start hostapd - assume proxyarp not supported in kernel version") raise HwsimSkip("Could not start hostapd - assume proxyarp not supported in kernel version")
return "skip"
ev = hapd.wait_event(["AP-ENABLED", "AP-DISABLED"], timeout=10) ev = hapd.wait_event(["AP-ENABLED", "AP-DISABLED"], timeout=10)
if ev is None: if ev is None:
raise Exception("AP startup timed out") raise Exception("AP startup timed out")
@ -3046,9 +3025,8 @@ def _test_proxyarp_open(dev, apdev, params):
def test_proxyarp_open(dev, apdev, params): def test_proxyarp_open(dev, apdev, params):
"""ProxyARP with open network""" """ProxyARP with open network"""
res = None
try: try:
res = _test_proxyarp_open(dev, apdev, params) _test_proxyarp_open(dev, apdev, params)
finally: finally:
try: try:
subprocess.call(['ebtables', '-F', 'FORWARD']) subprocess.call(['ebtables', '-F', 'FORWARD'])
@ -3059,5 +3037,3 @@ def test_proxyarp_open(dev, apdev, params):
stderr=open('/dev/null', 'w')) stderr=open('/dev/null', 'w'))
subprocess.call(['brctl', 'delbr', 'ap-br0'], subprocess.call(['brctl', 'delbr', 'ap-br0'],
stderr=open('/dev/null', 'w')) stderr=open('/dev/null', 'w'))
return res

View file

@ -11,6 +11,7 @@ import struct
import subprocess import subprocess
import hostapd import hostapd
from utils import HwsimSkip
import hwsim_utils import hwsim_utils
from test_ap_csa import csa_supported from test_ap_csa import csa_supported
@ -630,8 +631,7 @@ def test_ap_ht_40mhz_intolerant_ap(dev, apdev):
def test_ap_ht40_csa(dev, apdev): def test_ap_ht40_csa(dev, apdev):
"""HT with 40 MHz channel width and CSA""" """HT with 40 MHz channel width and CSA"""
if not csa_supported(dev[0]): csa_supported(dev[0])
return "skip"
try: try:
hapd = None hapd = None
params = { "ssid": "ht", params = { "ssid": "ht",
@ -675,8 +675,7 @@ def test_ap_ht40_csa(dev, apdev):
def test_ap_ht40_csa2(dev, apdev): def test_ap_ht40_csa2(dev, apdev):
"""HT with 40 MHz channel width and CSA""" """HT with 40 MHz channel width and CSA"""
if not csa_supported(dev[0]): csa_supported(dev[0])
return "skip"
try: try:
hapd = None hapd = None
params = { "ssid": "ht", params = { "ssid": "ht",
@ -720,8 +719,7 @@ def test_ap_ht40_csa2(dev, apdev):
def test_ap_ht40_csa3(dev, apdev): def test_ap_ht40_csa3(dev, apdev):
"""HT with 40 MHz channel width and CSA""" """HT with 40 MHz channel width and CSA"""
if not csa_supported(dev[0]): csa_supported(dev[0])
return "skip"
try: try:
hapd = None hapd = None
params = { "ssid": "ht", params = { "ssid": "ht",
@ -769,8 +767,7 @@ def test_ap_ht_smps(dev, apdev):
try: try:
hapd = hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
except: except:
logger.info("Assume mac80211_hwsim was not recent enough to support SMPS") raise HwsimSkip("Assume mac80211_hwsim was not recent enough to support SMPS")
return "skip"
params = { "ssid": "ht2", "ht_capab": "[SMPS-DYNAMIC]" } params = { "ssid": "ht2", "ht_capab": "[SMPS-DYNAMIC]" }
hapd2 = hostapd.add_ap(apdev[1]['ifname'], params) hapd2 = hostapd.add_ap(apdev[1]['ifname'], params)

View file

@ -16,6 +16,7 @@ import subprocess
import time import time
import hostapd import hostapd
from utils import HwsimSkip
import hwsim_utils import hwsim_utils
def check_mib(dev, vals): def check_mib(dev, vals):
@ -940,8 +941,7 @@ def test_wpa2_psk_key_lifetime_in_memory(dev, apdev, params):
logger.info("Checking keys in memory while associated") logger.info("Checking keys in memory while associated")
get_key_locations(buf, pmk, "PMK") get_key_locations(buf, pmk, "PMK")
if pmk not in buf: if pmk not in buf:
print("PMK not found while associated") raise HwsimSkip("PMK not found while associated")
return "skip"
if kck not in buf: if kck not in buf:
raise Exception("KCK not found while associated") raise Exception("KCK not found while associated")
if kek not in buf: if kek not in buf:

View file

@ -11,6 +11,7 @@ logger = logging.getLogger()
import hwsim_utils import hwsim_utils
import hostapd import hostapd
from utils import HwsimSkip
from wlantest import Wlantest from wlantest import Wlantest
def check_qos_map(ap, hapd, dev, sta, dscp, tid, ap_tid=None): def check_qos_map(ap, hapd, dev, sta, dscp, tid, ap_tid=None):
@ -36,7 +37,7 @@ def test_ap_qosmap(dev, apdev):
"""QoS mapping""" """QoS mapping"""
drv_flags = dev[0].get_driver_status_field("capa.flags") drv_flags = dev[0].get_driver_status_field("capa.flags")
if int(drv_flags, 0) & 0x40000000 == 0: if int(drv_flags, 0) & 0x40000000 == 0:
return "skip" raise HwsimSkip("Driver does not support QoS Map")
ssid = "test-qosmap" ssid = "test-qosmap"
params = { "ssid": ssid } params = { "ssid": ssid }
params['qos_map_set'] = '53,2,22,6,8,15,0,7,255,255,16,31,32,39,255,255,40,47,48,55' params['qos_map_set'] = '53,2,22,6,8,15,0,7,255,255,16,31,32,39,255,255,40,47,48,55'

View file

@ -13,6 +13,7 @@ import hwsim_utils
from hostapd import HostapdGlobal from hostapd import HostapdGlobal
from hostapd import Hostapd from hostapd import Hostapd
import hostapd import hostapd
from utils import HwsimSkip
from wlantest import Wlantest from wlantest import Wlantest
def start_ap_wpa2_psk(ifname): def start_ap_wpa2_psk(ifname):
@ -363,8 +364,7 @@ def test_tdls_chan_switch(dev, apdev):
"""Open AP and two stations using TDLS""" """Open AP and two stations using TDLS"""
flags = int(dev[0].get_driver_status_field('capa.flags'), 16) flags = int(dev[0].get_driver_status_field('capa.flags'), 16)
if flags & 0x800000000 == 0: if flags & 0x800000000 == 0:
logger.info("Driver does not support TDLS channel switching") raise HwsimSkip("Driver does not support TDLS channel switching")
return "skip"
hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" }) hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
connect_2sta_open(dev, hapd) connect_2sta_open(dev, hapd)

View file

@ -12,6 +12,7 @@ import subprocess, time
import hwsim_utils import hwsim_utils
import hostapd import hostapd
from utils import HwsimSkip
from test_dfs import wait_dfs_event from test_dfs import wait_dfs_event
from test_ap_csa import csa_supported from test_ap_csa import csa_supported
@ -42,8 +43,7 @@ def test_ap_vht80(dev, apdev):
except Exception, e: except Exception, e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
logger.info("80 MHz channel not supported in regulatory information") raise HwsimSkip("80 MHz channel not supported in regulatory information")
return "skip"
raise raise
finally: finally:
dev[0].request("DISCONNECT") dev[0].request("DISCONNECT")
@ -82,8 +82,7 @@ def test_ap_vht80_params(dev, apdev):
except Exception, e: except Exception, e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
logger.info("80 MHz channel not supported in regulatory information") raise HwsimSwkip("80 MHz channel not supported in regulatory information")
return "skip"
raise raise
finally: finally:
dev[0].request("DISCONNECT") dev[0].request("DISCONNECT")
@ -202,7 +201,7 @@ def test_ap_vht160(dev, apdev):
# Not all systems have recent enough CRDA version and # Not all systems have recent enough CRDA version and
# wireless-regdb changes to support 160 MHz and DFS. For now, # wireless-regdb changes to support 160 MHz and DFS. For now,
# do not report failures for this test case. # do not report failures for this test case.
return "skip" raise HwsimSkip("CRDA or wireless-regdb did not support 160 MHz")
raise Exception("Unexpected interface state: " + state) raise Exception("Unexpected interface state: " + state)
params = { "ssid": "vht2", params = { "ssid": "vht2",
@ -277,8 +276,7 @@ def test_ap_vht160(dev, apdev):
except Exception, e: except Exception, e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
logger.info("80/160 MHz channel not supported in regulatory information") raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
return "skip"
raise raise
finally: finally:
dev[0].request("DISCONNECT") dev[0].request("DISCONNECT")
@ -347,8 +345,7 @@ def test_ap_vht80plus80(dev, apdev):
except Exception, e: except Exception, e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
logger.info("80/160 MHz channel not supported in regulatory information") raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
return "skip"
raise raise
finally: finally:
dev[0].request("DISCONNECT") dev[0].request("DISCONNECT")
@ -363,8 +360,7 @@ def test_ap_vht80plus80(dev, apdev):
def test_ap_vht80_csa(dev, apdev): def test_ap_vht80_csa(dev, apdev):
"""VHT with 80 MHz channel width and CSA""" """VHT with 80 MHz channel width and CSA"""
if not csa_supported(dev[0]): csa_supported(dev[0])
return "skip"
try: try:
hapd = None hapd = None
params = { "ssid": "vht", params = { "ssid": "vht",
@ -406,8 +402,7 @@ def test_ap_vht80_csa(dev, apdev):
except Exception, e: except Exception, e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
logger.info("80 MHz channel not supported in regulatory information") raise HwsimSkip("80 MHz channel not supported in regulatory information")
return "skip"
raise raise
finally: finally:
dev[0].request("DISCONNECT") dev[0].request("DISCONNECT")

View file

@ -20,6 +20,7 @@ import StringIO
import hwsim_utils import hwsim_utils
import hostapd import hostapd
from wpasupplicant import WpaSupplicant from wpasupplicant import WpaSupplicant
from utils import HwsimSkip
def test_ap_wps_init(dev, apdev): def test_ap_wps_init(dev, apdev):
"""Initial AP configuration with first WPS Enrollee""" """Initial AP configuration with first WPS Enrollee"""
@ -1569,8 +1570,7 @@ def test_ap_wps_auto_setup_with_config_file(dev, apdev):
def test_ap_wps_pbc_timeout(dev, apdev, params): def test_ap_wps_pbc_timeout(dev, apdev, params):
"""wpa_supplicant PBC walk time [long]""" """wpa_supplicant PBC walk time [long]"""
if not params['long']: if not params['long']:
logger.info("Skip test case with long duration due to --long not specified") raise HwsimSkip("Skip test case with long duration due to --long not specified")
return "skip"
ssid = "test-wps" ssid = "test-wps"
hostapd.add_ap(apdev[0]['ifname'], hostapd.add_ap(apdev[0]['ifname'],
{ "ssid": ssid, "eap_server": "1", "wps_state": "1" }) { "ssid": ssid, "eap_server": "1", "wps_state": "1" })

View file

@ -298,7 +298,7 @@ def test_dbus_invalid_method(dev, apdev):
def test_dbus_get_set_wps(dev, apdev): def test_dbus_get_set_wps(dev, apdev):
"""D-Bus Get/Set for WPS properties""" """D-Bus Get/Set for WPS properties"""
try: try:
return _test_dbus_get_set_wps(dev, apdev) _test_dbus_get_set_wps(dev, apdev)
finally: finally:
dev[0].request("SET wps_cred_processing 0") dev[0].request("SET wps_cred_processing 0")
dev[0].request("SET config_methods display keypad virtual_display nfc_interface") dev[0].request("SET config_methods display keypad virtual_display nfc_interface")
@ -427,7 +427,7 @@ def test_dbus_wps_invalid(dev, apdev):
def test_dbus_wps_pbc(dev, apdev): def test_dbus_wps_pbc(dev, apdev):
"""D-Bus WPS/PBC operation and signals""" """D-Bus WPS/PBC operation and signals"""
try: try:
return _test_dbus_wps_pbc(dev, apdev) _test_dbus_wps_pbc(dev, apdev)
finally: finally:
dev[0].request("SET wps_cred_processing 0") dev[0].request("SET wps_cred_processing 0")
@ -490,7 +490,7 @@ def _test_dbus_wps_pbc(dev, apdev):
def test_dbus_wps_pin(dev, apdev): def test_dbus_wps_pin(dev, apdev):
"""D-Bus WPS/PIN operation and signals""" """D-Bus WPS/PIN operation and signals"""
try: try:
return _test_dbus_wps_pin(dev, apdev) _test_dbus_wps_pin(dev, apdev)
finally: finally:
dev[0].request("SET wps_cred_processing 0") dev[0].request("SET wps_cred_processing 0")
@ -551,7 +551,7 @@ def _test_dbus_wps_pin(dev, apdev):
def test_dbus_wps_pin2(dev, apdev): def test_dbus_wps_pin2(dev, apdev):
"""D-Bus WPS/PIN operation and signals (PIN from wpa_supplicant)""" """D-Bus WPS/PIN operation and signals (PIN from wpa_supplicant)"""
try: try:
return _test_dbus_wps_pin2(dev, apdev) _test_dbus_wps_pin2(dev, apdev)
finally: finally:
dev[0].request("SET wps_cred_processing 0") dev[0].request("SET wps_cred_processing 0")
@ -614,7 +614,7 @@ def _test_dbus_wps_pin2(dev, apdev):
def test_dbus_wps_pin_m2d(dev, apdev): def test_dbus_wps_pin_m2d(dev, apdev):
"""D-Bus WPS/PIN operation and signals with M2D""" """D-Bus WPS/PIN operation and signals with M2D"""
try: try:
return _test_dbus_wps_pin_m2d(dev, apdev) _test_dbus_wps_pin_m2d(dev, apdev)
finally: finally:
dev[0].request("SET wps_cred_processing 0") dev[0].request("SET wps_cred_processing 0")
@ -677,7 +677,7 @@ def _test_dbus_wps_pin_m2d(dev, apdev):
def test_dbus_wps_reg(dev, apdev): def test_dbus_wps_reg(dev, apdev):
"""D-Bus WPS/Registrar operation and signals""" """D-Bus WPS/Registrar operation and signals"""
try: try:
return _test_dbus_wps_reg(dev, apdev) _test_dbus_wps_reg(dev, apdev)
finally: finally:
dev[0].request("SET wps_cred_processing 0") dev[0].request("SET wps_cred_processing 0")
@ -1460,7 +1460,7 @@ def test_dbus_pkcs11(dev, apdev):
def test_dbus_apscan(dev, apdev): def test_dbus_apscan(dev, apdev):
"""D-Bus Get/Set ApScan""" """D-Bus Get/Set ApScan"""
try: try:
return _test_dbus_apscan(dev, apdev) _test_dbus_apscan(dev, apdev)
finally: finally:
dev[0].request("AP_SCAN 1") dev[0].request("AP_SCAN 1")
@ -1585,7 +1585,7 @@ def test_dbus_bss_expire(dev, apdev):
def test_dbus_country(dev, apdev): def test_dbus_country(dev, apdev):
"""D-Bus Get/Set Country""" """D-Bus Get/Set Country"""
try: try:
return _test_dbus_country(dev, apdev) _test_dbus_country(dev, apdev)
finally: finally:
dev[0].request("SET country 00") dev[0].request("SET country 00")
subprocess.call(['iw', 'reg', 'set', '00']) subprocess.call(['iw', 'reg', 'set', '00'])

View file

@ -555,7 +555,7 @@ def test_dbus_old_connect_eap(dev, apdev):
def test_dbus_old_wps_pbc(dev, apdev): def test_dbus_old_wps_pbc(dev, apdev):
"""The old D-Bus interface and WPS/PBC""" """The old D-Bus interface and WPS/PBC"""
try: try:
return _test_dbus_old_wps_pbc(dev, apdev) _test_dbus_old_wps_pbc(dev, apdev)
finally: finally:
dev[0].request("SET wps_cred_processing 0") dev[0].request("SET wps_cred_processing 0")
@ -622,7 +622,7 @@ def _test_dbus_old_wps_pbc(dev, apdev):
def test_dbus_old_wps_pin(dev, apdev): def test_dbus_old_wps_pin(dev, apdev):
"""The old D-Bus interface and WPS/PIN""" """The old D-Bus interface and WPS/PIN"""
try: try:
return _test_dbus_old_wps_pin(dev, apdev) _test_dbus_old_wps_pin(dev, apdev)
finally: finally:
dev[0].request("SET wps_cred_processing 0") dev[0].request("SET wps_cred_processing 0")
@ -677,7 +677,7 @@ def _test_dbus_old_wps_pin(dev, apdev):
def test_dbus_old_wps_reg(dev, apdev): def test_dbus_old_wps_reg(dev, apdev):
"""The old D-Bus interface and WPS/Registar""" """The old D-Bus interface and WPS/Registar"""
try: try:
return _test_dbus_old_wps_reg(dev, apdev) _test_dbus_old_wps_reg(dev, apdev)
finally: finally:
dev[0].request("SET wps_cred_processing 0") dev[0].request("SET wps_cred_processing 0")

View file

@ -12,6 +12,7 @@ logger = logging.getLogger()
import hwsim_utils import hwsim_utils
import hostapd import hostapd
from utils import HwsimSkip
def wait_dfs_event(hapd, event, timeout): def wait_dfs_event(hapd, event, timeout):
dfs_events = [ "DFS-RADAR-DETECTED", "DFS-NEW-CHANNEL", dfs_events = [ "DFS-RADAR-DETECTED", "DFS-NEW-CHANNEL",
@ -68,7 +69,9 @@ def start_dfs_ap(ap, allow_failure=False, ssid="dfs", ht=True, ht40=False,
if state != "DFS": if state != "DFS":
if allow_failure: if allow_failure:
logger.info("Interface state not DFS: " + state) logger.info("Interface state not DFS: " + state)
return None if not os.path.exists("dfs"):
raise HwsimSkip("Assume DFS testing not supported")
raise Exception("Failed to start DFS AP")
raise Exception("Unexpected interface state: " + state) raise Exception("Unexpected interface state: " + state)
return hapd return hapd
@ -84,10 +87,6 @@ def test_dfs(dev, apdev):
"""DFS CAC functionality on clear channel""" """DFS CAC functionality on clear channel"""
try: try:
hapd = start_dfs_ap(apdev[0], allow_failure=True) hapd = start_dfs_ap(apdev[0], allow_failure=True)
if hapd is None:
if not os.path.exists("dfs"):
return "skip"
raise Exception("Failed to start DFS AP")
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70) ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
if "success=1" not in ev: if "success=1" not in ev:
@ -141,10 +140,6 @@ def test_dfs_radar(dev, apdev):
try: try:
hapd2 = None hapd2 = None
hapd = start_dfs_ap(apdev[0], allow_failure=True) hapd = start_dfs_ap(apdev[0], allow_failure=True)
if hapd is None:
if not os.path.exists("dfs"):
return "skip"
raise Exception("Failed to start DFS AP")
time.sleep(1) time.sleep(1)
dfs_simulate_radar(hapd) dfs_simulate_radar(hapd)
@ -231,10 +226,6 @@ def test_dfs_radar_chanlist(dev, apdev):
"""DFS chanlist when radar is detected""" """DFS chanlist when radar is detected"""
try: try:
hapd = start_dfs_ap(apdev[0], chanlist="40 44", allow_failure=True) hapd = start_dfs_ap(apdev[0], chanlist="40 44", allow_failure=True)
if hapd is None:
if not os.path.exists("dfs"):
return "skip"
raise Exception("Failed to start DFS AP")
time.sleep(1) time.sleep(1)
dfs_simulate_radar(hapd) dfs_simulate_radar(hapd)
@ -269,10 +260,6 @@ def test_dfs_radar_chanlist_vht80(dev, apdev):
try: try:
hapd = start_dfs_ap(apdev[0], chanlist="36", ht40=True, vht80=True, hapd = start_dfs_ap(apdev[0], chanlist="36", ht40=True, vht80=True,
allow_failure=True) allow_failure=True)
if hapd is None:
if not os.path.exists("dfs"):
return "skip"
raise Exception("Failed to start DFS AP")
time.sleep(1) time.sleep(1)
dfs_simulate_radar(hapd) dfs_simulate_radar(hapd)
@ -310,10 +297,6 @@ def test_dfs_radar_chanlist_vht20(dev, apdev):
try: try:
hapd = start_dfs_ap(apdev[0], chanlist="36", vht20=True, hapd = start_dfs_ap(apdev[0], chanlist="36", vht20=True,
allow_failure=True) allow_failure=True)
if hapd is None:
if not os.path.exists("dfs"):
return "skip"
raise Exception("Failed to start DFS AP")
time.sleep(1) time.sleep(1)
dfs_simulate_radar(hapd) dfs_simulate_radar(hapd)
@ -348,10 +331,6 @@ def test_dfs_radar_no_ht(dev, apdev):
try: try:
hapd = start_dfs_ap(apdev[0], chanlist="36", ht=False, hapd = start_dfs_ap(apdev[0], chanlist="36", ht=False,
allow_failure=True) allow_failure=True)
if hapd is None:
if not os.path.exists("dfs"):
return "skip"
raise Exception("Failed to start DFS AP")
time.sleep(1) time.sleep(1)
dfs_simulate_radar(hapd) dfs_simulate_radar(hapd)
@ -386,10 +365,6 @@ def test_dfs_radar_ht40minus(dev, apdev):
try: try:
hapd = start_dfs_ap(apdev[0], chanlist="36", ht40minus=True, hapd = start_dfs_ap(apdev[0], chanlist="36", ht40minus=True,
allow_failure=True) allow_failure=True)
if hapd is None:
if not os.path.exists("dfs"):
return "skip"
raise Exception("Failed to start DFS AP")
time.sleep(1) time.sleep(1)
dfs_simulate_radar(hapd) dfs_simulate_radar(hapd)

View file

@ -13,6 +13,7 @@ import threading
import time import time
import hostapd import hostapd
from utils import HwsimSkip
EAP_CODE_REQUEST = 1 EAP_CODE_REQUEST = 1
EAP_CODE_RESPONSE = 2 EAP_CODE_RESPONSE = 2
@ -53,7 +54,7 @@ def start_radius_server(eap_handler):
import pyrad.packet import pyrad.packet
import pyrad.dictionary import pyrad.dictionary
except ImportError: except ImportError:
return None raise HwsimSkip("No pyrad modules available")
class TestServer(pyrad.server.Server): class TestServer(pyrad.server.Server):
def _HandleAuthPacket(self, pkt): def _HandleAuthPacket(self, pkt):
@ -260,8 +261,6 @@ def test_eap_proto(dev, apdev):
return None return None
srv = start_radius_server(eap_handler) srv = start_radius_server(eap_handler)
if srv is None:
return "skip"
try: try:
hapd = start_ap(apdev[0]['ifname']) hapd = start_ap(apdev[0]['ifname'])
@ -528,8 +527,6 @@ def test_eap_proto_sake(dev, apdev):
return sake_challenge(ctx) return sake_challenge(ctx)
srv = start_radius_server(sake_handler) srv = start_radius_server(sake_handler)
if srv is None:
return "skip"
try: try:
hapd = start_ap(apdev[0]['ifname']) hapd = start_ap(apdev[0]['ifname'])
@ -704,8 +701,6 @@ def test_eap_proto_leap(dev, apdev):
return None return None
srv = start_radius_server(leap_handler) srv = start_radius_server(leap_handler)
if srv is None:
return "skip"
try: try:
hapd = start_ap(apdev[0]['ifname']) hapd = start_ap(apdev[0]['ifname'])
@ -766,8 +761,6 @@ def test_eap_proto_md5(dev, apdev):
return None return None
srv = start_radius_server(md5_handler) srv = start_radius_server(md5_handler)
if srv is None:
return "skip"
try: try:
hapd = start_ap(apdev[0]['ifname']) hapd = start_ap(apdev[0]['ifname'])
@ -819,8 +812,6 @@ def test_eap_proto_otp(dev, apdev):
return None return None
srv = start_radius_server(otp_handler) srv = start_radius_server(otp_handler)
if srv is None:
return "skip"
try: try:
hapd = start_ap(apdev[0]['ifname']) hapd = start_ap(apdev[0]['ifname'])
@ -1274,8 +1265,6 @@ def test_eap_proto_gpsk(dev, apdev):
return None return None
srv = start_radius_server(gpsk_handler) srv = start_radius_server(gpsk_handler)
if srv is None:
return "skip"
try: try:
hapd = start_ap(apdev[0]['ifname']) hapd = start_ap(apdev[0]['ifname'])
@ -1582,8 +1571,6 @@ def test_eap_proto_eke(dev, apdev):
return None return None
srv = start_radius_server(eke_handler) srv = start_radius_server(eke_handler)
if srv is None:
return "skip"
try: try:
hapd = start_ap(apdev[0]['ifname']) hapd = start_ap(apdev[0]['ifname'])
@ -1904,8 +1891,6 @@ def test_eap_proto_pax(dev, apdev):
return struct.pack(">BBH", EAP_CODE_FAILURE, ctx['id'], 4) return struct.pack(">BBH", EAP_CODE_FAILURE, ctx['id'], 4)
srv = start_radius_server(pax_handler) srv = start_radius_server(pax_handler)
if srv is None:
return "skip"
try: try:
hapd = start_ap(apdev[0]['ifname']) hapd = start_ap(apdev[0]['ifname'])
@ -2043,8 +2028,6 @@ def test_eap_proto_psk(dev, apdev):
return None return None
srv = start_radius_server(psk_handler) srv = start_radius_server(psk_handler)
if srv is None:
return "skip"
try: try:
hapd = start_ap(apdev[0]['ifname']) hapd = start_ap(apdev[0]['ifname'])
@ -2786,8 +2769,6 @@ def test_eap_proto_aka(dev, apdev):
return None return None
srv = start_radius_server(aka_handler) srv = start_radius_server(aka_handler)
if srv is None:
return "skip"
try: try:
hapd = start_ap(apdev[0]['ifname']) hapd = start_ap(apdev[0]['ifname'])
@ -3133,8 +3114,6 @@ def test_eap_proto_aka_prime(dev, apdev):
return None return None
srv = start_radius_server(aka_prime_handler) srv = start_radius_server(aka_prime_handler)
if srv is None:
return "skip"
try: try:
hapd = start_ap(apdev[0]['ifname']) hapd = start_ap(apdev[0]['ifname'])
@ -3539,8 +3518,6 @@ def test_eap_proto_sim(dev, apdev):
return None return None
srv = start_radius_server(sim_handler) srv = start_radius_server(sim_handler)
if srv is None:
return "skip"
try: try:
hapd = start_ap(apdev[0]['ifname']) hapd = start_ap(apdev[0]['ifname'])
@ -4002,8 +3979,6 @@ def test_eap_proto_ikev2(dev, apdev):
return None return None
srv = start_radius_server(ikev2_handler) srv = start_radius_server(ikev2_handler)
if srv is None:
return "skip"
try: try:
hapd = start_ap(apdev[0]['ifname']) hapd = start_ap(apdev[0]['ifname'])

View file

@ -11,9 +11,15 @@ import os
import time import time
import hostapd import hostapd
from utils import HwsimSkip
from test_ap_eap import int_eap_server_params from test_ap_eap import int_eap_server_params
from test_ap_psk import find_wpas_process, read_process_memory, verify_not_present, get_key_locations from test_ap_psk import find_wpas_process, read_process_memory, verify_not_present, get_key_locations
def check_erp_capa(dev):
capab = dev.get_capability("erp")
if not capab or 'ERP' not in capab:
raise HwsimSkip("ERP not supported in the build")
def test_erp_initiate_reauth_start(dev, apdev): def test_erp_initiate_reauth_start(dev, apdev):
"""Authenticator sending EAP-Initiate/Re-auth-Start, but ERP disabled on peer""" """Authenticator sending EAP-Initiate/Re-auth-Start, but ERP disabled on peer"""
params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
@ -43,9 +49,7 @@ def test_erp_enabled_on_server(dev, apdev):
def test_erp(dev, apdev): def test_erp(dev, apdev):
"""ERP enabled on server and peer""" """ERP enabled on server and peer"""
capab = dev[0].get_capability("erp") check_erp_capa(dev[0])
if not capab or 'ERP' not in capab:
return "skip"
params = int_eap_server_params() params = int_eap_server_params()
params['erp_send_reauth_start'] = '1' params['erp_send_reauth_start'] = '1'
params['erp_domain'] = 'example.com' params['erp_domain'] = 'example.com'
@ -71,9 +75,7 @@ def test_erp(dev, apdev):
def test_erp_server_no_match(dev, apdev): def test_erp_server_no_match(dev, apdev):
"""ERP enabled on server and peer, but server has no key match""" """ERP enabled on server and peer, but server has no key match"""
capab = dev[0].get_capability("erp") check_erp_capa(dev[0])
if not capab or 'ERP' not in capab:
return "skip"
params = int_eap_server_params() params = int_eap_server_params()
params['erp_send_reauth_start'] = '1' params['erp_send_reauth_start'] = '1'
params['erp_domain'] = 'example.com' params['erp_domain'] = 'example.com'
@ -125,9 +127,7 @@ def start_erp_as(apdev):
def test_erp_radius(dev, apdev): def test_erp_radius(dev, apdev):
"""ERP enabled on RADIUS server and peer""" """ERP enabled on RADIUS server and peer"""
capab = dev[0].get_capability("erp") check_erp_capa(dev[0])
if not capab or 'ERP' not in capab:
return "skip"
start_erp_as(apdev[1]) start_erp_as(apdev[1])
params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
params['auth_server_port'] = "18128" params['auth_server_port'] = "18128"
@ -175,9 +175,7 @@ def erp_test(dev, hapd, **kwargs):
def test_erp_radius_eap_methods(dev, apdev): def test_erp_radius_eap_methods(dev, apdev):
"""ERP enabled on RADIUS server and peer""" """ERP enabled on RADIUS server and peer"""
capab = dev[0].get_capability("erp") check_erp_capa(dev[0])
if not capab or 'ERP' not in capab:
return "skip"
start_erp_as(apdev[1]) start_erp_as(apdev[1])
params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
params['auth_server_port'] = "18128" params['auth_server_port'] = "18128"
@ -222,9 +220,7 @@ def test_erp_radius_eap_methods(dev, apdev):
def test_erp_key_lifetime_in_memory(dev, apdev, params): def test_erp_key_lifetime_in_memory(dev, apdev, params):
"""ERP and key lifetime in memory""" """ERP and key lifetime in memory"""
capab = dev[0].get_capability("erp") check_erp_capa(dev[0])
if not capab or 'ERP' not in capab:
return "skip"
p = int_eap_server_params() p = int_eap_server_params()
p['erp_send_reauth_start'] = '1' p['erp_send_reauth_start'] = '1'
p['erp_domain'] = 'example.com' p['erp_domain'] = 'example.com'
@ -298,11 +294,9 @@ def test_erp_key_lifetime_in_memory(dev, apdev, params):
get_key_locations(buf, rRK, "rRK") get_key_locations(buf, rRK, "rRK")
get_key_locations(buf, rIK, "rIK") get_key_locations(buf, rIK, "rIK")
if password not in buf: if password not in buf:
print("Password not found while associated") raise HwsimSkip("Password not found while associated")
return "skip"
if pmk not in buf: if pmk not in buf:
print("PMK not found while associated") raise HwsimSkip("PMK not found while associated")
return "skip"
if kck not in buf: if kck not in buf:
raise Exception("KCK not found while associated") raise Exception("KCK not found while associated")
if kek not in buf: if kek not in buf:

View file

@ -11,6 +11,7 @@ logger = logging.getLogger()
import hwsim_utils import hwsim_utils
import utils import utils
from utils import HwsimSkip
from wlantest import Wlantest from wlantest import Wlantest
from wpasupplicant import WpaSupplicant from wpasupplicant import WpaSupplicant
@ -340,7 +341,7 @@ def test_autogo_chan_switch(dev):
if "FAIL" in res: if "FAIL" in res:
# for now, skip test since mac80211_hwsim support is not yet widely # for now, skip test since mac80211_hwsim support is not yet widely
# deployed # deployed
return 'skip' raise HwsimSkip("Assume mac80211_hwsim did not support channel switching")
ev = dev[0].wait_event(["AP-CSA-FINISHED"], timeout=10) ev = dev[0].wait_event(["AP-CSA-FINISHED"], timeout=10)
if ev is None: if ev is None:
raise Exception("CSA finished event timed out") raise Exception("CSA finished event timed out")

View file

@ -14,6 +14,7 @@ import os
import hostapd import hostapd
import hwsim_utils import hwsim_utils
import utils import utils
from utils import HwsimSkip
from wpasupplicant import WpaSupplicant from wpasupplicant import WpaSupplicant
def check_grpform_results(i_res, r_res): def check_grpform_results(i_res, r_res):
@ -728,8 +729,7 @@ def test_grpform_goneg_fail_with_group_iface(dev):
def test_grpform_cred_ready_timeout(dev, apdev, params): def test_grpform_cred_ready_timeout(dev, apdev, params):
"""P2P GO Negotiation wait for credentials to become ready [long]""" """P2P GO Negotiation wait for credentials to become ready [long]"""
if not params['long']: if not params['long']:
logger.info("Skip test case with long duration due to --long not specified") raise HwsimSkip("Skip test case with long duration due to --long not specified")
return "skip"
dev[1].p2p_listen() dev[1].p2p_listen()
addr1 = dev[1].p2p_dev_addr() addr1 = dev[1].p2p_dev_addr()

View file

@ -15,6 +15,7 @@ import threading
import time import time
import hostapd import hostapd
from utils import HwsimSkip
def connect(dev, ssid, wait_connect=True): def connect(dev, ssid, wait_connect=True):
dev.connect(ssid, key_mgmt="WPA-EAP", scan_freq="2412", dev.connect(ssid, key_mgmt="WPA-EAP", scan_freq="2412",
@ -237,7 +238,7 @@ def test_radius_das_disconnect(dev, apdev):
import pyrad.dictionary import pyrad.dictionary
import radius_das import radius_das
except ImportError: except ImportError:
return "skip" raise HwsimSkip("No pyrad modules available")
params = hostapd.wpa2_eap_params(ssid="radius-das") params = hostapd.wpa2_eap_params(ssid="radius-das")
params['radius_das_port'] = "3799" params['radius_das_port'] = "3799"
@ -504,7 +505,7 @@ def test_radius_das_coa(dev, apdev):
import pyrad.dictionary import pyrad.dictionary
import radius_das import radius_das
except ImportError: except ImportError:
return "skip" raise HwsimSkip("No pyrad modules available")
params = hostapd.wpa2_eap_params(ssid="radius-das") params = hostapd.wpa2_eap_params(ssid="radius-das")
params['radius_das_port'] = "3799" params['radius_das_port'] = "3799"
@ -626,7 +627,7 @@ def test_radius_protocol(dev, apdev):
import pyrad.packet import pyrad.packet
import pyrad.dictionary import pyrad.dictionary
except ImportError: except ImportError:
return "skip" raise HwsimSkip("No pyrad modules available")
class TestServer(pyrad.server.Server): class TestServer(pyrad.server.Server):
def _HandleAuthPacket(self, pkt): def _HandleAuthPacket(self, pkt):
@ -734,7 +735,7 @@ def test_radius_psk(dev, apdev):
import pyrad.packet import pyrad.packet
import pyrad.dictionary import pyrad.dictionary
except ImportError: except ImportError:
return "skip" raise HwsimSkip("No pyrad modules available")
class TestServer(pyrad.server.Server): class TestServer(pyrad.server.Server):
def _HandleAuthPacket(self, pkt): def _HandleAuthPacket(self, pkt):

View file

@ -13,6 +13,7 @@ from hostapd import HostapdGlobal
import hwsim_utils import hwsim_utils
from wpasupplicant import WpaSupplicant from wpasupplicant import WpaSupplicant
from rfkill import RFKill from rfkill import RFKill
from utils import HwsimSkip
def get_rfkill(dev): def get_rfkill(dev):
phy = dev.get_driver_status_field("phyname") phy = dev.get_driver_status_field("phyname")
@ -21,15 +22,12 @@ def get_rfkill(dev):
if r.name == phy: if r.name == phy:
return r return r
except Exception, e: except Exception, e:
logger.info("No rfkill available: " + str(e)) raise HwsimSkip("No rfkill available: " + str(e))
raise HwsimSkip("No rfkill match found for the interface")
return None
def test_rfkill_open(dev, apdev): def test_rfkill_open(dev, apdev):
"""rfkill block/unblock during open mode connection""" """rfkill block/unblock during open mode connection"""
rfk = get_rfkill(dev[0]) rfk = get_rfkill(dev[0])
if rfk is None:
return "skip"
hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" }) hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" })
dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") dev[0].connect("open", key_mgmt="NONE", scan_freq="2412")
@ -59,8 +57,6 @@ def test_rfkill_open(dev, apdev):
def test_rfkill_wpa2_psk(dev, apdev): def test_rfkill_wpa2_psk(dev, apdev):
"""rfkill block/unblock during WPA2-PSK connection""" """rfkill block/unblock during WPA2-PSK connection"""
rfk = get_rfkill(dev[0]) rfk = get_rfkill(dev[0])
if rfk is None:
return "skip"
ssid = "test-wpa2-psk" ssid = "test-wpa2-psk"
passphrase = 'qwertyuiop' passphrase = 'qwertyuiop'
@ -84,11 +80,7 @@ def test_rfkill_wpa2_psk(dev, apdev):
def test_rfkill_autogo(dev, apdev): def test_rfkill_autogo(dev, apdev):
"""rfkill block/unblock for autonomous P2P GO""" """rfkill block/unblock for autonomous P2P GO"""
rfk0 = get_rfkill(dev[0]) rfk0 = get_rfkill(dev[0])
if rfk0 is None:
return "skip"
rfk1 = get_rfkill(dev[1]) rfk1 = get_rfkill(dev[1])
if rfk1 is None:
return "skip"
dev[0].p2p_start_go() dev[0].p2p_start_go()
dev[1].request("SET p2p_no_group_iface 0") dev[1].request("SET p2p_no_group_iface 0")
@ -129,8 +121,6 @@ def test_rfkill_hostapd(dev, apdev):
hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" }) hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" })
rfk = get_rfkill(hapd) rfk = get_rfkill(hapd)
if rfk is None:
return "skip"
try: try:
rfk.block() rfk.block()
@ -169,8 +159,6 @@ def test_rfkill_wpas(dev, apdev):
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
wpas.interface_add("wlan5") wpas.interface_add("wlan5")
rfk = get_rfkill(wpas) rfk = get_rfkill(wpas)
if rfk is None:
return "skip"
wpas.interface_remove("wlan5") wpas.interface_remove("wlan5")
try: try:
rfk.block() rfk.block()

View file

@ -13,6 +13,7 @@ logger = logging.getLogger()
import hwsim_utils import hwsim_utils
import hostapd import hostapd
from utils import HwsimSkip
from test_ap_psk import find_wpas_process, read_process_memory, verify_not_present, get_key_locations from test_ap_psk import find_wpas_process, read_process_memory, verify_not_present, get_key_locations
def test_sae(dev, apdev): def test_sae(dev, apdev):
@ -228,11 +229,9 @@ def test_sae_key_lifetime_in_memory(dev, apdev, params):
get_key_locations(buf, password, "Password") get_key_locations(buf, password, "Password")
get_key_locations(buf, pmk, "PMK") get_key_locations(buf, pmk, "PMK")
if password not in buf: if password not in buf:
print("Password not found while associated") raise HwsimSkip("Password not found while associated")
return "skip"
if pmk not in buf: if pmk not in buf:
print("PMK not found while associated") raise HwsimSkip("PMK not found while associated")
return "skip"
if kck not in buf: if kck not in buf:
raise Exception("KCK not found while associated") raise Exception("KCK not found while associated")
if kek not in buf: if kek not in buf:

View file

@ -9,11 +9,12 @@ import logging
logger = logging.getLogger() logger = logging.getLogger()
import hostapd import hostapd
from utils import HwsimSkip
def test_suite_b(dev, apdev): def test_suite_b(dev, apdev):
"""WPA2-PSK/GCMP connection""" """WPA2-PSK/GCMP connection"""
if "GCMP" not in dev[0].get_capability("pairwise"): if "GCMP" not in dev[0].get_capability("pairwise"):
return "skip" raise HwsimSkip("GCMP not supported")
params = hostapd.wpa2_eap_params(ssid="test-suite-b") params = hostapd.wpa2_eap_params(ssid="test-suite-b")
params["wpa_key_mgmt"] = "WPA-EAP-SUITE-B" params["wpa_key_mgmt"] = "WPA-EAP-SUITE-B"
params['rsn_pairwise'] = "GCMP" params['rsn_pairwise'] = "GCMP"

View file

@ -8,6 +8,7 @@
import os.path import os.path
import hostapd import hostapd
from utils import HwsimSkip
from test_ap_eap import int_eap_server_params from test_ap_eap import int_eap_server_params
def test_tnc_peap_soh(dev, apdev): def test_tnc_peap_soh(dev, apdev):
@ -47,8 +48,7 @@ def test_tnc_ttls(dev, apdev):
hostapd.add_ap(apdev[0]['ifname'], params) hostapd.add_ap(apdev[0]['ifname'], params)
if not os.path.exists("tnc/libhostap_imc.so"): if not os.path.exists("tnc/libhostap_imc.so"):
logger.info("No IMC installed - skip") raise HwsimSkip("No IMC installed")
return "skip"
dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP",
eap="TTLS", identity="DOMAIN\mschapv2 user", eap="TTLS", identity="DOMAIN\mschapv2 user",
@ -69,8 +69,7 @@ def test_tnc_fast(dev, apdev):
hostapd.add_ap(apdev[0]['ifname'], params) hostapd.add_ap(apdev[0]['ifname'], params)
if not os.path.exists("tnc/libhostap_imc.so"): if not os.path.exists("tnc/libhostap_imc.so"):
logger.info("No IMC installed - skip") raise HwsimSkip("No IMC installed")
return "skip"
dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP",
eap="FAST", identity="user", eap="FAST", identity="user",

View file

@ -1,5 +1,5 @@
# Deprecated WEXT driver interface in wpa_supplicant # Deprecated WEXT driver interface in wpa_supplicant
# Copyright (c) 2013-2014, Jouni Malinen <j@w1.fi> # Copyright (c) 2013-2015, Jouni Malinen <j@w1.fi>
# #
# This software may be distributed under the terms of the BSD license. # This software may be distributed under the terms of the BSD license.
# See README for more details. # See README for more details.
@ -11,26 +11,23 @@ import os
import hostapd import hostapd
import hwsim_utils import hwsim_utils
from wpasupplicant import WpaSupplicant from wpasupplicant import WpaSupplicant
from utils import HwsimSkip
from test_rfkill import get_rfkill from test_rfkill import get_rfkill
def get_wext_interface(): def get_wext_interface():
if not os.path.exists("/proc/net/wireless"): if not os.path.exists("/proc/net/wireless"):
logger.info("WEXT support not included in the kernel") raise HwsimSkip("WEXT support not included in the kernel")
return
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
try: try:
wpas.interface_add("wlan5", driver="wext") wpas.interface_add("wlan5", driver="wext")
except Exception, e: except Exception, e:
logger.info("WEXT driver support not included in wpa_supplicant") raise HwsimSkip("WEXT driver support not included in wpa_supplicant")
return
return wpas return wpas
def test_wext_open(dev, apdev): def test_wext_open(dev, apdev):
"""WEXT driver interface with open network""" """WEXT driver interface with open network"""
wpas = get_wext_interface() wpas = get_wext_interface()
if not wpas:
return "skip"
params = { "ssid": "wext-open" } params = { "ssid": "wext-open" }
hapd = hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
@ -41,8 +38,6 @@ def test_wext_open(dev, apdev):
def test_wext_wpa2_psk(dev, apdev): def test_wext_wpa2_psk(dev, apdev):
"""WEXT driver interface with WPA2-PSK""" """WEXT driver interface with WPA2-PSK"""
wpas = get_wext_interface() wpas = get_wext_interface()
if not wpas:
return "skip"
params = hostapd.wpa2_params(ssid="wext-wpa2-psk", passphrase="12345678") params = hostapd.wpa2_params(ssid="wext-wpa2-psk", passphrase="12345678")
hapd = hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
@ -59,14 +54,12 @@ def test_wext_wpa2_psk(dev, apdev):
def test_wext_wpa_psk(dev, apdev): def test_wext_wpa_psk(dev, apdev):
"""WEXT driver interface with WPA-PSK""" """WEXT driver interface with WPA-PSK"""
wpas = get_wext_interface() wpas = get_wext_interface()
if not wpas:
return "skip"
params = hostapd.wpa_params(ssid="wext-wpa-psk", passphrase="12345678") params = hostapd.wpa_params(ssid="wext-wpa-psk", passphrase="12345678")
hapd = hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
testfile = "/sys/kernel/debug/ieee80211/%s/netdev:%s/tkip_mic_test" % (hapd.get_driver_status_field("phyname"), apdev[0]['ifname']) testfile = "/sys/kernel/debug/ieee80211/%s/netdev:%s/tkip_mic_test" % (hapd.get_driver_status_field("phyname"), apdev[0]['ifname'])
if not os.path.exists(testfile): if not os.path.exists(testfile):
return "skip" raise HwsimSkip("tkip_mic_test not supported in mac80211")
wpas.connect("wext-wpa-psk", psk="12345678") wpas.connect("wext-wpa-psk", psk="12345678")
hwsim_utils.test_connectivity(wpas, hapd) hwsim_utils.test_connectivity(wpas, hapd)
@ -87,8 +80,6 @@ def test_wext_wpa_psk(dev, apdev):
def test_wext_pmksa_cache(dev, apdev): def test_wext_pmksa_cache(dev, apdev):
"""PMKSA caching with WEXT""" """PMKSA caching with WEXT"""
wpas = get_wext_interface() wpas = get_wext_interface()
if not wpas:
return "skip"
params = hostapd.wpa2_eap_params(ssid="test-pmksa-cache") params = hostapd.wpa2_eap_params(ssid="test-pmksa-cache")
hostapd.add_ap(apdev[0]['ifname'], params) hostapd.add_ap(apdev[0]['ifname'], params)
@ -155,8 +146,6 @@ def test_wext_pmksa_cache(dev, apdev):
def test_wext_wep_open_auth(dev, apdev): def test_wext_wep_open_auth(dev, apdev):
"""WEP Open System authentication""" """WEP Open System authentication"""
wpas = get_wext_interface() wpas = get_wext_interface()
if not wpas:
return "skip"
hapd = hostapd.add_ap(apdev[0]['ifname'], hapd = hostapd.add_ap(apdev[0]['ifname'],
{ "ssid": "wep-open", { "ssid": "wep-open",
@ -170,8 +159,6 @@ def test_wext_wep_open_auth(dev, apdev):
def test_wext_wep_shared_key_auth(dev, apdev): def test_wext_wep_shared_key_auth(dev, apdev):
"""WEP Shared Key authentication""" """WEP Shared Key authentication"""
wpas = get_wext_interface() wpas = get_wext_interface()
if not wpas:
return "skip"
hapd = hostapd.add_ap(apdev[0]['ifname'], hapd = hostapd.add_ap(apdev[0]['ifname'],
{ "ssid": "wep-shared-key", { "ssid": "wep-shared-key",
@ -188,8 +175,6 @@ def test_wext_wep_shared_key_auth(dev, apdev):
def test_wext_pmf(dev, apdev): def test_wext_pmf(dev, apdev):
"""WEXT driver interface with WPA2-PSK and PMF""" """WEXT driver interface with WPA2-PSK and PMF"""
wpas = get_wext_interface() wpas = get_wext_interface()
if not wpas:
return "skip"
params = hostapd.wpa2_params(ssid="wext-wpa2-psk", passphrase="12345678") params = hostapd.wpa2_params(ssid="wext-wpa2-psk", passphrase="12345678")
params["wpa_key_mgmt"] = "WPA-PSK-SHA256"; params["wpa_key_mgmt"] = "WPA-PSK-SHA256";
@ -208,8 +193,6 @@ def test_wext_pmf(dev, apdev):
def test_wext_scan_hidden(dev, apdev): def test_wext_scan_hidden(dev, apdev):
"""WEXT with hidden SSID""" """WEXT with hidden SSID"""
wpas = get_wext_interface() wpas = get_wext_interface()
if not wpas:
return "skip"
hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-scan", hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-scan",
"ignore_broadcast_ssid": "1" }) "ignore_broadcast_ssid": "1" })
@ -244,13 +227,9 @@ def test_wext_rfkill(dev, apdev):
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
wpas.interface_add("wlan5") wpas.interface_add("wlan5")
rfk = get_rfkill(wpas) rfk = get_rfkill(wpas)
if rfk is None:
return "skip"
wpas.interface_remove("wlan5") wpas.interface_remove("wlan5")
wpas = get_wext_interface() wpas = get_wext_interface()
if not wpas:
return "skip"
hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" }) hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" })
wpas.connect("open", key_mgmt="NONE", scan_freq="2412") wpas.connect("open", key_mgmt="NONE", scan_freq="2412")

View file

@ -11,12 +11,12 @@ logger = logging.getLogger()
import hwsim_utils import hwsim_utils
from wpasupplicant import WpaSupplicant from wpasupplicant import WpaSupplicant
from utils import HwsimSkip
def mesh_supported(dev): def check_mesh_support(dev):
flags = int(dev.get_driver_status_field('capa.flags'), 16) flags = int(dev.get_driver_status_field('capa.flags'), 16)
if flags & 0x100000000: if flags & 0x100000000 == 0:
return True raise HwsimSkip("Driver does not support mesh")
return False
def check_mesh_scan(dev, params, other_started=False, beacon_int=0): def check_mesh_scan(dev, params, other_started=False, beacon_int=0):
if not other_started: if not other_started:
@ -116,8 +116,7 @@ def add_open_mesh_network(dev, ht_mode=False, freq="2412", start=True,
def test_wpas_mesh_group_added(dev): def test_wpas_mesh_group_added(dev):
"""wpa_supplicant MESH group add""" """wpa_supplicant MESH group add"""
if not mesh_supported(dev[0]): check_mesh_support(dev[0])
return "skip"
add_open_mesh_network(dev[0]) add_open_mesh_network(dev[0])
# Check for MESH-GROUP-STARTED event # Check for MESH-GROUP-STARTED event
@ -126,8 +125,7 @@ def test_wpas_mesh_group_added(dev):
def test_wpas_mesh_group_remove(dev): def test_wpas_mesh_group_remove(dev):
"""wpa_supplicant MESH group remove""" """wpa_supplicant MESH group remove"""
if not mesh_supported(dev[0]): check_mesh_support(dev[0])
return "skip"
add_open_mesh_network(dev[0], ht_mode="NOHT") add_open_mesh_network(dev[0], ht_mode="NOHT")
# Check for MESH-GROUP-STARTED event # Check for MESH-GROUP-STARTED event
check_mesh_group_added(dev[0]) check_mesh_group_added(dev[0])
@ -138,8 +136,7 @@ def test_wpas_mesh_group_remove(dev):
def test_wpas_mesh_peer_connected(dev): def test_wpas_mesh_peer_connected(dev):
"""wpa_supplicant MESH peer connected""" """wpa_supplicant MESH peer connected"""
if not mesh_supported(dev[0]): check_mesh_support(dev[0])
return "skip"
add_open_mesh_network(dev[0], ht_mode="HT20", beacon_int=160) add_open_mesh_network(dev[0], ht_mode="HT20", beacon_int=160)
add_open_mesh_network(dev[1], ht_mode="HT20", beacon_int=160) add_open_mesh_network(dev[1], ht_mode="HT20", beacon_int=160)
@ -154,8 +151,7 @@ def test_wpas_mesh_peer_connected(dev):
def test_wpas_mesh_peer_disconnected(dev): def test_wpas_mesh_peer_disconnected(dev):
"""wpa_supplicant MESH peer disconnected""" """wpa_supplicant MESH peer disconnected"""
if not mesh_supported(dev[0]): check_mesh_support(dev[0])
return "skip"
add_open_mesh_network(dev[0]) add_open_mesh_network(dev[0])
add_open_mesh_network(dev[1]) add_open_mesh_network(dev[1])
@ -175,8 +171,7 @@ def test_wpas_mesh_peer_disconnected(dev):
def test_wpas_mesh_mode_scan(dev): def test_wpas_mesh_mode_scan(dev):
"""wpa_supplicant MESH scan support""" """wpa_supplicant MESH scan support"""
if not mesh_supported(dev[0]): check_mesh_support(dev[0])
return "skip"
add_open_mesh_network(dev[0], ht_mode="HT40+") add_open_mesh_network(dev[0], ht_mode="HT40+")
add_open_mesh_network(dev[1], ht_mode="HT40+", beacon_int=175) add_open_mesh_network(dev[1], ht_mode="HT40+", beacon_int=175)
@ -189,8 +184,7 @@ def test_wpas_mesh_mode_scan(dev):
def test_wpas_mesh_open(dev, apdev): def test_wpas_mesh_open(dev, apdev):
"""wpa_supplicant open MESH network connectivity""" """wpa_supplicant open MESH network connectivity"""
if not mesh_supported(dev[0]): check_mesh_support(dev[0])
return "skip"
add_open_mesh_network(dev[0], ht_mode="HT40-", freq="2462") add_open_mesh_network(dev[0], ht_mode="HT40-", freq="2462")
add_open_mesh_network(dev[1], ht_mode="HT40-", freq="2462") add_open_mesh_network(dev[1], ht_mode="HT40-", freq="2462")
@ -207,8 +201,7 @@ def test_wpas_mesh_open(dev, apdev):
def test_wpas_mesh_open_no_auto(dev, apdev): def test_wpas_mesh_open_no_auto(dev, apdev):
"""wpa_supplicant open MESH network connectivity""" """wpa_supplicant open MESH network connectivity"""
if not mesh_supported(dev[0]): check_mesh_support(dev[0])
return "skip"
id = add_open_mesh_network(dev[0], start=False) id = add_open_mesh_network(dev[0], start=False)
dev[0].set_network(id, "dot11MeshMaxRetries", "16") dev[0].set_network(id, "dot11MeshMaxRetries", "16")
dev[0].set_network(id, "dot11MeshRetryTimeout", "255") dev[0].set_network(id, "dot11MeshRetryTimeout", "255")
@ -241,8 +234,7 @@ def add_mesh_secure_net(dev, psk=True):
def test_wpas_mesh_secure(dev, apdev): def test_wpas_mesh_secure(dev, apdev):
"""wpa_supplicant secure MESH network connectivity""" """wpa_supplicant secure MESH network connectivity"""
if not mesh_supported(dev[0]): check_mesh_support(dev[0])
return "skip"
dev[0].request("SET sae_groups ") dev[0].request("SET sae_groups ")
id = add_mesh_secure_net(dev[0]) id = add_mesh_secure_net(dev[0])
dev[0].mesh_group_add(id) dev[0].mesh_group_add(id)
@ -264,8 +256,7 @@ def test_wpas_mesh_secure(dev, apdev):
def test_wpas_mesh_secure_sae_group_mismatch(dev, apdev): def test_wpas_mesh_secure_sae_group_mismatch(dev, apdev):
"""wpa_supplicant secure MESH and SAE group mismatch""" """wpa_supplicant secure MESH and SAE group mismatch"""
if not mesh_supported(dev[0]): check_mesh_support(dev[0])
return "skip"
addr0 = dev[0].p2p_interface_addr() addr0 = dev[0].p2p_interface_addr()
addr1 = dev[1].p2p_interface_addr() addr1 = dev[1].p2p_interface_addr()
addr2 = dev[2].p2p_interface_addr() addr2 = dev[2].p2p_interface_addr()
@ -316,8 +307,7 @@ def test_wpas_mesh_secure_sae_group_mismatch(dev, apdev):
def test_wpas_mesh_secure_sae_missing_password(dev, apdev): def test_wpas_mesh_secure_sae_missing_password(dev, apdev):
"""wpa_supplicant secure MESH and missing SAE password""" """wpa_supplicant secure MESH and missing SAE password"""
if not mesh_supported(dev[0]): check_mesh_support(dev[0])
return "skip"
id = add_mesh_secure_net(dev[0], psk=False) id = add_mesh_secure_net(dev[0], psk=False)
dev[0].set_network(id, "psk", "8f20b381f9b84371d61b5080ad85cac3c61ab3ca9525be5b2d0f4da3d979187a") dev[0].set_network(id, "psk", "8f20b381f9b84371d61b5080ad85cac3c61ab3ca9525be5b2d0f4da3d979187a")
dev[0].mesh_group_add(id) dev[0].mesh_group_add(id)
@ -333,8 +323,7 @@ def test_wpas_mesh_secure_sae_missing_password(dev, apdev):
def test_wpas_mesh_secure_no_auto(dev, apdev): def test_wpas_mesh_secure_no_auto(dev, apdev):
"""wpa_supplicant secure MESH network connectivity""" """wpa_supplicant secure MESH network connectivity"""
if not mesh_supported(dev[0]): check_mesh_support(dev[0])
return "skip"
dev[0].request("SET sae_groups 19") dev[0].request("SET sae_groups 19")
id = add_mesh_secure_net(dev[0]) id = add_mesh_secure_net(dev[0])
dev[0].mesh_group_add(id) dev[0].mesh_group_add(id)
@ -360,8 +349,7 @@ def test_wpas_mesh_secure_no_auto(dev, apdev):
def test_wpas_mesh_ctrl(dev): def test_wpas_mesh_ctrl(dev):
"""wpa_supplicant ctrl_iface mesh command error cases""" """wpa_supplicant ctrl_iface mesh command error cases"""
if not mesh_supported(dev[0]): check_mesh_support(dev[0])
return "skip"
if "FAIL" not in dev[0].request("MESH_GROUP_ADD 123"): if "FAIL" not in dev[0].request("MESH_GROUP_ADD 123"):
raise Exception("Unexpected MESH_GROUP_ADD success") raise Exception("Unexpected MESH_GROUP_ADD success")
id = dev[0].add_network() id = dev[0].add_network()
@ -377,8 +365,7 @@ def test_wpas_mesh_ctrl(dev):
def test_wpas_mesh_dynamic_interface(dev): def test_wpas_mesh_dynamic_interface(dev):
"""wpa_supplicant mesh with dynamic interface""" """wpa_supplicant mesh with dynamic interface"""
if not mesh_supported(dev[0]): check_mesh_support(dev[0])
return "skip"
mesh0 = None mesh0 = None
mesh1 = None mesh1 = None
try: try:
@ -455,8 +442,7 @@ def test_wpas_mesh_dynamic_interface(dev):
def test_wpas_mesh_max_peering(dev, apdev): def test_wpas_mesh_max_peering(dev, apdev):
"""Mesh max peering limit""" """Mesh max peering limit"""
if not mesh_supported(dev[0]): check_mesh_support(dev[0])
return "skip"
try: try:
dev[0].request("SET max_peer_links 1") dev[0].request("SET max_peer_links 1")