mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-01-20 01:14:07 +01:00
autotests: notify tests after registerAgent()
This commit is contained in:
parent
fc0fd49cbd
commit
6be18cff4e
@ -7,17 +7,31 @@ import dbus
|
||||
import time
|
||||
import logging
|
||||
import os
|
||||
from random import randrange
|
||||
from subprocess import Popen
|
||||
from subprocess import Popen, PIPE, STDOUT
|
||||
import sys
|
||||
sys.path.append('../utility') #needed to import all the utility modules
|
||||
import utility
|
||||
import pty
|
||||
|
||||
class TestConnectDisconnect(unittest.TestCase):
|
||||
def doConnectDisconnect(self):
|
||||
objectList = utility.getObjectList(bus)
|
||||
networkToConnect = utility.getNetworkToConnectTo(objectList)
|
||||
|
||||
# start simpleAgent
|
||||
master, slave = pty.openpty()
|
||||
proc = Popen([sys.executable, '../utility/simpleAgent.py'],
|
||||
stdin=PIPE, stdout=slave, close_fds=True)
|
||||
stdout_handle = os.fdopen(master)
|
||||
if stdout_handle.readline().rstrip() == "AGENT_REGISTERED":
|
||||
logger.debug("Agent Registered")
|
||||
else:
|
||||
logger.debug("Agent failed to register")
|
||||
|
||||
# close the handles
|
||||
stdout_handle.close()
|
||||
os.close(slave)
|
||||
|
||||
networkToConnect = utility.getNetworkToConnectTo(objectList)
|
||||
# check if networkToConnect is not null. If yes, restart program
|
||||
# so that the network list is updated. Alternatively, we can scan
|
||||
# for networks.
|
||||
@ -27,9 +41,6 @@ class TestConnectDisconnect(unittest.TestCase):
|
||||
os.execl(sys.executable, sys.executable, * sys.argv)
|
||||
|
||||
self.assertNotEqual(networkToConnect, "")
|
||||
# start simpleAgent
|
||||
proc = Popen([sys.executable, '../utility/simpleAgent.py'])
|
||||
time.sleep(2)
|
||||
network = dbus.Interface(bus.get_object(utility.IWD_SERVICE,
|
||||
networkToConnect),
|
||||
utility.IWD_NETWORK_INTERFACE)
|
||||
@ -69,9 +80,6 @@ class TestConnectDisconnect(unittest.TestCase):
|
||||
if bus.name_has_owner(utility.IWD_SERVICE) == True:
|
||||
break
|
||||
self.doConnectDisconnect()
|
||||
#watch doesn't seem to work. So used name_has_owner
|
||||
#watch = bus.watch_name_owner(utility.IWD_SERVICE,
|
||||
# self.doConnectDisconnect)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -9,11 +9,12 @@ import dbus.mainloop.glib
|
||||
import time
|
||||
import threading
|
||||
import logging
|
||||
from subprocess import Popen
|
||||
from subprocess import Popen, PIPE, STDOUT
|
||||
import sys
|
||||
import os
|
||||
sys.path.append('../utility') #needed to import all the utlilty modules
|
||||
import utility
|
||||
import pty
|
||||
|
||||
def getSecondNetworkToConnect(objectList, firstNetworkName):
|
||||
logger.debug(sys._getframe().f_code.co_name)
|
||||
@ -32,8 +33,19 @@ class TestTwoNetworks(unittest.TestCase):
|
||||
# connect to network B. disconnect from network B.
|
||||
def connectToNetwork(self, networkToConnect):
|
||||
# start simpleAgent
|
||||
proc = Popen([sys.executable, '../utility/simpleAgent.py'])
|
||||
time.sleep(2)
|
||||
master, slave = pty.openpty()
|
||||
proc = Popen([sys.executable, '../utility/simpleAgent.py'],
|
||||
stdin=PIPE, stdout=slave, close_fds=True)
|
||||
stdout_handle = os.fdopen(master)
|
||||
if stdout_handle.readline().rstrip() == "AGENT_REGISTERED":
|
||||
logger.debug("Agent Registered")
|
||||
else:
|
||||
logger.debug("Agent failed to register")
|
||||
|
||||
# close the handles
|
||||
stdout_handle.close()
|
||||
os.close(slave)
|
||||
|
||||
network = dbus.Interface(bus.get_object(utility.IWD_SERVICE,
|
||||
networkToConnect),
|
||||
utility.IWD_NETWORK_INTERFACE)
|
||||
|
@ -9,7 +9,6 @@ import logging
|
||||
import traceback
|
||||
import threading
|
||||
import time
|
||||
|
||||
import sys
|
||||
sys.path.append('../utility') #needed to import all the utlilty modules
|
||||
import utility
|
||||
@ -55,6 +54,8 @@ def registerAgent(bus, mainloop):
|
||||
try:
|
||||
manager.RegisterAgent(pathAgent)
|
||||
logger.debug("Registered iwd agent")
|
||||
# this will be received by stdout in the parent
|
||||
print("AGENT_REGISTERED")
|
||||
except:
|
||||
logger.debug("Error in registering path")
|
||||
logger.debug(traceback.print_exc(file=sys.stdout))
|
||||
|
Loading…
Reference in New Issue
Block a user