]>
git.ipfire.org Git - thirdparty/hostap.git/blob - tests/hwsim/run-tests.py
4 # Copyright (c) 2013, Jouni Malinen <j@w1.fi>
6 # This software may be distributed under the terms of the BSD license.
7 # See README for more details.
16 from wpasupplicant
import WpaSupplicant
17 from hostapd
import HostapdGlobal
19 def reset_devs(dev
, apdev
):
22 hapd
= HostapdGlobal()
24 hapd
.remove(ap
['ifname'])
28 if len(sys
.argv
) > 1 and sys
.argv
[1] == '-d':
29 logging
.basicConfig(level
=logging
.DEBUG
)
31 elif len(sys
.argv
) > 1 and sys
.argv
[1] == '-q':
32 logging
.basicConfig(level
=logging
.WARNING
)
35 logging
.basicConfig(level
=logging
.INFO
)
37 if len(sys
.argv
) > idx
:
38 test_filter
= sys
.argv
[idx
]
42 dev0
= WpaSupplicant('wlan0')
43 dev1
= WpaSupplicant('wlan1')
44 dev2
= WpaSupplicant('wlan2')
45 dev
= [ dev0
, dev1
, dev2
]
47 apdev
.append({"ifname": 'wlan3', "bssid": "02:00:00:00:03:00"})
48 apdev
.append({"ifname": 'wlan4', "bssid": "02:00:00:00:04:00"})
52 print d
.ifname
+ ": No response from wpa_supplicant"
55 print "DEV: " + d
.ifname
+ ": " + d
.p2p_dev_addr()
57 print "APDEV: " + ap
['ifname']
60 for t
in os
.listdir("."):
61 m
= re
.match(r
'(test_.*)\.py$', t
)
63 print "Import test cases from " + t
64 mod
= __import__(m
.group(1))
66 if s
.startswith("test_"):
67 func
= mod
.__dict
__.get(s
)
75 if test_filter
!= t
.__name
__:
77 reset_devs(dev
, apdev
)
78 print "START " + t
.__name
__
80 print "Test: " + t
.__doc
__
82 d
.request("NOTE TEST-START " + t
.__name
__)
84 if t
.func_code
.co_argcount
> 1:
88 passed
.append(t
.__name
__)
89 print "PASS " + t
.__name
__
92 failed
.append(t
.__name
__)
93 print "FAIL " + t
.__name
__
95 d
.request("NOTE TEST-STOP " + t
.__name
__)
98 reset_devs(dev
, apdev
)
100 print "passed tests: " + str(passed
)
101 print "failed tests: " + str(failed
)
105 if __name__
== "__main__":