tests: Move WPS_ER_STOP from reset() to test cases

This avoids one more cleanup step between most test cases by stopping ER
only in case it was actually used during a test.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2014-12-13 20:31:44 +02:00
parent d6b916c9db
commit be9f156200
3 changed files with 60 additions and 1 deletions

View file

@ -839,6 +839,12 @@ def test_ap_wps_cancel(dev, apdev):
def test_ap_wps_er_add_enrollee(dev, apdev): def test_ap_wps_er_add_enrollee(dev, apdev):
"""WPS ER configuring AP and adding a new enrollee using PIN""" """WPS ER configuring AP and adding a new enrollee using PIN"""
try:
_test_ap_wps_er_add_enrollee(dev, apdev)
finally:
dev[0].request("WPS_ER_STOP")
def _test_ap_wps_er_add_enrollee(dev, apdev):
ssid = "wps-er-add-enrollee" ssid = "wps-er-add-enrollee"
ap_pin = "12345670" ap_pin = "12345670"
ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e"
@ -967,6 +973,12 @@ def test_ap_wps_er_add_enrollee(dev, apdev):
def test_ap_wps_er_add_enrollee_pbc(dev, apdev): def test_ap_wps_er_add_enrollee_pbc(dev, apdev):
"""WPS ER connected to AP and adding a new enrollee using PBC""" """WPS ER connected to AP and adding a new enrollee using PBC"""
try:
_test_ap_wps_er_add_enrollee_pbc(dev, apdev)
finally:
dev[0].request("WPS_ER_STOP")
def _test_ap_wps_er_add_enrollee_pbc(dev, apdev):
ssid = "wps-er-add-enrollee-pbc" ssid = "wps-er-add-enrollee-pbc"
ap_pin = "12345670" ap_pin = "12345670"
ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e"
@ -1034,6 +1046,12 @@ def test_ap_wps_er_add_enrollee_pbc(dev, apdev):
def test_ap_wps_er_pbc_overlap(dev, apdev): def test_ap_wps_er_pbc_overlap(dev, apdev):
"""WPS ER connected to AP and PBC session overlap""" """WPS ER connected to AP and PBC session overlap"""
try:
_test_ap_wps_er_pbc_overlap(dev, apdev)
finally:
dev[0].request("WPS_ER_STOP")
def _test_ap_wps_er_pbc_overlap(dev, apdev):
ssid = "wps-er-add-enrollee-pbc" ssid = "wps-er-add-enrollee-pbc"
ap_pin = "12345670" ap_pin = "12345670"
ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e"
@ -1087,6 +1105,12 @@ def test_ap_wps_er_pbc_overlap(dev, apdev):
def test_ap_wps_er_v10_add_enrollee_pin(dev, apdev): def test_ap_wps_er_v10_add_enrollee_pin(dev, apdev):
"""WPS v1.0 ER connected to AP and adding a new enrollee using PIN""" """WPS v1.0 ER connected to AP and adding a new enrollee using PIN"""
try:
_test_ap_wps_er_v10_add_enrollee_pin(dev, apdev)
finally:
dev[0].request("WPS_ER_STOP")
def _test_ap_wps_er_v10_add_enrollee_pin(dev, apdev):
ssid = "wps-er-add-enrollee-pbc" ssid = "wps-er-add-enrollee-pbc"
ap_pin = "12345670" ap_pin = "12345670"
ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e"
@ -1137,6 +1161,12 @@ def test_ap_wps_er_v10_add_enrollee_pin(dev, apdev):
def test_ap_wps_er_config_ap(dev, apdev): def test_ap_wps_er_config_ap(dev, apdev):
"""WPS ER configuring AP over UPnP""" """WPS ER configuring AP over UPnP"""
try:
_test_ap_wps_er_config_ap(dev, apdev)
finally:
dev[0].request("WPS_ER_STOP")
def _test_ap_wps_er_config_ap(dev, apdev):
ssid = "wps-er-ap-config" ssid = "wps-er-ap-config"
ap_pin = "12345670" ap_pin = "12345670"
ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e"

View file

@ -411,6 +411,12 @@ def start_ap_er(er, ap, ssid):
def test_nfc_wps_er_pw_token(dev, apdev): def test_nfc_wps_er_pw_token(dev, apdev):
"""WPS NFC password token from Enrollee to ER""" """WPS NFC password token from Enrollee to ER"""
try:
_test_nfc_wps_er_pw_token(dev, apdev)
finally:
dev[0].request("WPS_ER_STOP")
def _test_nfc_wps_er_pw_token(dev, apdev):
ssid = "wps-nfc-er-pw-token" ssid = "wps-nfc-er-pw-token"
start_ap_er(dev[0], apdev[0], ssid) start_ap_er(dev[0], apdev[0], ssid)
hapd = hostapd.Hostapd(apdev[0]['ifname']) hapd = hostapd.Hostapd(apdev[0]['ifname'])
@ -436,6 +442,12 @@ def test_nfc_wps_er_pw_token(dev, apdev):
def test_nfc_wps_er_config_token(dev, apdev): def test_nfc_wps_er_config_token(dev, apdev):
"""WPS NFC configuration token from ER to Enrollee""" """WPS NFC configuration token from ER to Enrollee"""
try:
_test_nfc_wps_er_config_token(dev, apdev)
finally:
dev[0].request("WPS_ER_STOP")
def _test_nfc_wps_er_config_token(dev, apdev):
ssid = "wps-nfc-er-config-token" ssid = "wps-nfc-er-config-token"
start_ap_er(dev[0], apdev[0], ssid) start_ap_er(dev[0], apdev[0], ssid)
hapd = hostapd.Hostapd(apdev[0]['ifname']) hapd = hostapd.Hostapd(apdev[0]['ifname'])
@ -457,6 +469,12 @@ def test_nfc_wps_er_config_token(dev, apdev):
def test_nfc_wps_er_handover(dev, apdev): def test_nfc_wps_er_handover(dev, apdev):
"""WPS NFC connection handover between Enrollee and ER""" """WPS NFC connection handover between Enrollee and ER"""
try:
_test_nfc_wps_er_handover(dev, apdev)
finally:
dev[0].request("WPS_ER_STOP")
def _test_nfc_wps_er_handover(dev, apdev):
ssid = "wps-nfc-er-handover" ssid = "wps-nfc-er-handover"
start_ap_er(dev[0], apdev[0], ssid) start_ap_er(dev[0], apdev[0], ssid)
hapd = hostapd.Hostapd(apdev[0]['ifname']) hapd = hostapd.Hostapd(apdev[0]['ifname'])
@ -481,6 +499,12 @@ def test_nfc_wps_er_handover(dev, apdev):
def test_nfc_wps_er_handover_pk_hash_mismatch_sta(dev, apdev): def test_nfc_wps_er_handover_pk_hash_mismatch_sta(dev, apdev):
"""WPS NFC connection handover with invalid pkhash from station to ER (negative)""" """WPS NFC connection handover with invalid pkhash from station to ER (negative)"""
try:
_test_nfc_wps_er_handover_pk_hash_mismatch_sta(dev, apdev)
finally:
dev[0].request("WPS_ER_STOP")
def _test_nfc_wps_er_handover_pk_hash_mismatch_sta(dev, apdev):
ssid = "wps-nfc-er-handover-pkhash-sta" ssid = "wps-nfc-er-handover-pkhash-sta"
start_ap_er(dev[0], apdev[0], ssid) start_ap_er(dev[0], apdev[0], ssid)
hapd = hostapd.Hostapd(apdev[0]['ifname']) hapd = hostapd.Hostapd(apdev[0]['ifname'])
@ -509,6 +533,12 @@ def test_nfc_wps_er_handover_pk_hash_mismatch_sta(dev, apdev):
def test_nfc_wps_er_handover_pk_hash_mismatch_er(dev, apdev): def test_nfc_wps_er_handover_pk_hash_mismatch_er(dev, apdev):
"""WPS NFC connection handover with invalid pkhash from ER to station (negative)""" """WPS NFC connection handover with invalid pkhash from ER to station (negative)"""
try:
_test_nfc_wps_er_handover_pk_hash_mismatch_er(dev, apdev)
finally:
dev[0].request("WPS_ER_STOP")
def _test_nfc_wps_er_handover_pk_hash_mismatch_er(dev, apdev):
ssid = "wps-nfc-er-handover-pkhash-er" ssid = "wps-nfc-er-handover-pkhash-er"
start_ap_er(dev[0], apdev[0], ssid) start_ap_er(dev[0], apdev[0], ssid)
hapd = hostapd.Hostapd(apdev[0]['ifname']) hapd = hostapd.Hostapd(apdev[0]['ifname'])

View file

@ -91,7 +91,6 @@ class WpaSupplicant:
res = self.request("FLUSH") res = self.request("FLUSH")
if not "OK" in res: if not "OK" in res:
logger.info("FLUSH to " + self.ifname + " failed: " + res) logger.info("FLUSH to " + self.ifname + " failed: " + res)
self.request("WPS_ER_STOP")
self.request("SET pmf 0") self.request("SET pmf 0")
self.request("SET p2p_add_cli_chan 0") self.request("SET p2p_add_cli_chan 0")
self.request("SET p2p_no_go_freq ") self.request("SET p2p_no_go_freq ")