tests: Convert "hwsim-SKIP" exception to use a custom class
This makes the design a bit cleaner for catching the exceptions. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
910eb5b525
commit
51c5aeb42a
5 changed files with 24 additions and 18 deletions
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
#
|
#
|
||||||
# Test case executor
|
# Test case executor
|
||||||
# Copyright (c) 2013-2014, Jouni Malinen <j@w1.fi>
|
# Copyright (c) 2013-2015, Jouni Malinen <j@w1.fi>
|
||||||
#
|
#
|
||||||
# This software may be distributed under the terms of the BSD license.
|
# This software may be distributed under the terms of the BSD license.
|
||||||
# See README for more details.
|
# See README for more details.
|
||||||
|
@ -27,6 +27,7 @@ from wpasupplicant import WpaSupplicant
|
||||||
from hostapd import HostapdGlobal
|
from hostapd import HostapdGlobal
|
||||||
from check_kernel import check_kernel
|
from check_kernel import check_kernel
|
||||||
from wlantest import Wlantest
|
from wlantest import Wlantest
|
||||||
|
from utils import HwsimSkip
|
||||||
|
|
||||||
def set_term_echo(fd, enabled):
|
def set_term_echo(fd, enabled):
|
||||||
[iflag, oflag, cflag, lflag, ispeed, ospeed, cc] = termios.tcgetattr(fd)
|
[iflag, oflag, cflag, lflag, ispeed, ospeed, cc] = termios.tcgetattr(fd)
|
||||||
|
@ -441,14 +442,14 @@ def main():
|
||||||
result = "SKIP"
|
result = "SKIP"
|
||||||
else:
|
else:
|
||||||
result = "PASS"
|
result = "PASS"
|
||||||
|
except HwsimSkip, e:
|
||||||
|
logger.info("Skip test case: %s" % e)
|
||||||
|
result = "SKIP"
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
if str(e) == "hwsim-SKIP":
|
logger.info(e)
|
||||||
result = "SKIP"
|
if args.loglevel == logging.WARNING:
|
||||||
else:
|
print "Exception: " + str(e)
|
||||||
logger.info(e)
|
result = "FAIL"
|
||||||
if args.loglevel == logging.WARNING:
|
|
||||||
print "Exception: " + str(e)
|
|
||||||
result = "FAIL"
|
|
||||||
for d in dev:
|
for d in dev:
|
||||||
try:
|
try:
|
||||||
d.dump_monitor()
|
d.dump_monitor()
|
||||||
|
|
|
@ -19,6 +19,7 @@ except ImportError:
|
||||||
|
|
||||||
import hostapd
|
import hostapd
|
||||||
from wpasupplicant import WpaSupplicant
|
from wpasupplicant import WpaSupplicant
|
||||||
|
from utils import HwsimSkip
|
||||||
from test_ap_tdls import connect_2sta_open
|
from test_ap_tdls import connect_2sta_open
|
||||||
|
|
||||||
WPAS_DBUS_SERVICE = "fi.w1.wpa_supplicant1"
|
WPAS_DBUS_SERVICE = "fi.w1.wpa_supplicant1"
|
||||||
|
@ -35,7 +36,7 @@ WPAS_DBUS_PERSISTENT_GROUP = "fi.w1.wpa_supplicant1.PersistentGroup"
|
||||||
def prepare_dbus(dev):
|
def prepare_dbus(dev):
|
||||||
if not dbus_imported:
|
if not dbus_imported:
|
||||||
logger.info("No dbus module available")
|
logger.info("No dbus module available")
|
||||||
raise Exception("hwsim-SKIP")
|
raise HwsimSkip("No dbus module available")
|
||||||
try:
|
try:
|
||||||
from dbus.mainloop.glib import DBusGMainLoop
|
from dbus.mainloop.glib import DBusGMainLoop
|
||||||
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
|
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
|
||||||
|
@ -46,8 +47,7 @@ def prepare_dbus(dev):
|
||||||
if_obj = bus.get_object(WPAS_DBUS_SERVICE, path)
|
if_obj = bus.get_object(WPAS_DBUS_SERVICE, path)
|
||||||
return (bus,wpas_obj,path,if_obj)
|
return (bus,wpas_obj,path,if_obj)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
logger.info("No D-Bus support available: " + str(e))
|
raise HwsimSkip("Could not connect to D-Bus: %s" % e)
|
||||||
raise Exception("hwsim-SKIP")
|
|
||||||
|
|
||||||
class TestDbus(object):
|
class TestDbus(object):
|
||||||
def __init__(self, bus):
|
def __init__(self, bus):
|
||||||
|
|
|
@ -15,6 +15,7 @@ except ImportError:
|
||||||
dbus_imported = False
|
dbus_imported = False
|
||||||
|
|
||||||
import hostapd
|
import hostapd
|
||||||
|
from utils import HwsimSkip
|
||||||
from test_dbus import TestDbus, start_ap
|
from test_dbus import TestDbus, start_ap
|
||||||
|
|
||||||
WPAS_DBUS_OLD_SERVICE = "fi.epitest.hostap.WPASupplicant"
|
WPAS_DBUS_OLD_SERVICE = "fi.epitest.hostap.WPASupplicant"
|
||||||
|
@ -25,8 +26,7 @@ WPAS_DBUS_OLD_NETWORK = "fi.epitest.hostap.WPASupplicant.Network"
|
||||||
|
|
||||||
def prepare_dbus(dev):
|
def prepare_dbus(dev):
|
||||||
if not dbus_imported:
|
if not dbus_imported:
|
||||||
logger.info("No dbus module available")
|
raise HwsimSkip("No dbus module available")
|
||||||
raise Exception("hwsim-SKIP")
|
|
||||||
try:
|
try:
|
||||||
from dbus.mainloop.glib import DBusGMainLoop
|
from dbus.mainloop.glib import DBusGMainLoop
|
||||||
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
|
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
|
||||||
|
@ -37,8 +37,7 @@ def prepare_dbus(dev):
|
||||||
if_obj = bus.get_object(WPAS_DBUS_OLD_SERVICE, path)
|
if_obj = bus.get_object(WPAS_DBUS_OLD_SERVICE, path)
|
||||||
return (bus,wpas_obj,path,if_obj)
|
return (bus,wpas_obj,path,if_obj)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
logger.info("No D-Bus support available: " + str(e))
|
raise HwsimSkip("Could not connect to D-Bus: %s" % e)
|
||||||
raise Exception("hwsim-SKIP")
|
|
||||||
|
|
||||||
class TestDbusOldWps(TestDbus):
|
class TestDbusOldWps(TestDbus):
|
||||||
def __init__(self, bus):
|
def __init__(self, bus):
|
||||||
|
|
|
@ -12,6 +12,7 @@ import subprocess
|
||||||
|
|
||||||
import hostapd
|
import hostapd
|
||||||
from wpasupplicant import WpaSupplicant
|
from wpasupplicant import WpaSupplicant
|
||||||
|
from utils import HwsimSkip
|
||||||
|
|
||||||
def check_scan(dev, params, other_started=False, test_busy=False):
|
def check_scan(dev, params, other_started=False, test_busy=False):
|
||||||
if not other_started:
|
if not other_started:
|
||||||
|
@ -698,8 +699,7 @@ def _test_scan_random_mac(dev, apdev, params):
|
||||||
raise Exception("Invalid MAC_RAND_SCAN accepted: " + args)
|
raise Exception("Invalid MAC_RAND_SCAN accepted: " + args)
|
||||||
|
|
||||||
if dev[0].get_driver_status_field('capa.mac_addr_rand_scan_supported') != '1':
|
if dev[0].get_driver_status_field('capa.mac_addr_rand_scan_supported') != '1':
|
||||||
logger.info("Driver does not support random MAC address for scanning")
|
raise HwsimSkip("Driver does not support random MAC address for scanning")
|
||||||
raise Exception("hwsim-SKIP")
|
|
||||||
|
|
||||||
tests = [ "all enable=1",
|
tests = [ "all enable=1",
|
||||||
"all enable=1 addr=f2:11:22:33:44:55 mask=ff:ff:ff:ff:ff:ff",
|
"all enable=1 addr=f2:11:22:33:44:55 mask=ff:ff:ff:ff:ff:ff",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Testing utilities
|
# Testing utilities
|
||||||
# Copyright (c) 2013, Jouni Malinen <j@w1.fi>
|
# Copyright (c) 2013-2015, Jouni Malinen <j@w1.fi>
|
||||||
#
|
#
|
||||||
# This software may be distributed under the terms of the BSD license.
|
# This software may be distributed under the terms of the BSD license.
|
||||||
# See README for more details.
|
# See README for more details.
|
||||||
|
@ -13,3 +13,9 @@ def get_ifnames():
|
||||||
if len(val) == 2:
|
if len(val) == 2:
|
||||||
ifnames.append(val[0].strip(' '))
|
ifnames.append(val[0].strip(' '))
|
||||||
return ifnames
|
return ifnames
|
||||||
|
|
||||||
|
class HwsimSkip(Exception):
|
||||||
|
def __init__(self, reason):
|
||||||
|
self.reason = reason
|
||||||
|
def __str__(self):
|
||||||
|
return self.reason
|
||||||
|
|
Loading…
Reference in a new issue