diff mbox

tests: Add an option to use random ssids for remote tests

Message ID 20160719204959.9392-1-jonathan@wizery.com
State Changes Requested
Headers show

Commit Message

Jonathan Afek July 19, 2016, 8:49 p.m. UTC
More than one instance of a remote test can be executed
in a signle room. This option will make the different
instances use different ssids.

Signed-off-by: Jonathan Afek <jonathanx.afek@intel.com>
---
 tests/hwsim/hostapd.py        | 7 ++++++-
 tests/hwsim/wpasupplicant.py  | 8 ++++++--
 tests/remote/hwsim_wrapper.py | 4 ++++
 tests/remote/rutils.py        | 8 ++++++++
 4 files changed, 24 insertions(+), 3 deletions(-)

Comments

Jouni Malinen Dec. 5, 2016, 6:46 p.m. UTC | #1
On Tue, Jul 19, 2016 at 11:49:59PM +0300, Jonathan Afek wrote:
> More than one instance of a remote test can be executed
> in a signle room. This option will make the different
> instances use different ssids.

This is a bit problematic change for number of test cases since there
are various checks and operations depending on the exact SSID. Based on
a quick test, almost 100 test cases fail because of that (see list
below).

If we want to get this included in hostap.git, it would likely be a good
idea to make this more generic by allowing it to be run (as an optional
functionality) as part of the local mac80211_hwsim test cases in
addition to the remote test cases. That makes it quite a bit more
convenient to verify full implications to the test cases.

> diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py
> @@ -406,7 +406,12 @@ def add_ap(apdev, params, wait_enabled=True, no_enable=False, timeout=30):
> -                hapd.set(field, params[field])
> +                if hostname is not None and field in ["ssid", "ssid2"]:
> +                    import rutils
> +                    prefix = rutils.RandomSsid.ssid_prefix
> +                    hapd.set(field, prefix + params[field])
> +                else:
> +                    hapd.set(field, params[field])

That ssid2 part is problematic since the ssid2 value can start with the
'"' and 'P"' prefixes. Neither of those cases would work correctly if
this random prefix is added. The third option (hexdump) would work, but
this ssid2 change would need more logic here to handle all possible
cases.

Adding any prefix to SSID would also need to take into account
possibility of going beyond the 32 octet limit, i.e., the changes here
should be conditional on there being sufficient room for the extra
prefix.

> diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py
>      def connect(self, ssid=None, ssid2=None, **kwargs):
> +        prefix = ""
> +        if self.hostname is not None:
> +            import rutils
> +            prefix = rutils.RandomSsid.ssid_prefix
>          if ssid:
> -            self.set_network_quoted(id, "ssid", ssid)
> +            self.set_network_quoted(id, "ssid", prefix + ssid)
>          elif ssid2:
> -            self.set_network(id, "ssid", ssid2)
> +            self.set_network(id, "ssid", prefix + ssid2)

> diff --git a/tests/remote/rutils.py b/tests/remote/rutils.py
> +class RandomSsid(object):

tests/hwsim/utils.py could be more useful location for this to allow the
local test cases to be used to check this functionality as well.


At least these test cases seemed to fail with the SSID prefix added:

ap_pmf_sta_unprot_deauth_burst dbus_ap_scan_2_ap_mode_scan
ap_wpa2_psk_drop_first_msg_4 dbus_connect scan_specify_ssid wpas_ap_open
ap_vlan_iface_cleanup_multibss_per_sta_vif
wps_ext_cred_proto_mac_addr_mismatch autogo_legacy
ap_vlan_iface_cleanup_multibss scan_hidden_many
nfc_wps_config_token_init wpas_ap_wps_disabled wpas_ap_acs dfs
ap_wpa2_psk_wildcard_ssid wpas_ap_open_ht_disabled dbus_connect_psk_mem
nfc_wps_handover_init ap_wpa2_eap_sim_no_change_set ap_multi_bss_acs
nfc_wps_handover_5ghz nfc_wps_er_handover ap_wps_conf
ap_hs20_network_preference2 sta_ap_scan_0 ap_multi_bss_config
dbus_assoc_reject wps_ext_cred_proto_zero_padding
ap_hs20_network_preference ap_pmf_sta_sa_query_oom
monitor_iface_multi_bss nfc_wps_handover autogo_passphrase_len
ap_hs20_excluded_ssid ap_bss_add_remove nfc_wps_password_token_sta_init
ap_wpa2_psk_ext_retry_msg_3 ap_cipher_mixed_wpa_wpa2 ap_wps_init
monitor_iface_open ap_wps_reg_connect_mixed_mode ap_pmf_sta_sa_query
wpas_ap_default_frequency dfs_radar_chanlist dfs_radar ap_wpa2_psk_ext
scan_ap_scan_2_ap_mode nfc_wps_handover_chan14
nfc_wps_password_token_sta dbus_connect_wpa_eap ap_wps_er_config_ap
dfs_radar_chanlist_vht80 dbus_old_connect hapd_ctrl_status
monitor_iface_wpa2_psk nfc_wps_er_config_token
wpas_ctrl_interface_add_ap sta_ap_scan_2 dfs_radar_ht40minus dbus_ap
ap_pmf_sta_sa_query_no_response wpas_ap_wep ap_cli_order
wpas_ctrl_dup_network_global ap_open_unexpected_assoc_event
nfc_wps_config_token wpas_ctrl_disallow_aps wps_ext_cred_proto_success
ap_pmf_sta_sa_query_local_failure wpas_ap_dfs
ap_bss_add_remove_during_ht_scan ap_wpa2_psk radius_acct_non_ascii_ssid
nfc_wps_handover_with_pw_token_set nfc_wps_er_pw_token
wpas_ap_and_assoc_req_p2p_ie wpas_ctrl_dup_network ap_wps_conf_pin
ap_wps_init_through_wps_config dfs_radar_no_ht ap_open_external_assoc
ssid_hex_encoded ap_bss_add_many ap_wps_reg_override_ap_settings
ap_enable_disable_reenable ap_multi_bss ap_wps_reg_connect
dfs_radar_chanlist_vht20 ap_invalid_config
wpa2_psk_key_lifetime_in_memory dbus_old_connect_eap ap_add_with_driver
ap_hs20_disallow_aps ap_wpa2_psk_mem dbus_connect_eap
diff mbox

Patch

diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py
index 51ad02e..65126a0 100644
--- a/tests/hwsim/hostapd.py
+++ b/tests/hwsim/hostapd.py
@@ -406,7 +406,12 @@  def add_ap(apdev, params, wait_enabled=True, no_enable=False, timeout=30):
                    "acct_server_addr", "osu_server_uri" ]
         for field in fields:
             if field in params:
-                hapd.set(field, params[field])
+                if hostname is not None and field in ["ssid", "ssid2"]:
+                    import rutils
+                    prefix = rutils.RandomSsid.ssid_prefix
+                    hapd.set(field, prefix + params[field])
+                else:
+                    hapd.set(field, params[field])
         for f,v in params.items():
             if f in fields:
                 continue
diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py
index d50a4c8..bb03ab1 100644
--- a/tests/hwsim/wpasupplicant.py
+++ b/tests/hwsim/wpasupplicant.py
@@ -982,10 +982,14 @@  class WpaSupplicant:
     def connect(self, ssid=None, ssid2=None, **kwargs):
         logger.info("Connect STA " + self.ifname + " to AP")
         id = self.add_network()
+        prefix = ""
+        if self.hostname is not None:
+            import rutils
+            prefix = rutils.RandomSsid.ssid_prefix
         if ssid:
-            self.set_network_quoted(id, "ssid", ssid)
+            self.set_network_quoted(id, "ssid", prefix + ssid)
         elif ssid2:
-            self.set_network(id, "ssid", ssid2)
+            self.set_network(id, "ssid", prefix + ssid2)
 
         quoted = [ "psk", "identity", "anonymous_identity", "password",
                    "ca_cert", "client_cert", "private_key",
diff --git a/tests/remote/hwsim_wrapper.py b/tests/remote/hwsim_wrapper.py
index d2598ab..8b28300 100644
--- a/tests/remote/hwsim_wrapper.py
+++ b/tests/remote/hwsim_wrapper.py
@@ -31,6 +31,10 @@  def run_hwsim_test(devices, setup_params, refs, duts, monitors, hwsim_test):
             dut_host = rutils.get_host(devices, dut)
             dut_hosts.append(dut_host)
 
+        # setup random ssid
+        if "random_ssid" in setup_params and setup_params["random_ssid"]:
+            rutils.RandomSsid.set_random_ssid_prefix()
+
         # setup log dir
         local_log_dir = setup_params['local_log_dir']
 
diff --git a/tests/remote/rutils.py b/tests/remote/rutils.py
index 879fadc..fb0d32e 100644
--- a/tests/remote/rutils.py
+++ b/tests/remote/rutils.py
@@ -9,6 +9,14 @@  import time
 from remotehost import Host
 import hostapd
 import config
+import random
+
+class RandomSsid(object):
+    ssid_prefix = ""
+    @classmethod
+    def set_random_ssid_prefix(cls):
+        chars = '0123456789abcdef'
+        cls.ssid_prefix = ''.join(random.choice(chars) for _ in range(4))
 
 class TestSkip(Exception):
     def __init__(self, reason):