From b8573ad7ac59743e1e6803ea08c8cee7920edcd2 Mon Sep 17 00:00:00 2001 From: Tim Kourt Date: Fri, 30 Sep 2016 15:03:19 -0700 Subject: [PATCH] auto-t: remove old 1 AP test --- autotests/test1AP/APShutdownTest.py | 97 --------------------- autotests/test1AP/IntelWIFI_CCMP.conf | 8 -- autotests/test1AP/IntelWIFI_TKIP.conf | 7 -- autotests/test1AP/README.txt | 44 ---------- autotests/test1AP/connectDisconnectTest.py | 98 ---------------------- autotests/test1AP/hw.conf | 6 -- autotests/test1AP/invalidPassphrase.conf | 7 -- autotests/test1AP/invalidPassphraseTest.py | 82 ------------------ autotests/test1AP/scanNetworkTest.py | 37 -------- 9 files changed, 386 deletions(-) delete mode 100755 autotests/test1AP/APShutdownTest.py delete mode 100644 autotests/test1AP/IntelWIFI_CCMP.conf delete mode 100644 autotests/test1AP/IntelWIFI_TKIP.conf delete mode 100644 autotests/test1AP/README.txt delete mode 100755 autotests/test1AP/connectDisconnectTest.py delete mode 100644 autotests/test1AP/hw.conf delete mode 100644 autotests/test1AP/invalidPassphrase.conf delete mode 100755 autotests/test1AP/invalidPassphraseTest.py delete mode 100755 autotests/test1AP/scanNetworkTest.py diff --git a/autotests/test1AP/APShutdownTest.py b/autotests/test1AP/APShutdownTest.py deleted file mode 100755 index 756658f3..00000000 --- a/autotests/test1AP/APShutdownTest.py +++ /dev/null @@ -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) diff --git a/autotests/test1AP/IntelWIFI_CCMP.conf b/autotests/test1AP/IntelWIFI_CCMP.conf deleted file mode 100644 index 23ba82f8..00000000 --- a/autotests/test1AP/IntelWIFI_CCMP.conf +++ /dev/null @@ -1,8 +0,0 @@ -hw_mode=g -channel=1 -ssid=IntelWIFI - -wpa=2 -wpa_key_mgmt=WPA-PSK -wpa_pairwise=CCMP -wpa_passphrase=EasilyGuessedPassword diff --git a/autotests/test1AP/IntelWIFI_TKIP.conf b/autotests/test1AP/IntelWIFI_TKIP.conf deleted file mode 100644 index 85379d6b..00000000 --- a/autotests/test1AP/IntelWIFI_TKIP.conf +++ /dev/null @@ -1,7 +0,0 @@ -hw_mode=g -channel=1 -ssid=IntelWIFI - -wpa=1 -wpa_pairwise=TKIP -wpa_passphrase=EasilyGuessedPassword diff --git a/autotests/test1AP/README.txt b/autotests/test1AP/README.txt deleted file mode 100644 index 0f4ba977..00000000 --- a/autotests/test1AP/README.txt +++ /dev/null @@ -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 -2. Start iwd. - sudo iwd -3. Start connectDisconnect test (inside autotests directory). - cd /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") diff --git a/autotests/test1AP/connectDisconnectTest.py b/autotests/test1AP/connectDisconnectTest.py deleted file mode 100755 index 69ffa9f5..00000000 --- a/autotests/test1AP/connectDisconnectTest.py +++ /dev/null @@ -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) diff --git a/autotests/test1AP/hw.conf b/autotests/test1AP/hw.conf deleted file mode 100644 index 6faafe0e..00000000 --- a/autotests/test1AP/hw.conf +++ /dev/null @@ -1,6 +0,0 @@ -[SETUP] -num_radios=3 - -[HOSTAPD] -rad0=IntelWIFI_TKIP.conf -rad1=invalidPassphrase.conf diff --git a/autotests/test1AP/invalidPassphrase.conf b/autotests/test1AP/invalidPassphrase.conf deleted file mode 100644 index 18796eb1..00000000 --- a/autotests/test1AP/invalidPassphrase.conf +++ /dev/null @@ -1,7 +0,0 @@ -hw_mode=g -channel=1 -ssid=IntelWIFI_WrongPW - -wpa=1 -wpa_pairwise=TKIP -wpa_passphrase=WrongPassword diff --git a/autotests/test1AP/invalidPassphraseTest.py b/autotests/test1AP/invalidPassphraseTest.py deleted file mode 100755 index 3239f4ee..00000000 --- a/autotests/test1AP/invalidPassphraseTest.py +++ /dev/null @@ -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) diff --git a/autotests/test1AP/scanNetworkTest.py b/autotests/test1AP/scanNetworkTest.py deleted file mode 100755 index b75588fd..00000000 --- a/autotests/test1AP/scanNetworkTest.py +++ /dev/null @@ -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)