test_p2p_ext.py 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # P2P vendor specific extension tests
  2. # Copyright (c) 2014, Qualcomm Atheros, Inc.
  3. import logging
  4. logger = logging.getLogger()
  5. def test_p2p_ext_discovery(dev):
  6. """P2P device discovery with vendor specific extensions"""
  7. addr0 = dev[0].p2p_dev_addr()
  8. addr1 = dev[1].p2p_dev_addr()
  9. try:
  10. if "OK" not in dev[0].request("VENDOR_ELEM_ADD 1 dd050011223344"):
  11. raise Exception("VENDOR_ELEM_ADD failed")
  12. res = dev[0].request("VENDOR_ELEM_GET 1")
  13. if res != "dd050011223344":
  14. raise Exception("Unexpected VENDOR_ELEM_GET result: " + res)
  15. if "OK" not in dev[0].request("VENDOR_ELEM_ADD 1 dd06001122335566"):
  16. raise Exception("VENDOR_ELEM_ADD failed")
  17. res = dev[0].request("VENDOR_ELEM_GET 1")
  18. if res != "dd050011223344dd06001122335566":
  19. raise Exception("Unexpected VENDOR_ELEM_GET result(2): " + res)
  20. res = dev[0].request("VENDOR_ELEM_GET 2")
  21. if res != "":
  22. raise Exception("Unexpected VENDOR_ELEM_GET result(3): " + res)
  23. if "OK" not in dev[0].request("VENDOR_ELEM_REMOVE 1 dd050011223344"):
  24. raise Exception("VENDOR_ELEM_REMOVE failed")
  25. res = dev[0].request("VENDOR_ELEM_GET 1")
  26. if res != "dd06001122335566":
  27. raise Exception("Unexpected VENDOR_ELEM_GET result(4): " + res)
  28. if "OK" not in dev[0].request("VENDOR_ELEM_REMOVE 1 dd06001122335566"):
  29. raise Exception("VENDOR_ELEM_REMOVE failed")
  30. res = dev[0].request("VENDOR_ELEM_GET 1")
  31. if res != "":
  32. raise Exception("Unexpected VENDOR_ELEM_GET result(5): " + res)
  33. if "OK" not in dev[0].request("VENDOR_ELEM_ADD 1 dd050011223344dd06001122335566"):
  34. raise Exception("VENDOR_ELEM_ADD failed(2)")
  35. if "FAIL" not in dev[0].request("VENDOR_ELEM_REMOVE 1 dd051122334455"):
  36. raise Exception("Unexpected VENDOR_ELEM_REMOVE success")
  37. if "FAIL" not in dev[0].request("VENDOR_ELEM_REMOVE 1 dd"):
  38. raise Exception("Unexpected VENDOR_ELEM_REMOVE success(2)")
  39. if "FAIL" not in dev[0].request("VENDOR_ELEM_ADD 1 ddff"):
  40. raise Exception("Unexpected VENDOR_ELEM_ADD success(3)")
  41. dev[0].p2p_listen()
  42. if not dev[1].discover_peer(addr0):
  43. raise Exception("Device discovery timed out")
  44. if not dev[0].discover_peer(addr1):
  45. raise Exception("Device discovery timed out")
  46. peer = dev[1].get_peer(addr0)
  47. if peer['vendor_elems'] != "dd050011223344dd06001122335566":
  48. raise Exception("Vendor elements not reported correctly")
  49. res = dev[0].request("VENDOR_ELEM_GET 1")
  50. if res != "dd050011223344dd06001122335566":
  51. raise Exception("Unexpected VENDOR_ELEM_GET result(6): " + res)
  52. if "OK" not in dev[0].request("VENDOR_ELEM_REMOVE 1 dd06001122335566"):
  53. raise Exception("VENDOR_ELEM_REMOVE failed")
  54. res = dev[0].request("VENDOR_ELEM_GET 1")
  55. if res != "dd050011223344":
  56. raise Exception("Unexpected VENDOR_ELEM_GET result(7): " + res)
  57. finally:
  58. dev[0].request("VENDOR_ELEM_REMOVE 1 *")
  59. def test_p2p_ext_discovery_go(dev):
  60. """P2P device discovery with vendor specific extensions for GO"""
  61. addr0 = dev[0].p2p_dev_addr()
  62. addr1 = dev[1].p2p_dev_addr()
  63. try:
  64. if "OK" not in dev[0].request("VENDOR_ELEM_ADD 2 dd050011223344dd06001122335566"):
  65. raise Exception("VENDOR_ELEM_ADD failed")
  66. if "OK" not in dev[0].request("VENDOR_ELEM_ADD 3 dd050011223344dd06001122335566"):
  67. raise Exception("VENDOR_ELEM_ADD failed")
  68. if "OK" not in dev[0].request("VENDOR_ELEM_ADD 12 dd050011223344dd06001122335566"):
  69. raise Exception("VENDOR_ELEM_ADD failed")
  70. dev[0].p2p_start_go(freq="2412")
  71. if not dev[1].discover_peer(addr0):
  72. raise Exception("Device discovery timed out")
  73. peer = dev[1].get_peer(addr0)
  74. if peer['vendor_elems'] != "dd050011223344dd06001122335566":
  75. print peer['vendor_elems']
  76. raise Exception("Vendor elements not reported correctly")
  77. finally:
  78. dev[0].request("VENDOR_ELEM_REMOVE 2 *")
  79. dev[0].request("VENDOR_ELEM_REMOVE 3 *")
  80. dev[0].request("VENDOR_ELEM_REMOVE 12 *")