test_wmediumd.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # wmediumd sanity checks
  2. # Copyright (c) 2015, Intel Deutschland GmbH
  3. #
  4. # This software may be distributed under the terms of the BSD license.
  5. # See README for more details.
  6. import tempfile, os, subprocess, errno
  7. from utils import HwsimSkip
  8. from test_ap_open import _test_ap_open
  9. CFG = """
  10. ifaces :
  11. {
  12. ids = ["%s", "%s" ];
  13. links = (
  14. (0, 1, 30)
  15. );
  16. };
  17. """
  18. def test_wmediumd_simple(dev, apdev):
  19. """test a simple wmediumd configuration"""
  20. fd, fn = tempfile.mkstemp()
  21. try:
  22. f = os.fdopen(fd, 'w')
  23. f.write(CFG % (apdev[0]['bssid'], dev[0].own_addr()))
  24. f.close()
  25. try:
  26. p = subprocess.Popen(['wmediumd', '-c', fn],
  27. stdout=open('/dev/null', 'a'),
  28. stderr=subprocess.STDOUT)
  29. except OSError, e:
  30. if e.errno == errno.ENOENT:
  31. raise HwsimSkip("wmediumd not available")
  32. raise
  33. try:
  34. _test_ap_open(dev, apdev)
  35. finally:
  36. p.terminate()
  37. p.wait()
  38. # test that releasing hwsim works correctly
  39. _test_ap_open(dev, apdev)
  40. finally:
  41. os.unlink(fn)