From 47dcb1186f2dbd981a414fceef8f99b6c013c79e Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 28 Nov 2014 16:13:06 +0200 Subject: [PATCH] tests: Move external_sim reset to test cases that change this This removes unnecessary reset() step from between every test case. Signed-off-by: Jouni Malinen --- tests/hwsim/test_ap_eap.py | 12 ++++++++++++ tests/hwsim/test_ap_hs20.py | 38 ++++++++++++++++++++++++++---------- tests/hwsim/wpasupplicant.py | 1 - 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/tests/hwsim/test_ap_eap.py b/tests/hwsim/test_ap_eap.py index 092811710..f5a7e6bac 100644 --- a/tests/hwsim/test_ap_eap.py +++ b/tests/hwsim/test_ap_eap.py @@ -247,6 +247,12 @@ def test_ap_wpa2_eap_sim_config(dev, apdev): def test_ap_wpa2_eap_sim_ext(dev, apdev): """WPA2-Enterprise connection using EAP-SIM and external GSM auth""" + try: + return _test_ap_wpa2_eap_sim_ext(dev, apdev) + finally: + dev[0].request("SET external_sim 0") + +def _test_ap_wpa2_eap_sim_ext(dev, apdev): if not os.path.exists("/tmp/hlr_auc_gw.sock"): logger.info("No hlr_auc_gw available"); return "skip" @@ -498,6 +504,12 @@ def test_ap_wpa2_eap_aka_config(dev, apdev): def test_ap_wpa2_eap_aka_ext(dev, apdev): """WPA2-Enterprise connection using EAP-AKA and external UMTS auth""" + try: + return _test_ap_wpa2_eap_aka_ext(dev, apdev) + finally: + dev[0].request("SET external_sim 0") + +def _test_ap_wpa2_eap_aka_ext(dev, apdev): if not os.path.exists("/tmp/hlr_auc_gw.sock"): logger.info("No hlr_auc_gw available"); return "skip" diff --git a/tests/hwsim/test_ap_hs20.py b/tests/hwsim/test_ap_hs20.py index 22a6a2f8c..5e02f160d 100644 --- a/tests/hwsim/test_ap_hs20.py +++ b/tests/hwsim/test_ap_hs20.py @@ -399,11 +399,14 @@ def test_ap_hs20_ext_sim(dev, apdev): hostapd.add_ap(apdev[0]['ifname'], params) dev[0].hs20_enable() - dev[0].request("SET external_sim 1") - dev[0].add_cred_values({ 'imsi': "23201-0000000000", 'eap': "SIM" }) - interworking_select(dev[0], "home", freq="2412") - interworking_ext_sim_connect(dev[0], bssid, "SIM") - check_sp_type(dev[0], "home") + try: + dev[0].request("SET external_sim 1") + dev[0].add_cred_values({ 'imsi': "23201-0000000000", 'eap': "SIM" }) + interworking_select(dev[0], "home", freq="2412") + interworking_ext_sim_connect(dev[0], bssid, "SIM") + check_sp_type(dev[0], "home") + finally: + dev[0].request("SET external_sim 0") def test_ap_hs20_ext_sim_roaming(dev, apdev): """Hotspot 2.0 with external SIM processing in roaming network""" @@ -417,11 +420,14 @@ def test_ap_hs20_ext_sim_roaming(dev, apdev): hostapd.add_ap(apdev[0]['ifname'], params) dev[0].hs20_enable() - dev[0].request("SET external_sim 1") - dev[0].add_cred_values({ 'imsi': "23201-0000000000", 'eap': "SIM" }) - interworking_select(dev[0], "roaming", freq="2412") - interworking_ext_sim_connect(dev[0], bssid, "SIM") - check_sp_type(dev[0], "roaming") + try: + dev[0].request("SET external_sim 1") + dev[0].add_cred_values({ 'imsi': "23201-0000000000", 'eap': "SIM" }) + interworking_select(dev[0], "roaming", freq="2412") + interworking_ext_sim_connect(dev[0], bssid, "SIM") + check_sp_type(dev[0], "roaming") + finally: + dev[0].request("SET external_sim 0") def test_ap_hs20_username(dev, apdev): """Hotspot 2.0 connection in username/password credential""" @@ -1215,6 +1221,12 @@ def test_ap_hs20_max_bss_load2(dev, apdev): def test_ap_hs20_multi_cred_sp_prio(dev, apdev): """Hotspot 2.0 multi-cred sp_priority""" + try: + return _test_ap_hs20_multi_cred_sp_prio(dev, apdev) + finally: + dev[0].request("SET external_sim 0") + +def _test_ap_hs20_multi_cred_sp_prio(dev, apdev): if not hlr_auc_gw_available(): return "skip" bssid = apdev[0]['bssid'] @@ -1252,6 +1264,12 @@ def test_ap_hs20_multi_cred_sp_prio(dev, apdev): def test_ap_hs20_multi_cred_sp_prio2(dev, apdev): """Hotspot 2.0 multi-cred sp_priority with two BSSes""" + try: + return _test_ap_hs20_multi_cred_sp_prio2(dev, apdev) + finally: + dev[0].request("SET external_sim 0") + +def _test_ap_hs20_multi_cred_sp_prio2(dev, apdev): if not hlr_auc_gw_available(): return "skip" bssid = apdev[0]['bssid'] diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index e4788ac36..1ef5ea470 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -93,7 +93,6 @@ class WpaSupplicant: logger.info("FLUSH to " + self.ifname + " failed: " + res) self.request("WPS_ER_STOP") self.request("SET pmf 0") - self.request("SET external_sim 0") self.request("SET hessid 00:00:00:00:00:00") self.request("SET access_network_type 15") self.request("SET p2p_add_cli_chan 0")