tests: Fix wpas_config_file after implementation change
authorJouni Malinen <jouni@qca.qualcomm.com>
Fri, 6 Feb 2015 22:10:04 +0000 (00:10 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 7 Feb 2015 13:37:13 +0000 (15:37 +0200)
The new wpa_supplicant configuration writing design (rename instead of
write to original file) did not fail with the symlink-to-self case, so
replace this with the config file being replaced with a directory. In
addition, get rid of unnecessary use of subprocess since run-tests.py is
running as root nowadays.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
tests/hwsim/test_wpas_config.py

index 223b428..1974f7f 100644 (file)
@@ -7,7 +7,6 @@
 import logging
 logger = logging.getLogger()
 import os
-import subprocess
 
 from wpasupplicant import WpaSupplicant
 
@@ -34,7 +33,7 @@ def test_wpas_config_file(dev):
     """wpa_supplicant config file parsing/writing"""
     config = "/tmp/test_wpas_config_file.conf"
     if os.path.exists(config):
-        subprocess.call(['sudo', 'rm', config])
+        os.remove(config)
 
     wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
     try:
@@ -119,9 +118,9 @@ def test_wpas_config_file(dev):
         if "OK" in wpas.global_request("SAVE_CONFIG"):
             raise Exception("SAVE_CONFIG (global) succeeded unexpectedly")
 
-        # symlink config file to itself to break writing
-        subprocess.call(['rm', config])
-        subprocess.call(['ln', '-s', config, config])
+        # replace the config file with a directory to break writing/renaming
+        os.remove(config)
+        os.mkdir(config)
         wpas.request("SET update_config 1")
         if "OK" in wpas.request("SAVE_CONFIG"):
             raise Exception("SAVE_CONFIG succeeded unexpectedly")
@@ -129,4 +128,11 @@ def test_wpas_config_file(dev):
             raise Exception("SAVE_CONFIG (global) succeeded unexpectedly")
 
     finally:
-        subprocess.call(['sudo', 'rm', config])
+        try:
+            os.remove(config)
+        except:
+            pass
+        try:
+            os.rmdir(config)
+        except:
+            pass