test_radio_work.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Radio work tests
  2. # Copyright (c) 2014, 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 time
  7. import logging
  8. logger = logging.getLogger()
  9. import subprocess
  10. import hostapd
  11. def test_ext_radio_work(dev, apdev):
  12. """External radio work item"""
  13. id = dev[0].request("RADIO_WORK add test-work-a")
  14. if "FAIL" in id:
  15. raise Exception("Failed to add radio work")
  16. id2 = dev[0].request("RADIO_WORK add test-work-b freq=2417")
  17. if "FAIL" in id2:
  18. raise Exception("Failed to add radio work")
  19. id3 = dev[0].request("RADIO_WORK add test-work-c")
  20. if "FAIL" in id3:
  21. raise Exception("Failed to add radio work")
  22. ev = dev[0].wait_event(["EXT-RADIO-WORK-START"])
  23. if ev is None:
  24. raise Exception("Timeout while waiting radio work to start")
  25. if "EXT-RADIO-WORK-START " + id not in ev:
  26. raise Exception("Unexpected radio work start id")
  27. items = dev[0].request("RADIO_WORK show")
  28. if "ext:test-work-a@wlan0:0:1:" not in items:
  29. logger.info("Pending radio work items:\n" + items)
  30. raise Exception("Radio work item(a) missing from the list")
  31. if "ext:test-work-b@wlan0:2417:0:" not in items:
  32. logger.info("Pending radio work items:\n" + items)
  33. raise Exception("Radio work item(b) missing from the list")
  34. if "ext:test-work-c@wlan0:0:0:" not in items:
  35. logger.info("Pending radio work items:\n" + items)
  36. raise Exception("Radio work item(c) missing from the list")
  37. dev[0].request("RADIO_WORK done " + id2)
  38. dev[0].request("RADIO_WORK done " + id)
  39. ev = dev[0].wait_event(["EXT-RADIO-WORK-START"])
  40. if ev is None:
  41. raise Exception("Timeout while waiting radio work to start")
  42. if "EXT-RADIO-WORK-START " + id3 not in ev:
  43. raise Exception("Unexpected radio work start id")
  44. dev[0].request("RADIO_WORK done " + id3)
  45. items = dev[0].request("RADIO_WORK show")
  46. if "ext:" in items:
  47. logger.info("Pending radio work items:\n" + items)
  48. raise Exception("Unexpected remaining radio work item")