From 3093e577150be698b83c4bb3e38333cc02787a96 Mon Sep 17 00:00:00 2001 From: Tim Kourt Date: Fri, 30 Sep 2016 15:03:16 -0700 Subject: [PATCH] auto-t: Add scan test --- autotests/testScan/hw.conf | 7 ++++ autotests/testScan/ssidCCMP.conf | 7 ++++ autotests/testScan/ssidOpen.conf | 3 ++ autotests/testScan/ssidTKIP.conf | 7 ++++ autotests/testScan/test.py | 65 ++++++++++++++++++++++++++++++++ 5 files changed, 89 insertions(+) create mode 100644 autotests/testScan/hw.conf create mode 100644 autotests/testScan/ssidCCMP.conf create mode 100644 autotests/testScan/ssidOpen.conf create mode 100644 autotests/testScan/ssidTKIP.conf create mode 100644 autotests/testScan/test.py diff --git a/autotests/testScan/hw.conf b/autotests/testScan/hw.conf new file mode 100644 index 00000000..c2a4351b --- /dev/null +++ b/autotests/testScan/hw.conf @@ -0,0 +1,7 @@ +[SETUP] +num_radios=4 + +[HOSTAPD] +rad0=ssidOpen.conf +rad1=ssidTKIP.conf +rad2=ssidCCMP.conf diff --git a/autotests/testScan/ssidCCMP.conf b/autotests/testScan/ssidCCMP.conf new file mode 100644 index 00000000..074e8228 --- /dev/null +++ b/autotests/testScan/ssidCCMP.conf @@ -0,0 +1,7 @@ +hw_mode=g +channel=1 +ssid=ssidCCMP + +wpa=2 +wpa_pairwise=CCMP +wpa_passphrase=secret123 diff --git a/autotests/testScan/ssidOpen.conf b/autotests/testScan/ssidOpen.conf new file mode 100644 index 00000000..03efa0a3 --- /dev/null +++ b/autotests/testScan/ssidOpen.conf @@ -0,0 +1,3 @@ +hw_mode=g +channel=1 +ssid=ssidOpen diff --git a/autotests/testScan/ssidTKIP.conf b/autotests/testScan/ssidTKIP.conf new file mode 100644 index 00000000..11ef15f0 --- /dev/null +++ b/autotests/testScan/ssidTKIP.conf @@ -0,0 +1,7 @@ +hw_mode=g +channel=1 +ssid=ssidTKIP + +wpa=1 +wpa_pairwise=TKIP +wpa_passphrase=secret123 diff --git a/autotests/testScan/test.py b/autotests/testScan/test.py new file mode 100644 index 00000000..550e128d --- /dev/null +++ b/autotests/testScan/test.py @@ -0,0 +1,65 @@ +#!/usr/bin/python3 + +import unittest +import sys + +sys.path.append('../util') +import iwd +from iwd import IWD +from iwd import NetworkType + +class Test(unittest.TestCase): + + def test_scan(self): + wd = IWD() + + devices = wd.list_devices(); + self.assertIsNotNone(devices) + device = devices[0] + + condition = 'not obj.scanning' + wd.wait_for_object_condition(device, condition) + + device.scan() + + condition = 'not obj.scanning' + wd.wait_for_object_condition(device, condition) + + ordered_networks = device.get_ordered_networks() + + seen = [0] * 3 + for o_n in ordered_networks: + if o_n.name == "ssidOpen": + self.assertEqual(o_n.type, NetworkType.open) + if seen[0]: + raise Exception('Duplicated list entry') + else: + seen[0] = 1 + elif o_n.name == "ssidTKIP": + self.assertEqual(o_n.type, NetworkType.psk) + if seen[1]: + raise Exception('Duplicated list entry') + else: + seen[1] = 1 + elif o_n.name == "ssidCCMP": + self.assertEqual(o_n.type, NetworkType.psk) + if seen[2]: + raise Exception('Duplicated list entry') + else: + seen[2] = 1 + else: + raise Exception() + + for entry in seen: + self.assertNotEqual(entry, 0) + + @classmethod + def setUpClass(cls): + pass + + @classmethod + def tearDownClass(cls): + IWD.clear_storage() + +if __name__ == '__main__': + unittest.main(exit=True)