test_radio_work.py 2.1 KB

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