@@ -558,7 +558,8 @@ class IntegrationTestsWifi(IntegrationTestsBase):
558
558
@classmethod
559
559
def setUpClass (klass ):
560
560
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
562
563
try :
563
564
subprocess .check_call (['modprobe' , 'cfg80211' ])
564
565
# set regulatory domain "EU", so that we can use 80211.a 5 GHz channels
@@ -567,20 +568,34 @@ def setUpClass(klass):
567
568
assert m
568
569
klass .orig_country = m .group (1 )
569
570
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
572
574
573
575
@classmethod
574
576
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 ])
576
579
super ().tearDownClass ()
577
580
578
581
@classmethod
579
582
def create_devices (klass ):
580
583
'''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
+
581
597
if os .path .exists ('/sys/module/mac80211_hwsim' ):
582
598
raise SystemError ('mac80211_hwsim module already loaded' )
583
- super ().create_devices ()
584
599
# create virtual wlan devs
585
600
before_wlan = set ([c for c in os .listdir ('/sys/class/net' ) if c .startswith ('wlan' )])
586
601
subprocess .check_call (['modprobe' , 'mac80211_hwsim' ])
@@ -602,6 +617,7 @@ def create_devices(klass):
602
617
# don't let NM trample over our fake AP
603
618
with open ('/etc/NetworkManager/conf.d/99-test-denylist-wifi.conf' , 'w' ) as f :
604
619
f .write ('[keyfile]\n unmanaged-devices+=%s\n ' % klass .dev_w_ap )
620
+ super ().create_devices ()
605
621
606
622
@classmethod
607
623
def shutdown_devices (klass ):
0 commit comments