From: Andrei Otcheretianski Date: Tue, 26 Nov 2024 09:10:18 +0000 (+0200) Subject: tests: Support parsing group formation events without password X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9368dac255c7ae2f1f2438a82b0940e83efc7ca2;p=thirdparty%2Fhostap.git tests: Support parsing group formation events without password P2P2 clients don't acquire group password with PASN SAE pairing. Support parsing GROUP-STARTED events without password. Signed-off-by: Andrei Otcheretianski --- diff --git a/tests/hwsim/test_p2p2.py b/tests/hwsim/test_p2p2.py index 404ae0dc4..14a9217f7 100644 --- a/tests/hwsim/test_p2p2.py +++ b/tests/hwsim/test_p2p2.py @@ -180,13 +180,13 @@ def test_p2p_pairing_password(dev, apdev): ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=10) if ev is None: raise Exception("Group formation timed out") - #dev[0].group_form_result(ev) + dev[0].group_form_result(ev, no_pwd=True) dev[0].dump_monitor() ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=10) if ev is None: raise Exception("Group formation timed out(2)") - #dev[1].group_form_result(ev) + dev[1].group_form_result(ev) dev[1].remove_group() dev[0].wait_go_ending_session() @@ -251,7 +251,7 @@ def test_p2p_pairing_opportunistic(dev, apdev): ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=10) if ev is None: raise Exception("Group formation timed out(2)") - #dev[1].group_form_result(ev) + dev[1].group_form_result(ev) dev[1].wait_sta() dev[1].remove_group() diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index c6fb1d9a4..4ea27a771 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -699,7 +699,8 @@ class WpaSupplicant: vals[name] = value return vals - def group_form_result(self, ev, expect_failure=False, go_neg_res=None): + def group_form_result(self, ev, expect_failure=False, go_neg_res=None, + no_pwd=False): if expect_failure: if "P2P-GROUP-STARTED" in ev: raise Exception("Group formation succeeded when expecting failure") @@ -715,13 +716,17 @@ class WpaSupplicant: if "P2P-GROUP-STARTED" not in ev: raise Exception("No P2P-GROUP-STARTED event seen") - exp = r'<.>(P2P-GROUP-STARTED) ([^ ]*) ([^ ]*) ssid="(.*)" freq=([0-9]*) ((?:psk=.*)|(?:passphrase=".*")) go_dev_addr=([0-9a-f:]*) ip_addr=([0-9.]*) ip_mask=([0-9.]*) go_ip_addr=([0-9.]*)' + pwd = '' if no_pwd else r'((?:psk=.*)|(?:passphrase=".*")) ' + offset = 0 if no_pwd else 1 + exp = r'<.>(P2P-GROUP-STARTED) ([^ ]*) ([^ ]*) ssid="(.*)" freq=([0-9]*) ' + pwd + \ + r'go_dev_addr=([0-9a-f:]*) ip_addr=([0-9.]*) ip_mask=([0-9.]*) go_ip_addr=([0-9.]*)' s = re.split(exp, ev) - if len(s) < 11: - exp = r'<.>(P2P-GROUP-STARTED) ([^ ]*) ([^ ]*) ssid="(.*)" freq=([0-9]*) ((?:psk=.*)|(?:passphrase=".*")) go_dev_addr=([0-9a-f:]*)' + if len(s) < 10 + offset: + exp = r'<.>(P2P-GROUP-STARTED) ([^ ]*) ([^ ]*) ssid="(.*)" freq=([0-9]*) ' + pwd + \ + r'go_dev_addr=([0-9a-f:]*)' s = re.split(exp, ev) - if len(s) < 8: - raise Exception("Could not parse P2P-GROUP-STARTED") + if len(s) < 7 + offset: + raise Exception("Could not parse P2P-GROUP-STARTED %d" % len(s)) res = {} res['result'] = 'success' res['ifname'] = s[2] @@ -751,14 +756,16 @@ class WpaSupplicant: p = re.match(r'passphrase="(.*)"', s[6]) if p: res['passphrase'] = p.group(1) - res['go_dev_addr'] = s[7] - - if len(s) > 8 and len(s[8]) > 0 and "[PERSISTENT]" not in s[8]: - res['ip_addr'] = s[8] - if len(s) > 9: - res['ip_mask'] = s[9] - if len(s) > 10: - res['go_ip_addr'] = s[10] + + res['go_dev_addr'] = s[6 + offset] + + if len(s) > 7 + offset and len(s[7 + offset]) > 0 and \ + "[PERSISTENT]" not in s[7 + offset]: + res['ip_addr'] = s[7 + offset] + if len(s) > 8 + offset: + res['ip_mask'] = s[8 + offset] + if len(s) > 9 + offset: + res['go_ip_addr'] = s[9 + offset] if go_neg_res: exp = r'<.>(P2P-GO-NEG-SUCCESS) role=(GO|client) freq=([0-9]*)'