[PATCH] tests: Make wpas_config_file test more robust

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Avraham Stern <avraham.stern@xxxxxxxxx>

When saving a configuration, many fields are only saved only if
they are set to a value different than the default value.
So if the test sets a field to its default value and than saves
the configuration, this value will not be saved to the config file
and the test will fail. This requires this test to be updated if
default values are changed.

Fix that by only verifying that fields that are set to a non-default
value are written to the saved configuration.

Signed-off-by: Avraham Stern <avraham.stern@xxxxxxxxx>
---
 tests/hwsim/test_wpas_config.py | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/tests/hwsim/test_wpas_config.py b/tests/hwsim/test_wpas_config.py
index 12cb6e8..52ecbf7 100644
--- a/tests/hwsim/test_wpas_config.py
+++ b/tests/hwsim/test_wpas_config.py
@@ -121,7 +121,7 @@ config_checks = [ ("ap_scan", "0"),
                   ("fst_priority", "5"),
                   ("fst_llt", "7"),
                   ("openssl_ciphers", "DEFAULT") ]
-def check_config(config):
+def check_config(config, exclude=[]):
     with open(config, "r") as f:
         data = f.read()
     if "ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=" not in data:
@@ -133,10 +133,17 @@ def check_config(config):
     if "network={" not in data:
         raise Exception("Missing network")
     for field, value in config_checks:
-        if "\n" + field + "=" + value + "\n" not in data:
+        if field not in exclude and "\n" + field + "=" + value + "\n" not in data:
             raise Exception("Missing value: " + field)
     return data
 
+def check_defaults(dev):
+    exclude = []
+    for field, value in config_checks:
+        if dev.request("GET " + field) == value:
+	    exclude.append(field)
+    return exclude
+
 def test_wpas_config_file(dev, apdev, params):
     """wpa_supplicant config file parsing/writing"""
     config = os.path.join(params['logdir'], 'wpas_config_file.conf')
@@ -172,6 +179,8 @@ def test_wpas_config_file(dev, apdev, params):
 
         wpas.interface_add("wlan5", config=config)
 
+        exclude = check_defaults(wpas)
+
         id = wpas.add_network()
         wpas.set_network_quoted(id, "ssid", "foo")
         wpas.set_network_quoted(id, "psk", "12345678")
@@ -213,7 +222,7 @@ def test_wpas_config_file(dev, apdev, params):
             raise Exception("Failed to save configuration file")
 
         wpas.interface_remove("wlan5")
-        data1 = check_config(config)
+        data1 = check_config(config, exclude)
 
         wpas.interface_add("wlan5", config=config)
         if len(wpas.list_networks()) != 1:
@@ -223,7 +232,7 @@ def test_wpas_config_file(dev, apdev, params):
 
         if "OK" not in wpas.request("SAVE_CONFIG"):
             raise Exception("Failed to save configuration file")
-        data2 = check_config(config)
+        data2 = check_config(config, exclude)
 
         if data1 != data2:
             logger.debug(data1)
-- 
1.9.1


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux