test_p2p_concurrency.py 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. # P2P concurrency test cases
  2. # Copyright (c) 2013, Jouni Malinen <j@w1.fi>
  3. #
  4. # This software may be distributed under the terms of the BSD license.
  5. # See README for more details.
  6. import logging
  7. logger = logging.getLogger()
  8. import time
  9. import hwsim_utils
  10. import hostapd
  11. from test_p2p_grpform import go_neg_pin_authorized
  12. from test_p2p_grpform import go_neg_pbc
  13. from test_p2p_grpform import check_grpform_results
  14. from test_p2p_grpform import remove_group
  15. from test_p2p_persistent import form
  16. from test_p2p_persistent import invite_from_cli
  17. from test_p2p_persistent import invite_from_go
  18. def test_concurrent_autogo(dev, apdev):
  19. """Concurrent P2P autonomous GO"""
  20. logger.info("Connect to an infrastructure AP")
  21. hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
  22. dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412")
  23. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  24. logger.info("Start a P2P group while associated to an AP")
  25. dev[0].request("SET p2p_no_group_iface 0")
  26. dev[0].p2p_start_go()
  27. pin = dev[1].wps_read_pin()
  28. dev[0].p2p_go_authorize_client(pin)
  29. dev[1].p2p_connect_group(dev[0].p2p_dev_addr(), pin, timeout=60,
  30. social=True)
  31. hwsim_utils.test_connectivity_p2p(dev[0], dev[1])
  32. dev[0].remove_group()
  33. dev[1].wait_go_ending_session()
  34. logger.info("Confirm AP connection after P2P group removal")
  35. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  36. def test_concurrent_p2pcli(dev, apdev):
  37. """Concurrent P2P client join"""
  38. logger.info("Connect to an infrastructure AP")
  39. hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
  40. dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412")
  41. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  42. logger.info("Join a P2P group while associated to an AP")
  43. dev[0].request("SET p2p_no_group_iface 0")
  44. dev[1].p2p_start_go(freq=2412)
  45. pin = dev[0].wps_read_pin()
  46. dev[1].p2p_go_authorize_client(pin)
  47. dev[0].p2p_connect_group(dev[1].p2p_dev_addr(), pin, timeout=60,
  48. social=True)
  49. hwsim_utils.test_connectivity_p2p(dev[0], dev[1])
  50. dev[1].remove_group()
  51. dev[0].wait_go_ending_session()
  52. logger.info("Confirm AP connection after P2P group removal")
  53. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  54. def test_concurrent_grpform_go(dev, apdev):
  55. """Concurrent P2P group formation to become GO"""
  56. logger.info("Connect to an infrastructure AP")
  57. hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
  58. dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412")
  59. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  60. logger.info("Form a P2P group while associated to an AP")
  61. dev[0].request("SET p2p_no_group_iface 0")
  62. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
  63. r_dev=dev[1], r_intent=0)
  64. check_grpform_results(i_res, r_res)
  65. remove_group(dev[0], dev[1])
  66. logger.info("Confirm AP connection after P2P group removal")
  67. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  68. def test_concurrent_grpform_cli(dev, apdev):
  69. """Concurrent P2P group formation to become P2P Client"""
  70. logger.info("Connect to an infrastructure AP")
  71. hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
  72. dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412")
  73. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  74. logger.info("Form a P2P group while associated to an AP")
  75. dev[0].request("SET p2p_no_group_iface 0")
  76. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=0,
  77. r_dev=dev[1], r_intent=15)
  78. check_grpform_results(i_res, r_res)
  79. remove_group(dev[0], dev[1])
  80. logger.info("Confirm AP connection after P2P group removal")
  81. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  82. def test_concurrent_grpform_while_connecting(dev, apdev):
  83. """Concurrent P2P group formation while connecting to an AP"""
  84. logger.info("Start connection to an infrastructure AP")
  85. hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
  86. dev[0].connect("test-open", key_mgmt="NONE", wait_connect=False)
  87. logger.info("Form a P2P group while connecting to an AP")
  88. dev[0].request("SET p2p_no_group_iface 0")
  89. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_freq=2412,
  90. r_dev=dev[1], r_freq=2412)
  91. check_grpform_results(i_res, r_res)
  92. remove_group(dev[0], dev[1])
  93. logger.info("Confirm AP connection after P2P group removal")
  94. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  95. def test_concurrent_grpform_while_connecting2(dev, apdev):
  96. """Concurrent P2P group formation while connecting to an AP (2)"""
  97. logger.info("Start connection to an infrastructure AP")
  98. hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
  99. dev[0].connect("test-open", key_mgmt="NONE", wait_connect=False)
  100. logger.info("Form a P2P group while connecting to an AP")
  101. dev[0].request("SET p2p_no_group_iface 0")
  102. [i_res, r_res] = go_neg_pbc(i_dev=dev[0], i_intent=15, i_freq=2412,
  103. r_dev=dev[1], r_intent=0, r_freq=2412)
  104. check_grpform_results(i_res, r_res)
  105. remove_group(dev[0], dev[1])
  106. logger.info("Confirm AP connection after P2P group removal")
  107. dev[0].wait_completed()
  108. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  109. def test_concurrent_grpform_while_connecting3(dev, apdev):
  110. """Concurrent P2P group formation while connecting to an AP (3)"""
  111. logger.info("Start connection to an infrastructure AP")
  112. hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
  113. dev[0].connect("test-open", key_mgmt="NONE", wait_connect=False)
  114. logger.info("Form a P2P group while connecting to an AP")
  115. dev[0].request("SET p2p_no_group_iface 0")
  116. [i_res, r_res] = go_neg_pbc(i_dev=dev[1], i_intent=15, i_freq=2412,
  117. r_dev=dev[0], r_intent=0, r_freq=2412)
  118. check_grpform_results(i_res, r_res)
  119. remove_group(dev[0], dev[1])
  120. logger.info("Confirm AP connection after P2P group removal")
  121. dev[0].wait_completed()
  122. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  123. def test_concurrent_persistent_group(dev, apdev):
  124. """Concurrent P2P persistent group"""
  125. logger.info("Connect to an infrastructure AP")
  126. hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open", "channel": "2" })
  127. dev[0].request("SET p2p_no_group_iface 0")
  128. dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2417")
  129. logger.info("Run persistent group test while associated to an AP")
  130. form(dev[0], dev[1])
  131. [go_res, cli_res] = invite_from_cli(dev[0], dev[1])
  132. if go_res['freq'] != '2417':
  133. raise Exception("Unexpected channel selected: " + go_res['freq'])
  134. [go_res, cli_res] = invite_from_go(dev[0], dev[1])
  135. if go_res['freq'] != '2417':
  136. raise Exception("Unexpected channel selected: " + go_res['freq'])