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'])
29 if len(sys.argv) > 1 and sys.argv[1] == '-d':
30 logging.basicConfig(level=logging.DEBUG)
32 elif len(sys.argv) > 1 and sys.argv[1] == '-q':
33 logging.basicConfig(level=logging.WARNING)
36 logging.basicConfig(level=logging.INFO)
38 if len(sys.argv) > idx + 1 and sys.argv[idx] == '-f':
39 test_file = sys.argv[idx + 1]
42 if len(sys.argv) > idx:
43 test_filter = sys.argv[idx]
47 dev0 = WpaSupplicant('wlan0')
48 dev1 = WpaSupplicant('wlan1')
49 dev2 = WpaSupplicant('wlan2')
50 dev = [ dev0, dev1, dev2 ]
52 apdev.append({"ifname": 'wlan3', "bssid": "02:00:00:00:03:00"})
53 apdev.append({"ifname": 'wlan4', "bssid": "02:00:00:00:04:00"})
57 print d.ifname + ": No response from wpa_supplicant"
60 print "DEV: " + d.ifname + ": " + d.p2p_dev_addr()
62 print "APDEV: " + ap['ifname']
65 for t in os.listdir("."):
66 m = re.match(r'(test_.*)\.py$', t)
68 if test_file and test_file not in t:
70 print "Import test cases from " + t
71 mod = __import__(m.group(1))
73 if s.startswith("test_"):
74 func = mod.__dict__.get(s)
82 if test_filter != t.__name__:
84 reset_devs(dev, apdev)
85 print "START " + t.__name__
87 print "Test: " + t.__doc__
89 d.request("NOTE TEST-START " + t.__name__)
91 if t.func_code.co_argcount > 1:
95 passed.append(t.__name__)
96 print "PASS " + t.__name__
99 failed.append(t.__name__)
100 print "FAIL " + t.__name__
102 d.request("NOTE TEST-STOP " + t.__name__)
105 reset_devs(dev, apdev)
107 print "passed tests: " + str(passed)
108 print "failed tests: " + str(failed)
112 if __name__ == "__main__":