This makes the design a bit cleaner for catching the exceptions.
Signed-off-by: Jouni Malinen <j@w1.fi>
#!/usr/bin/env python2
#
# 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.
# See README for more details.
from hostapd import HostapdGlobal
from check_kernel import check_kernel
from wlantest import Wlantest
+from utils import HwsimSkip
def set_term_echo(fd, enabled):
[iflag, oflag, cflag, lflag, ispeed, ospeed, cc] = termios.tcgetattr(fd)
result = "SKIP"
else:
result = "PASS"
+ except HwsimSkip, e:
+ logger.info("Skip test case: %s" % e)
+ result = "SKIP"
except Exception, e:
- if str(e) == "hwsim-SKIP":
- result = "SKIP"
- else:
- logger.info(e)
- if args.loglevel == logging.WARNING:
- print "Exception: " + str(e)
- result = "FAIL"
+ logger.info(e)
+ if args.loglevel == logging.WARNING:
+ print "Exception: " + str(e)
+ result = "FAIL"
for d in dev:
try:
d.dump_monitor()
import hostapd
from wpasupplicant import WpaSupplicant
+from utils import HwsimSkip
from test_ap_tdls import connect_2sta_open
WPAS_DBUS_SERVICE = "fi.w1.wpa_supplicant1"
def prepare_dbus(dev):
if not dbus_imported:
logger.info("No dbus module available")
- raise Exception("hwsim-SKIP")
+ raise HwsimSkip("No dbus module available")
try:
from dbus.mainloop.glib import DBusGMainLoop
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
if_obj = bus.get_object(WPAS_DBUS_SERVICE, path)
return (bus,wpas_obj,path,if_obj)
except Exception, e:
- logger.info("No D-Bus support available: " + str(e))
- raise Exception("hwsim-SKIP")
+ raise HwsimSkip("Could not connect to D-Bus: %s" % e)
class TestDbus(object):
def __init__(self, bus):
dbus_imported = False
import hostapd
+from utils import HwsimSkip
from test_dbus import TestDbus, start_ap
WPAS_DBUS_OLD_SERVICE = "fi.epitest.hostap.WPASupplicant"
def prepare_dbus(dev):
if not dbus_imported:
- logger.info("No dbus module available")
- raise Exception("hwsim-SKIP")
+ raise HwsimSkip("No dbus module available")
try:
from dbus.mainloop.glib import DBusGMainLoop
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
if_obj = bus.get_object(WPAS_DBUS_OLD_SERVICE, path)
return (bus,wpas_obj,path,if_obj)
except Exception, e:
- logger.info("No D-Bus support available: " + str(e))
- raise Exception("hwsim-SKIP")
+ raise HwsimSkip("Could not connect to D-Bus: %s" % e)
class TestDbusOldWps(TestDbus):
def __init__(self, bus):
import hostapd
from wpasupplicant import WpaSupplicant
+from utils import HwsimSkip
def check_scan(dev, params, other_started=False, test_busy=False):
if not other_started:
raise Exception("Invalid MAC_RAND_SCAN accepted: " + args)
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 Exception("hwsim-SKIP")
+ raise HwsimSkip("Driver does not support random MAC address for scanning")
tests = [ "all enable=1",
"all enable=1 addr=f2:11:22:33:44:55 mask=ff:ff:ff:ff:ff:ff",
# 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.
# See README for more details.
if len(val) == 2:
ifnames.append(val[0].strip(' '))
return ifnames
+
+class HwsimSkip(Exception):
+ def __init__(self, reason):
+ self.reason = reason
+ def __str__(self):
+ return self.reason