tests: Replace subprocess.call for rm with os.remove()
authorJouni Malinen <jouni@qca.qualcomm.com>
Fri, 6 Feb 2015 22:15:01 +0000 (00:15 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 7 Feb 2015 13:37:13 +0000 (15:37 +0200)
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 <jouni@qca.qualcomm.com>
tests/hwsim/test_ap_eap.py
tests/hwsim/test_ap_wps.py

index fb5f15e..183e544 100644 (file)
@@ -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"""
index 8d73d3e..e9a948e 100644 (file)
@@ -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]"""