331967343dee3827a8dfbc596c240aa31b9ed626
[mech_eap.git] / tests / hwsim / test_wmediumd.py
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
7 import tempfile, os, subprocess, errno
8 from utils import HwsimSkip
9 from test_ap_open import _test_ap_open
10
11 CFG = """
12 ifaces :
13 {
14     ids = ["%s", "%s" ];
15     links = (
16         (0, 1, 30)
17     );
18 };
19 """
20
21 def test_wmediumd_simple(dev, apdev):
22     """test a simple wmediumd configuration"""
23     fd, fn = tempfile.mkstemp()
24     try:
25         f = os.fdopen(fd, 'w')
26         f.write(CFG % (apdev[0]['bssid'], dev[0].own_addr()))
27         f.close()
28         try:
29             p = subprocess.Popen(['wmediumd', '-c', fn],
30                                  stdout=open('/dev/null', 'a'),
31                                  stderr=subprocess.STDOUT)
32         except OSError, e:
33             if e.errno == errno.ENOENT:
34                 raise HwsimSkip("wmediumd not available")
35             raise
36         try:
37             _test_ap_open(dev, apdev)
38         finally:
39             p.terminate()
40             p.wait()
41         # test that releasing hwsim works correctly
42         _test_ap_open(dev, apdev)
43     finally:
44         os.unlink(fn)