Skip to content

Commit 04bf213

Browse files
committed
tests:wifi: Fail properly, don't indicate 'OK (skipped=all) PASS'
1 parent 03e60e5 commit 04bf213

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

tests/integration/base.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,8 @@ class IntegrationTestsWifi(IntegrationTestsBase):
558558
@classmethod
559559
def setUpClass(klass):
560560
super().setUpClass()
561-
# ensure we have this so that iw works
561+
klass.orig_country = None
562+
# ensure we have cfg80211 so that iw works
562563
try:
563564
subprocess.check_call(['modprobe', 'cfg80211'])
564565
# set regulatory domain "EU", so that we can use 80211.a 5 GHz channels
@@ -567,20 +568,34 @@ def setUpClass(klass):
567568
assert m
568569
klass.orig_country = m.group(1)
569570
subprocess.check_call(['iw', 'reg', 'set', 'EU'])
570-
except Exception:
571-
raise unittest.SkipTest("cfg80211 (wireless) is unavailable, can't test")
571+
except subprocess.CalledProcessError:
572+
print('cfg80211 (wireless) is unavailable, can\'t test', file=sys.stderr)
573+
raise
572574

573575
@classmethod
574576
def tearDownClass(klass):
575-
subprocess.check_call(['iw', 'reg', 'set', klass.orig_country])
577+
if klass.orig_country is not None:
578+
subprocess.check_call(['iw', 'reg', 'set', klass.orig_country])
576579
super().tearDownClass()
577580

578581
@classmethod
579582
def create_devices(klass):
580583
'''Create Access Point and Client devices with mac80211_hwsim and veth'''
584+
# TODO: Consider using some trickery, to allow loading modules on the
585+
# host by name/alias from within a container.
586+
# https://github.com/weaveworks/weave/issues/3115
587+
# https://x.com/lucabruno/status/902934379835662336
588+
# https://github.com/docker-library/docker/blob/master/modprobe.sh # wokeignore:rule=master
589+
# https://github.com/torvalds/linux/blob/master/net/core/dev_ioctl.c:dev_load() # wokeignore:rule=master
590+
# e.g. via netdev ioctl SIOCGIFINDEX:
591+
# https://github.com/weaveworks/go-odp/blob/master/odp/dpif.go#L67 # wokeignore:rule=master
592+
#
593+
# Or alternatively, port the WiFi testing to virt_wifi, which can be
594+
# auto-loaded via "ip link add link eth0 name wlan42 type virt_wifi"
595+
# inside a (privileged) LXC container, as used by autopkgtest.
596+
581597
if os.path.exists('/sys/module/mac80211_hwsim'):
582598
raise SystemError('mac80211_hwsim module already loaded')
583-
super().create_devices()
584599
# create virtual wlan devs
585600
before_wlan = set([c for c in os.listdir('/sys/class/net') if c.startswith('wlan')])
586601
subprocess.check_call(['modprobe', 'mac80211_hwsim'])
@@ -602,6 +617,7 @@ def create_devices(klass):
602617
# don't let NM trample over our fake AP
603618
with open('/etc/NetworkManager/conf.d/99-test-denylist-wifi.conf', 'w') as f:
604619
f.write('[keyfile]\nunmanaged-devices+=%s\n' % klass.dev_w_ap)
620+
super().create_devices()
605621

606622
@classmethod
607623
def shutdown_devices(klass):

0 commit comments

Comments
 (0)