test_p2p_concurrency.py 6.2 KB

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