From b638f70316bae7e26fca13505e75ebd9563c8e4e Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 7 Feb 2015 00:15:01 +0200 Subject: [PATCH] tests: Replace subprocess.call for rm with os.remove() There is no need to use sudo and external rm to remove files now that run-tests.py is required to run as root. Signed-off-by: Jouni Malinen --- tests/hwsim/test_ap_eap.py | 10 ++++++++-- tests/hwsim/test_ap_wps.py | 12 +++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/hwsim/test_ap_eap.py b/tests/hwsim/test_ap_eap.py index fb5f15e4b..183e54494 100644 --- a/tests/hwsim/test_ap_eap.py +++ b/tests/hwsim/test_ap_eap.py @@ -2057,8 +2057,14 @@ def test_ap_wpa2_eap_fast_pac_file(dev, apdev, params): phase1="fast_pac_format=binary", pac_file=pac_file2) finally: - subprocess.call(['sudo', 'rm', pac_file]) - subprocess.call(['sudo', 'rm', pac_file2]) + try: + os.remove(pac_file) + except: + pass + try: + os.remove(pac_file2) + except: + pass def test_ap_wpa2_eap_fast_binary_pac(dev, apdev): """WPA2-Enterprise connection using EAP-FAST and binary PAC format""" diff --git a/tests/hwsim/test_ap_wps.py b/tests/hwsim/test_ap_wps.py index 8d73d3e77..e9a948e46 100644 --- a/tests/hwsim/test_ap_wps.py +++ b/tests/hwsim/test_ap_wps.py @@ -1536,7 +1536,7 @@ def test_ap_wps_pin_request_file(dev, apdev): ssid = "wps" pinfile = "/tmp/ap_wps_pin_request_file.log" if os.path.exists(pinfile): - subprocess.call(['sudo', 'rm', pinfile]) + os.remove(pinfile) hostapd.add_ap(apdev[0]['ifname'], { "ssid": ssid, "eap_server": "1", "wps_state": "2", "wps_pin_requests": pinfile, @@ -1564,7 +1564,10 @@ def test_ap_wps_pin_request_file(dev, apdev): if not success: raise Exception("PIN request entry not in the log file") finally: - subprocess.call(['sudo', 'rm', pinfile]) + try: + os.remove(pinfile) + except: + pass def test_ap_wps_auto_setup_with_config_file(dev, apdev): """WPS auto-setup with configuration file""" @@ -1602,7 +1605,10 @@ def test_ap_wps_auto_setup_with_config_file(dev, apdev): if vals['ieee80211n'] != '1' or vals['wps_state'] != '2' or "WPA-PSK" not in vals['wpa_key_mgmt']: raise Exception("Incorrect configuration: " + str(vals)) finally: - subprocess.call(['sudo', 'rm', conffile]) + try: + os.remove(conffile) + except: + pass def test_ap_wps_pbc_timeout(dev, apdev, params): """wpa_supplicant PBC walk time [long]"""