From: Jouni Malinen Date: Fri, 6 Feb 2015 22:10:04 +0000 (+0200) Subject: tests: Fix wpas_config_file after implementation change X-Git-Tag: hostap_2_4~181 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=592015c3c101213df16ccdb675fe50471628ba70;p=thirdparty%2Fhostap.git tests: Fix wpas_config_file after implementation change 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 --- diff --git a/tests/hwsim/test_wpas_config.py b/tests/hwsim/test_wpas_config.py index 223b4287a..1974f7f98 100644 --- a/tests/hwsim/test_wpas_config.py +++ b/tests/hwsim/test_wpas_config.py @@ -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