[PATCH] tests: Add an option to use random ssids for remote tests

Jouni Malinen j at w1.fi
Mon Dec 5 10:46:34 PST 2016

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

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

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

> 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
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
Jouni Malinen                                            PGP id EFC895FA

More information about the Hostap mailing list