mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-20 19:12:33 +01:00
autotests: fixed twoNetworks after objectManager changes
This commit is contained in:
parent
0976f3cee4
commit
2b781d544d
@ -9,36 +9,28 @@ import dbus.mainloop.glib
|
|||||||
import time
|
import time
|
||||||
import threading
|
import threading
|
||||||
import logging
|
import logging
|
||||||
from random import randrange
|
|
||||||
from subprocess import Popen
|
from subprocess import Popen
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
sys.path.append('../utility') #needed to import all the utlilty modules
|
sys.path.append('../utility') #needed to import all the utlilty modules
|
||||||
import utility
|
import utility
|
||||||
|
|
||||||
def defineAgentVars():
|
def getSecondNetworkToConnect(objectList, firstNetworkName):
|
||||||
global manager, pathAgent
|
|
||||||
bus = dbus.SystemBus()
|
|
||||||
pathAgent = "/connectToNetwork/agent/" + str(randrange(100))
|
|
||||||
manager = dbus.Interface(bus.get_object('net.connman.iwd', "/"),
|
|
||||||
'net.connman.iwd.Manager')
|
|
||||||
|
|
||||||
def getManager():
|
|
||||||
return manager
|
|
||||||
|
|
||||||
def getPathAgent():
|
|
||||||
return pathAgent
|
|
||||||
|
|
||||||
def getSecondNetworkToConnect(networkList, firstNetworkName):
|
|
||||||
logger.debug(sys._getframe().f_code.co_name)
|
logger.debug(sys._getframe().f_code.co_name)
|
||||||
for networkInfo in networkList:
|
for path in objectList:
|
||||||
properties = networkList[networkInfo]
|
if 'net.connman.iwd.Device' not in objectList[path]:
|
||||||
for key in properties.keys():
|
|
||||||
val = properties[key]
|
|
||||||
# skip the first connected network
|
|
||||||
if (properties["Name"] == firstNetworkName):
|
|
||||||
continue
|
continue
|
||||||
return networkInfo
|
for path2 in objectList:
|
||||||
|
if not path2.startswith(path) or \
|
||||||
|
'net.connman.iwd.Network' not in objectList[path2]:
|
||||||
|
continue
|
||||||
|
network = objectList[path2]['net.connman.iwd.Network']
|
||||||
|
for key in network.keys():
|
||||||
|
if key in ["Name"]:
|
||||||
|
# skip the first connected network
|
||||||
|
if (network[key] == firstNetworkName):
|
||||||
|
continue
|
||||||
|
return path2
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
class TestTwoNetworks(unittest.TestCase):
|
class TestTwoNetworks(unittest.TestCase):
|
||||||
@ -46,7 +38,7 @@ class TestTwoNetworks(unittest.TestCase):
|
|||||||
# connect to network B. disconnect from network B.
|
# connect to network B. disconnect from network B.
|
||||||
def connectToNetwork(self, networkToConnect):
|
def connectToNetwork(self, networkToConnect):
|
||||||
# start simpleAgent
|
# start simpleAgent
|
||||||
proc = Popen([sys.executable, './simpleAgent.py'])
|
proc = Popen([sys.executable, '../utility/simpleAgent.py'])
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
network = dbus.Interface(bus.get_object("net.connman.iwd",
|
network = dbus.Interface(bus.get_object("net.connman.iwd",
|
||||||
networkToConnect),
|
networkToConnect),
|
||||||
@ -80,10 +72,8 @@ class TestTwoNetworks(unittest.TestCase):
|
|||||||
return connectedNetworkName
|
return connectedNetworkName
|
||||||
|
|
||||||
def doConnectDisconnectTwoNetworks(self):
|
def doConnectDisconnectTwoNetworks(self):
|
||||||
deviceList = utility.getDeviceList(bus)
|
objectList = utility.getObjectList(bus)
|
||||||
networkList = utility.getNetworkList(deviceList, bus)
|
networkToConnect = utility.getNetworkToConnectTo(objectList)
|
||||||
utility.printNetworkInfo(networkList)
|
|
||||||
networkToConnect = utility.getNetworkToConnectTo(networkList)
|
|
||||||
|
|
||||||
# check if networkToConnect is not null. If yes, restart program
|
# check if networkToConnect is not null. If yes, restart program
|
||||||
# so that the network list is updated. Alternatively, we can scan
|
# so that the network list is updated. Alternatively, we can scan
|
||||||
@ -98,9 +88,9 @@ class TestTwoNetworks(unittest.TestCase):
|
|||||||
connectedNetworkName = self.connectToNetwork(networkToConnect)
|
connectedNetworkName = self.connectToNetwork(networkToConnect)
|
||||||
|
|
||||||
# connect to the 2nd network
|
# connect to the 2nd network
|
||||||
secondNetworkToConnect = getSecondNetworkToConnect(networkList,
|
secondNetworkToConnect = getSecondNetworkToConnect(objectList,
|
||||||
connectedNetworkName)
|
connectedNetworkName)
|
||||||
connectedNetworkName = self.connectToNetwork(secondNetworkToConnect)
|
connectedNetwork = self.connectToNetwork(secondNetworkToConnect)
|
||||||
|
|
||||||
def test_twoNetworks(self):
|
def test_twoNetworks(self):
|
||||||
logger.info(sys._getframe().f_code.co_name)
|
logger.info(sys._getframe().f_code.co_name)
|
||||||
|
Loading…
Reference in New Issue
Block a user