test_p2p_concurrency.py 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. def test_concurrent_autogo(dev, apdev):
  16. """Concurrent P2P autonomous GO"""
  17. logger.info("Connect to an infrastructure AP")
  18. hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
  19. dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412")
  20. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  21. logger.info("Start a P2P group while associated to an AP")
  22. dev[0].request("SET p2p_no_group_iface 0")
  23. dev[0].p2p_start_go()
  24. pin = dev[1].wps_read_pin()
  25. dev[0].p2p_go_authorize_client(pin)
  26. dev[1].p2p_connect_group(dev[0].p2p_dev_addr(), pin, timeout=60,
  27. social=True)
  28. hwsim_utils.test_connectivity_p2p(dev[0], dev[1])
  29. dev[0].remove_group()
  30. dev[1].wait_go_ending_session()
  31. logger.info("Confirm AP connection after P2P group removal")
  32. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  33. def test_concurrent_p2pcli(dev, apdev):
  34. """Concurrent P2P client join"""
  35. logger.info("Connect to an infrastructure AP")
  36. hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
  37. dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412")
  38. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  39. logger.info("Join a P2P group while associated to an AP")
  40. dev[0].request("SET p2p_no_group_iface 0")
  41. dev[1].p2p_start_go(freq=2412)
  42. pin = dev[0].wps_read_pin()
  43. dev[1].p2p_go_authorize_client(pin)
  44. dev[0].p2p_connect_group(dev[1].p2p_dev_addr(), pin, timeout=60,
  45. social=True)
  46. hwsim_utils.test_connectivity_p2p(dev[0], dev[1])
  47. dev[1].remove_group()
  48. dev[0].wait_go_ending_session()
  49. logger.info("Confirm AP connection after P2P group removal")
  50. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  51. def test_concurrent_grpform_go(dev, apdev):
  52. """Concurrent P2P group formation to become GO"""
  53. logger.info("Connect to an infrastructure AP")
  54. hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
  55. dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412")
  56. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  57. logger.info("Form a P2P group while associated to an AP")
  58. dev[0].request("SET p2p_no_group_iface 0")
  59. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
  60. r_dev=dev[1], r_intent=0)
  61. check_grpform_results(i_res, r_res)
  62. remove_group(dev[0], dev[1])
  63. logger.info("Confirm AP connection after P2P group removal")
  64. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  65. def test_concurrent_grpform_cli(dev, apdev):
  66. """Concurrent P2P group formation to become P2P Client"""
  67. logger.info("Connect to an infrastructure AP")
  68. hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
  69. dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412")
  70. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  71. logger.info("Form a P2P group while associated to an AP")
  72. dev[0].request("SET p2p_no_group_iface 0")
  73. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=0,
  74. r_dev=dev[1], r_intent=15)
  75. check_grpform_results(i_res, r_res)
  76. remove_group(dev[0], dev[1])
  77. logger.info("Confirm AP connection after P2P group removal")
  78. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  79. def test_concurrent_grpform_while_connecting(dev, apdev):
  80. """Concurrent P2P group formation while connecting to an AP"""
  81. logger.info("Start connection to an infrastructure AP")
  82. hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
  83. dev[0].connect("test-open", key_mgmt="NONE", wait_connect=False)
  84. logger.info("Form a P2P group while connecting to an AP")
  85. dev[0].request("SET p2p_no_group_iface 0")
  86. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_freq=2412,
  87. r_dev=dev[1], r_freq=2412)
  88. check_grpform_results(i_res, r_res)
  89. remove_group(dev[0], dev[1])
  90. logger.info("Confirm AP connection after P2P group removal")
  91. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  92. def test_concurrent_grpform_while_connecting2(dev, apdev):
  93. """Concurrent P2P group formation while connecting to an AP (2)"""
  94. logger.info("Start connection to an infrastructure AP")
  95. hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
  96. dev[0].connect("test-open", key_mgmt="NONE", wait_connect=False)
  97. logger.info("Form a P2P group while connecting to an AP")
  98. dev[0].request("SET p2p_no_group_iface 0")
  99. [i_res, r_res] = go_neg_pbc(i_dev=dev[0], i_intent=15, i_freq=2412,
  100. r_dev=dev[1], r_intent=0, r_freq=2412)
  101. check_grpform_results(i_res, r_res)
  102. remove_group(dev[0], dev[1])
  103. logger.info("Confirm AP connection after P2P group removal")
  104. dev[0].wait_completed()
  105. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  106. def test_concurrent_grpform_while_connecting3(dev, apdev):
  107. """Concurrent P2P group formation while connecting to an AP (3)"""
  108. logger.info("Start connection to an infrastructure AP")
  109. hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
  110. dev[0].connect("test-open", key_mgmt="NONE", wait_connect=False)
  111. logger.info("Form a P2P group while connecting to an AP")
  112. dev[0].request("SET p2p_no_group_iface 0")
  113. [i_res, r_res] = go_neg_pbc(i_dev=dev[1], i_intent=15, i_freq=2412,
  114. r_dev=dev[0], r_intent=0, r_freq=2412)
  115. check_grpform_results(i_res, r_res)
  116. remove_group(dev[0], dev[1])
  117. logger.info("Confirm AP connection after P2P group removal")
  118. dev[0].wait_completed()
  119. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])