eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

adhoc_test.py (1860B)


      1 #!/usr/bin/python3
      2 
      3 import unittest
      4 import sys
      5 
      6 sys.path.append('../util')
      7 from iwd import IWD
      8 from iwd import AdHocDevice
      9 from config import ctx
     10 import testutil
     11 
     12 class Test(unittest.TestCase):
     13 
     14     def validate_connection(self, wd, client=False):
     15         dev1, dev2 = wd.list_devices(2)
     16 
     17         self.assertIsNotNone(dev1)
     18         self.assertIsNotNone(dev2)
     19 
     20         adhoc1 = dev1.start_adhoc("AdHocNetwork", "secret123")
     21 
     22         condition = 'obj.started == True'
     23         wd.wait_for_object_condition(adhoc1, condition)
     24 
     25         if not client:
     26             adhoc2 = dev2.start_adhoc("AdHocNetwork", "secret123")
     27         else:
     28             ctx.start_process(['iwctl', 'device', dev2.name, 'set-property',
     29                                 'Mode', 'ad-hoc'], check=True)
     30             ctx.start_process(['iwctl', 'ad-hoc', dev2.name, 'start',
     31                                 'AdHocNetwork', 'secret123'], check=True)
     32             adhoc2 = AdHocDevice(dev2.device_path)
     33 
     34         condition = 'obj.started == True'
     35         wd.wait_for_object_condition(adhoc1, condition)
     36 
     37         condition = '"%s" in obj.connected_peers' % dev2.address
     38         wd.wait_for_object_condition(adhoc1, condition)
     39 
     40         condition = '"%s" in obj.connected_peers' % dev1.address
     41         wd.wait_for_object_condition(adhoc2, condition)
     42 
     43         testutil.test_iface_operstate(dev1.name)
     44         testutil.test_iface_operstate(dev2.name)
     45         testutil.test_ifaces_connected(dev1.name, dev2.name)
     46 
     47     def test_connection_success(self):
     48         wd = IWD(True)
     49 
     50         self.validate_connection(wd)
     51 
     52     def test_client_adhoc(self):
     53         wd = IWD(True)
     54         self.validate_connection(wd, client=True)
     55 
     56     @classmethod
     57     def setUpClass(cls):
     58         pass
     59 
     60     @classmethod
     61     def tearDownClass(cls):
     62         IWD.clear_storage()
     63 
     64 if __name__ == '__main__':
     65     unittest.main(exit=True)