diff --git a/tests/hwsim/run-tests.py b/tests/hwsim/run-tests.py index c7d3db2eb..7a6d60e31 100755 --- a/tests/hwsim/run-tests.py +++ b/tests/hwsim/run-tests.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # # Test case executor -# Copyright (c) 2013-2014, Jouni Malinen +# Copyright (c) 2013-2015, Jouni Malinen # # This software may be distributed under the terms of the BSD license. # See README for more details. @@ -27,6 +27,7 @@ from wpasupplicant import WpaSupplicant 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) @@ -441,14 +442,14 @@ def main(): 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() diff --git a/tests/hwsim/test_dbus.py b/tests/hwsim/test_dbus.py index 4d69639e3..f5038607e 100644 --- a/tests/hwsim/test_dbus.py +++ b/tests/hwsim/test_dbus.py @@ -19,6 +19,7 @@ except ImportError: 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" @@ -35,7 +36,7 @@ WPAS_DBUS_PERSISTENT_GROUP = "fi.w1.wpa_supplicant1.PersistentGroup" 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) @@ -46,8 +47,7 @@ def prepare_dbus(dev): 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): diff --git a/tests/hwsim/test_dbus_old.py b/tests/hwsim/test_dbus_old.py index 7f29c5a07..dd724327d 100644 --- a/tests/hwsim/test_dbus_old.py +++ b/tests/hwsim/test_dbus_old.py @@ -15,6 +15,7 @@ except ImportError: dbus_imported = False import hostapd +from utils import HwsimSkip from test_dbus import TestDbus, start_ap 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): 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) @@ -37,8 +37,7 @@ def prepare_dbus(dev): 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): diff --git a/tests/hwsim/test_scan.py b/tests/hwsim/test_scan.py index a9869aec0..8da32636c 100644 --- a/tests/hwsim/test_scan.py +++ b/tests/hwsim/test_scan.py @@ -12,6 +12,7 @@ import subprocess 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: @@ -698,8 +699,7 @@ def _test_scan_random_mac(dev, apdev, params): 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", diff --git a/tests/hwsim/utils.py b/tests/hwsim/utils.py index 66589bb2e..a763a259c 100644 --- a/tests/hwsim/utils.py +++ b/tests/hwsim/utils.py @@ -1,5 +1,5 @@ # Testing utilities -# Copyright (c) 2013, Jouni Malinen +# Copyright (c) 2013-2015, Jouni Malinen # # This software may be distributed under the terms of the BSD license. # See README for more details. @@ -13,3 +13,9 @@ def get_ifnames(): 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