mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-23 22:42:37 +01:00
auto-t: remove old 1 AP test
This commit is contained in:
parent
ef6bef27d5
commit
b8573ad7ac
@ -1,97 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
#built-in python libraries
|
||||
import unittest
|
||||
from gi.repository import GLib
|
||||
import dbus
|
||||
import time
|
||||
import logging
|
||||
import os
|
||||
from subprocess import Popen, PIPE, STDOUT, call, check_output
|
||||
import sys
|
||||
sys.path.append('../utility') #needed to import all the utility modules
|
||||
import utility
|
||||
import pty
|
||||
import signal
|
||||
|
||||
class TestAPShutdown(unittest.TestCase):
|
||||
def doConnectDisconnect(self):
|
||||
objectList = utility.getObjectList(bus)
|
||||
|
||||
# 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,
|
||||
"IntelWIFI")
|
||||
# check if networkToConnect is not null. If yes, restart program
|
||||
# so that the network list is updated. Alternatively, we can scan
|
||||
# for networks.
|
||||
if (networkToConnect == ""):
|
||||
time.sleep(2)
|
||||
logger.debug("RESTART PROGRAM")
|
||||
os.execl(sys.executable, sys.executable, * sys.argv)
|
||||
|
||||
self.assertNotEqual(networkToConnect, "")
|
||||
network = dbus.Interface(bus.get_object(utility.IWD_SERVICE,
|
||||
networkToConnect),
|
||||
utility.IWD_NETWORK_INTERFACE)
|
||||
|
||||
status = utility.connect(networkToConnect, self, mainloop, bus)
|
||||
|
||||
if status == False:
|
||||
#terminate proc
|
||||
proc.terminate()
|
||||
return
|
||||
logger.info("Currently connected to: %s",
|
||||
utility.getCurrentlyConnectedNetworkName())
|
||||
self.assertEqual(utility.getCurrentlyConnectedNetworkName(),
|
||||
"IntelWIFI")
|
||||
|
||||
#kill AP
|
||||
pid_bytes = check_output("pgrep -o -x hostapd", shell=True)
|
||||
pid = pid_bytes.decode('utf-8')
|
||||
logger.debug("shutting down AP with pid: %s", pid)
|
||||
os.system("kill " + pid)
|
||||
|
||||
#should not be connected to any network after AP shutdown
|
||||
logger.info("After AP shutdown, connected to: %s",
|
||||
utility.getCurrentlyConnectedNetworkName())
|
||||
self.assertEqual(utility.getCurrentlyConnectedNetworkName(),
|
||||
"")
|
||||
#terminate proc
|
||||
proc.terminate()
|
||||
|
||||
# connect to network A. Wait for 2 seconds. Disconnect.
|
||||
def test_APShutdown(self):
|
||||
logger.info(sys._getframe().f_code.co_name)
|
||||
while (True):
|
||||
if bus.name_has_owner(utility.IWD_SERVICE) == True:
|
||||
break
|
||||
self.doConnectDisconnect()
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
global logger, bus, mainloop
|
||||
os.system("rm -rf /var/lib/iwd")
|
||||
utility.initLogger()
|
||||
logger = logging.getLogger(__name__)
|
||||
bus = dbus.SystemBus()
|
||||
mainloop = GLib.MainLoop()
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
mainloop.quit()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(exit=True)
|
@ -1,8 +0,0 @@
|
||||
hw_mode=g
|
||||
channel=1
|
||||
ssid=IntelWIFI
|
||||
|
||||
wpa=2
|
||||
wpa_key_mgmt=WPA-PSK
|
||||
wpa_pairwise=CCMP
|
||||
wpa_passphrase=EasilyGuessedPassword
|
@ -1,7 +0,0 @@
|
||||
hw_mode=g
|
||||
channel=1
|
||||
ssid=IntelWIFI
|
||||
|
||||
wpa=1
|
||||
wpa_pairwise=TKIP
|
||||
wpa_passphrase=EasilyGuessedPassword
|
@ -1,44 +0,0 @@
|
||||
scanNetworkTest: This test checks that we find the right AP, as
|
||||
specified in the hostapd conf file.
|
||||
conf file: IntelWIFI_CCMP.conf, IntelWIFI_TKIP.conf
|
||||
|
||||
connectDisconnectTest: Connect and disconnect from a network
|
||||
as specified in the hostapd conf file.
|
||||
conf file: IntelWIFI_CCMP.conf, IntelWIFI_TKIP.conf
|
||||
|
||||
invalidPassphraseTest: Try to connect to a network with an
|
||||
invalid passphrase. The connection is
|
||||
unsuccessful.
|
||||
conf file: invalidPassphrase.conf
|
||||
|
||||
APShutdownTest: Connect to a network. Shutdown the AP. The
|
||||
connection is lost.
|
||||
conf file: IntelWIFI_CCMP.conf, IntelWIFI_TKIP.conf
|
||||
NOTE: Test will be removed once hwsim supports
|
||||
the ability to modify signal strength.
|
||||
|
||||
Pre-requisites:
|
||||
1. Ensure you have hostapd installed.
|
||||
2. Verify that the kernel has mac80211_hwsim.
|
||||
|
||||
Setup:
|
||||
1. Create radios using mac80211_hwsim. For most tests, we need 2 radios.
|
||||
sudo modprobe mac80211_hwsim radios=2
|
||||
2. Enable network interfaces:
|
||||
sudo ifconfig wlan0 up
|
||||
sudo ifconfig wlan1 up
|
||||
|
||||
Run tests (e.g. connectDisconnect test):
|
||||
1. Start hostapd, with a config file as an argument.
|
||||
You can use the IntelWIFI.conf file in autotests/test1AP directory.
|
||||
sudo ./hostapd <path to autotests dir/test1AP/IntelWIFI.conf>
|
||||
2. Start iwd.
|
||||
sudo iwd
|
||||
3. Start connectDisconnect test (inside autotests directory).
|
||||
cd <iwd>/autotests/test1AP
|
||||
./connectDisconnect.py
|
||||
|
||||
Optional changes:
|
||||
1. You can provide your own config file to hostapd. If so, then you would need to
|
||||
change the assert inside the test to the name of the ssid in your test.
|
||||
self.assertEqual(connectedNetworkName, "IntelWIFI")
|
@ -1,98 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
#built-in python libraries
|
||||
import unittest
|
||||
from gi.repository import GLib
|
||||
import dbus
|
||||
import time
|
||||
import logging
|
||||
import os
|
||||
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)
|
||||
|
||||
# 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,
|
||||
"IntelWIFI")
|
||||
# check if networkToConnect is not null. If yes, restart program
|
||||
# so that the network list is updated. Alternatively, we can scan
|
||||
# for networks.
|
||||
if (networkToConnect == ""):
|
||||
time.sleep(2)
|
||||
logger.debug("RESTART PROGRAM")
|
||||
os.execl(sys.executable, sys.executable, * sys.argv)
|
||||
|
||||
self.assertNotEqual(networkToConnect, "")
|
||||
network = dbus.Interface(bus.get_object(utility.IWD_SERVICE,
|
||||
networkToConnect),
|
||||
utility.IWD_NETWORK_INTERFACE)
|
||||
|
||||
status = utility.connect(networkToConnect, self, mainloop, bus)
|
||||
|
||||
if status == False:
|
||||
#terminate proc
|
||||
proc.terminate()
|
||||
return
|
||||
logger.info("Currently connected to: %s",
|
||||
utility.getCurrentlyConnectedNetworkName())
|
||||
self.assertEqual(utility.getCurrentlyConnectedNetworkName(),
|
||||
"IntelWIFI")
|
||||
|
||||
# retrieve the deviceId form networkToConnect. This will be used
|
||||
# for checking if we are disconnecting from the right device later.
|
||||
deviceIdIndex = networkToConnect.rfind("/", 0,
|
||||
len(networkToConnect))
|
||||
deviceIdOfConnectedNetwork = networkToConnect[0:deviceIdIndex]
|
||||
logger.debug("device id of connected network %s",
|
||||
deviceIdOfConnectedNetwork)
|
||||
|
||||
# wait 2 seconds before initiating disconnect
|
||||
time.sleep(2)
|
||||
deviceIdToDisconnect = utility.getCurrentlyConnectedDevice()
|
||||
logger.info("Disconnecting from: %s", deviceIdToDisconnect)
|
||||
self.assertEqual(deviceIdToDisconnect, deviceIdOfConnectedNetwork)
|
||||
utility.disconnect(deviceIdToDisconnect, mainloop, bus)
|
||||
#terminate proc
|
||||
proc.terminate()
|
||||
|
||||
# connect to network A. Wait for 2 seconds. Disconnect.
|
||||
def test_connectDisconnect(self):
|
||||
logger.info(sys._getframe().f_code.co_name)
|
||||
while (True):
|
||||
if bus.name_has_owner(utility.IWD_SERVICE) == True:
|
||||
break
|
||||
self.doConnectDisconnect()
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
global logger, bus, mainloop
|
||||
utility.initLogger()
|
||||
logger = logging.getLogger(__name__)
|
||||
bus = dbus.SystemBus()
|
||||
mainloop = GLib.MainLoop()
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
mainloop.quit()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(exit=True)
|
@ -1,6 +0,0 @@
|
||||
[SETUP]
|
||||
num_radios=3
|
||||
|
||||
[HOSTAPD]
|
||||
rad0=IntelWIFI_TKIP.conf
|
||||
rad1=invalidPassphrase.conf
|
@ -1,7 +0,0 @@
|
||||
hw_mode=g
|
||||
channel=1
|
||||
ssid=IntelWIFI_WrongPW
|
||||
|
||||
wpa=1
|
||||
wpa_pairwise=TKIP
|
||||
wpa_passphrase=WrongPassword
|
@ -1,82 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
#built-in python libraries
|
||||
import unittest
|
||||
from gi.repository import GLib
|
||||
import dbus
|
||||
import time
|
||||
import logging
|
||||
import os
|
||||
from subprocess import Popen, PIPE, STDOUT
|
||||
import sys
|
||||
import subprocess
|
||||
sys.path.append('../utility') #needed to import all the utility modules
|
||||
import utility
|
||||
import pty
|
||||
|
||||
class TestInvalidPassphrase(unittest.TestCase):
|
||||
def doConnectDisconnect(self):
|
||||
objectList = utility.getObjectList(bus)
|
||||
|
||||
# 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,
|
||||
"IntelWIFI_WrongPW")
|
||||
# check if networkToConnect is not null. If yes, restart program
|
||||
# so that the network list is updated. Alternatively, we can scan
|
||||
# for networks.
|
||||
if (networkToConnect == ""):
|
||||
time.sleep(2)
|
||||
logger.debug("RESTART PROGRAM")
|
||||
os.execl(sys.executable, sys.executable, * sys.argv)
|
||||
|
||||
self.assertNotEqual(networkToConnect, "")
|
||||
network = dbus.Interface(bus.get_object(utility.IWD_SERVICE,
|
||||
networkToConnect),
|
||||
utility.IWD_NETWORK_INTERFACE)
|
||||
try:
|
||||
network.Connect()
|
||||
except:
|
||||
errorMsg = "Could not connect to network %s", networkToConnect
|
||||
logger.debug(errorMsg)
|
||||
|
||||
self.assertEqual(utility.getCurrentlyConnectedNetworkName(),
|
||||
"")
|
||||
#terminate proc
|
||||
proc.terminate()
|
||||
|
||||
# connect to network A. Wait for 2 seconds. Disconnect.
|
||||
def test_invalidPassphrase(self):
|
||||
logger.info(sys._getframe().f_code.co_name)
|
||||
while (True):
|
||||
if bus.name_has_owner(utility.IWD_SERVICE) == True:
|
||||
break
|
||||
self.doConnectDisconnect()
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
global logger, bus, mainloop
|
||||
os.system("rm -rf /var/lib/iwd")
|
||||
utility.initLogger()
|
||||
logger = logging.getLogger(__name__)
|
||||
bus = dbus.SystemBus()
|
||||
mainloop = GLib.MainLoop()
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
mainloop.quit()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(exit=True)
|
@ -1,37 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
#built-in python libraries
|
||||
import unittest
|
||||
import dbus
|
||||
import logging
|
||||
import sys
|
||||
import time
|
||||
import os
|
||||
sys.path.append('../utility') #needed to import all the utility modules
|
||||
import utility
|
||||
|
||||
class TestScanNetwork(unittest.TestCase):
|
||||
def test_scanNetwork(self):
|
||||
logger.info(sys._getframe().f_code.co_name)
|
||||
objectList = utility.getObjectList(bus)
|
||||
networkName = utility.getNetworkName(objectList)
|
||||
# check if networkName is not null. If yes, restart program.
|
||||
# Alternatively, we can scan for networks.
|
||||
if networkName == "":
|
||||
time.sleep(2)
|
||||
logger.debug("RESTART PROGRAM")
|
||||
os.execl(sys.executable, sys.executable, * sys.argv)
|
||||
|
||||
logger.info("Network Found: %s", networkName)
|
||||
networkListToMatch = ["IntelWIFI", "IntelWIFI_WrongPW"]
|
||||
self.assertIn(networkName, networkListToMatch)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
global logger, bus
|
||||
utility.initLogger()
|
||||
logger = logging.getLogger(__name__)
|
||||
bus = dbus.SystemBus()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(exit=True)
|
Loading…
Reference in New Issue
Block a user