From patchwork Thu Apr 7 05:38:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz.Dziedzic@tieto.com X-Patchwork-Id: 607247 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qgWcQ2Yycz9t5q for ; Thu, 7 Apr 2016 15:39:18 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=tieto.com header.i=@tieto.com header.b=rOvxel8J; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ao2eu-00057j-NH; Thu, 07 Apr 2016 05:39:12 +0000 Received: from mail-lf0-x231.google.com ([2a00:1450:4010:c07::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ao2eg-0004wn-AX for hostap@lists.infradead.org; Thu, 07 Apr 2016 05:39:04 +0000 Received: by mail-lf0-x231.google.com with SMTP id j11so48842030lfb.1 for ; Wed, 06 Apr 2016 22:38:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tieto.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ts2wAUwS6sSDRyHwHKeJ0cirHRxaaFZuOWRXzv+15W4=; b=rOvxel8J7zufpWMnTpeGpb0BuZILOrvXTMWYfqH+rQYdRF+74o3bzDfh01UMOINy/Q Qyj+x8asOnt4Zz44GoJKqQGPLLO4eydPUnHol5TqgRWOAy772Vw1ASclJLVTuEzE3ttS i2H9AriPaPHexUX4fVIzWXQdjMdCF1XQQsyn0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ts2wAUwS6sSDRyHwHKeJ0cirHRxaaFZuOWRXzv+15W4=; b=BKzv5eAnn3J28US4Wn+FmcNmU+wAV2u2Dm2RuQ//PUFyGlvLQM4rIjvC1FCK6oaD+N nqfwTeaMujNaC8i8Ijv9YI69ifNyMJaCeHenQVULQzinxKFhixasoPfT7ZQ0066zWs4a f6UOObBEfrGTFveQFC9OrDnWEd/5wpQkVXp5raofg8iApyGBLrqP5q0ER6MJzPtPVT4a fuzDYFoAflrWKJ4OK2G8IDH4AcEwjeaeka2bFtmP0BOl8c3K99IkYHFTuQhAvpTBfc2k 4Uh/Qn966ktUALDYJwnU//bhzMottm9bolu+jQJ73rJMaEbyDUy7uPJmEtIHI4sfe1zk /jkA== X-Gm-Message-State: AD7BkJLWd9qXchR/74/F5OSeQs+t8JCOXwKkmSsYg/qu/cfEbP8kIhlVZoCaeyqzDijztSvcXaMZG77zr+KmhEq6Q05gZYmbExgJh8cjyeiMMNaK8JS70Vf2pUUoDtR/i+27/227MSCntH6PDJTTEr1DKKY3nI+p4u0REvT/oZQcxGDd2w5OqTxMToOoKNLXzq8j X-Received: by 10.25.37.135 with SMTP id l129mr586445lfl.56.1460007514010; Wed, 06 Apr 2016 22:38:34 -0700 (PDT) Received: from localhost.localdomain ([213.192.73.50]) by smtp.gmail.com with ESMTPSA id f134sm938018lff.34.2016.04.06.22.38.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Apr 2016 22:38:33 -0700 (PDT) From: Janusz Dziedzic To: hostap@lists.infradead.org Subject: [PATCH v2 04/17] tests: pass apdev to hostapd.add_bss() Date: Thu, 7 Apr 2016 07:38:02 +0200 Message-Id: <1460007495-17921-4-git-send-email-janusz.dziedzic@tieto.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1460007495-17921-1-git-send-email-janusz.dziedzic@tieto.com> References: <1460007495-17921-1-git-send-email-janusz.dziedzic@tieto.com> X-DomainID: tieto.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160406_223858_748981_C1756370 X-CRM114-Status: GOOD ( 12.07 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:4010:c07:0:0:0:231 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@w1.fi, Janusz Dziedzic MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Pass apdev param to hostapd.add_bss(). Kill hardcoded phy param and get phy base on apdev. Signed-off-by: Janusz Dziedzic --- tests/hwsim/hostapd.py | 15 ++++++++--- tests/hwsim/test_ap_dynamic.py | 61 +++++++++++++++++++++--------------------- tests/hwsim/test_ap_ht.py | 6 ++--- tests/hwsim/test_ap_wps.py | 2 +- tests/hwsim/utils.py | 22 +++++++++++++++ 5 files changed, 68 insertions(+), 38 deletions(-) diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py index 868f664..01b336e 100644 --- a/tests/hwsim/hostapd.py +++ b/tests/hwsim/hostapd.py @@ -11,6 +11,7 @@ import binascii import struct import wpaspy import remotehost +import utils logger = logging.getLogger() hapd_ctrl = '/var/run/hostapd' @@ -389,9 +390,17 @@ def add_ap(apdev, params, wait_enabled=True, no_enable=False, timeout=30): raise Exception("AP startup failed") return hapd -def add_bss(phy, ifname, confname, ignore_error=False, hostname=None, - port=8878): - logger.info("Starting BSS phy=" + phy + " ifname=" + ifname) +def add_bss(apdev, ifname, confname, phy=None, ignore_error=False): + if phy == None: + phy = utils.get_phy(apdev) + try: + hostname = apdev['hostname'] + port = apdev['port'] + logger.info("Starting BSS " + hostname + "/" + port + " phy=" + phy + " ifname=" + ifname) + except: + logger.info("Starting BSS phy=" + phy + " ifname=" + ifname) + hostname = None + port = 8878 hapd_global = HostapdGlobal(hostname=hostname, port=port) hapd_global.add_bss(phy, confname, ignore_error) port = hapd_global.get_ctrl_iface_port(ifname) diff --git a/tests/hwsim/test_ap_dynamic.py b/tests/hwsim/test_ap_dynamic.py index a859651..fb8e35c 100644 --- a/tests/hwsim/test_ap_dynamic.py +++ b/tests/hwsim/test_ap_dynamic.py @@ -96,31 +96,31 @@ def _test_ap_bss_add_remove(dev, apdev): ifname2 = apdev[0]['ifname'] + '-2' ifname3 = apdev[0]['ifname'] + '-3' logger.info("Set up three BSSes one by one") - hostapd.add_bss('phy3', ifname1, 'bss-1.conf') + hostapd.add_bss(apdev[0], ifname1, 'bss-1.conf') multi_check(dev, [ True, False, False ]) - hostapd.add_bss('phy3', ifname2, 'bss-2.conf') + hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf') multi_check(dev, [ True, True, False ]) - hostapd.add_bss('phy3', ifname3, 'bss-3.conf') + hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf') multi_check(dev, [ True, True, True ]) logger.info("Remove the last BSS and re-add it") hostapd.remove_bss(apdev[0], ifname3) multi_check(dev, [ True, True, False ]) - hostapd.add_bss('phy3', ifname3, 'bss-3.conf') + hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf') multi_check(dev, [ True, True, True ]) logger.info("Remove the middle BSS and re-add it") hostapd.remove_bss(apdev[0], ifname2) multi_check(dev, [ True, False, True ]) - hostapd.add_bss('phy3', ifname2, 'bss-2.conf') + hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf') multi_check(dev, [ True, True, True ]) logger.info("Remove the first BSS and re-add it and other BSSs") hostapd.remove_bss(apdev[0], ifname1) multi_check(dev, [ False, False, False ]) - hostapd.add_bss('phy3', ifname1, 'bss-1.conf') - hostapd.add_bss('phy3', ifname2, 'bss-2.conf') - hostapd.add_bss('phy3', ifname3, 'bss-3.conf') + hostapd.add_bss(apdev[0], ifname1, 'bss-1.conf') + hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf') + hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf') multi_check(dev, [ True, True, True ]) logger.info("Remove two BSSes and re-add them") @@ -128,9 +128,9 @@ def _test_ap_bss_add_remove(dev, apdev): multi_check(dev, [ True, False, True ]) hostapd.remove_bss(apdev[0], ifname3) multi_check(dev, [ True, False, False ]) - hostapd.add_bss('phy3', ifname2, 'bss-2.conf') + hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf') multi_check(dev, [ True, True, False ]) - hostapd.add_bss('phy3', ifname3, 'bss-3.conf') + hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf') multi_check(dev, [ True, True, True ]) logger.info("Remove three BSSes in and re-add them") @@ -140,15 +140,15 @@ def _test_ap_bss_add_remove(dev, apdev): multi_check(dev, [ True, False, False ]) hostapd.remove_bss(apdev[0], ifname1) multi_check(dev, [ False, False, False ]) - hostapd.add_bss('phy3', ifname1, 'bss-1.conf') + hostapd.add_bss(apdev[0], ifname1, 'bss-1.conf') multi_check(dev, [ True, False, False ]) - hostapd.add_bss('phy3', ifname2, 'bss-2.conf') + hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf') multi_check(dev, [ True, True, False ]) - hostapd.add_bss('phy3', ifname3, 'bss-3.conf') + hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf') multi_check(dev, [ True, True, True ]) logger.info("Test error handling if a duplicate ifname is tried") - hostapd.add_bss('phy3', ifname3, 'bss-3.conf', ignore_error=True) + hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf', ignore_error=True) multi_check(dev, [ True, True, True ]) def test_ap_bss_add_remove_during_ht_scan(dev, apdev): @@ -157,20 +157,20 @@ def test_ap_bss_add_remove_during_ht_scan(dev, apdev): dev[i].flush_scan_cache() ifname1 = apdev[0]['ifname'] ifname2 = apdev[0]['ifname'] + '-2' - hostapd.add_bss('phy3', ifname1, 'bss-ht40-1.conf') - hostapd.add_bss('phy3', ifname2, 'bss-ht40-2.conf') + hostapd.add_bss(apdev[0], ifname1, 'bss-ht40-1.conf') + hostapd.add_bss(apdev[0], ifname2, 'bss-ht40-2.conf') multi_check(dev, [ True, True ], scan_opt=False) hostapd.remove_bss(apdev[0], ifname2) hostapd.remove_bss(apdev[0], ifname1) - hostapd.add_bss('phy3', ifname1, 'bss-ht40-1.conf') - hostapd.add_bss('phy3', ifname2, 'bss-ht40-2.conf') + hostapd.add_bss(apdev[0], ifname1, 'bss-ht40-1.conf') + hostapd.add_bss(apdev[0], ifname2, 'bss-ht40-2.conf') hostapd.remove_bss(apdev[0], ifname2) multi_check(dev, [ True, False ], scan_opt=False) hostapd.remove_bss(apdev[0], ifname1) - hostapd.add_bss('phy3', ifname1, 'bss-ht40-1.conf') - hostapd.add_bss('phy3', ifname2, 'bss-ht40-2.conf') + hostapd.add_bss(apdev[0], ifname1, 'bss-ht40-1.conf') + hostapd.add_bss(apdev[0], ifname2, 'bss-ht40-2.conf') hostapd.remove_bss(apdev[0], ifname1) multi_check(dev, [ False, False ]) @@ -348,8 +348,8 @@ def test_ap_enable_disable_reenable(dev, apdev): def test_ap_double_disable(dev, apdev): """Double DISABLE regression test""" - hostapd.add_bss('phy3', apdev[0]['ifname'], 'bss-1.conf') - hostapd.add_bss('phy3', apdev[0]['ifname'] + '-2', 'bss-2.conf') + hostapd.add_bss(apdev[0], apdev[0]['ifname'], 'bss-1.conf') + hostapd.add_bss(apdev[0], apdev[0]['ifname'] + '-2', 'bss-2.conf') hapd = hostapd.Hostapd(apdev[0]['ifname']) hapd.disable() if "FAIL" not in hapd.request("DISABLE"): @@ -378,8 +378,7 @@ def test_ap_bss_add_many(dev, apdev): def _test_ap_bss_add_many(dev, apdev): ifname = apdev[0]['ifname'] - phy = 'phy3' - hostapd.add_bss(phy, ifname, 'bss-1.conf') + hostapd.add_bss(apdev[0], ifname, 'bss-1.conf') hapd = hostapd.HostapdGlobal() fname = '/tmp/hwsim-bss.conf' for i in range(16): @@ -393,7 +392,7 @@ def _test_ap_bss_add_many(dev, apdev): f.write("bssid=02:00:00:00:03:%02x\n" % (i + 1)) f.write("ctrl_interface=/var/run/hostapd\n") f.write("ssid=test-%d\n" % i) - hostapd.add_bss(phy, ifname2, fname) + hostapd.add_bss(apdev[0], ifname2, fname) os.remove(fname) dev[0].request("SCAN_INTERVAL 1") @@ -411,10 +410,10 @@ def test_ap_bss_add_reuse_existing(dev, apdev): """Dynamic BSS add operation reusing existing interface""" ifname1 = apdev[0]['ifname'] ifname2 = apdev[0]['ifname'] + '-2' - hostapd.add_bss('phy3', ifname1, 'bss-1.conf') + hostapd.add_bss(apdev[0], ifname1, 'bss-1.conf') subprocess.check_call(["iw", "dev", ifname1, "interface", "add", ifname2, "type", "__ap"]) - hostapd.add_bss('phy3', ifname2, 'bss-2.conf') + hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf') hostapd.remove_bss(apdev[0], ifname2) subprocess.check_call(["iw", "dev", ifname2, "del"]) @@ -439,14 +438,14 @@ def test_ap_bss_add_out_of_memory(dev, apdev): hapd_bss_out_of_mem(hapd2, 'phy3', 'bss-1.conf', 1, 'ieee802_11_build_ap_params') - hostapd.add_bss('phy3', ifname1, 'bss-1.conf') + hostapd.add_bss(apdev[0], ifname1, 'bss-1.conf') hapd_bss_out_of_mem(hapd2, 'phy3', 'bss-2.conf', 1, 'hostapd_interface_init_bss') hapd_bss_out_of_mem(hapd2, 'phy3', 'bss-2.conf', 1, 'ieee802_11_build_ap_params') - hostapd.add_bss('phy3', ifname2, 'bss-2.conf') + hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf') hostapd.remove_bss(apdev[0], ifname2) hostapd.remove_bss(apdev[0], ifname1) @@ -454,8 +453,8 @@ def test_ap_multi_bss(dev, apdev): """Multiple BSSes with hostapd""" ifname1 = apdev[0]['ifname'] ifname2 = apdev[0]['ifname'] + '-2' - hostapd.add_bss('phy3', ifname1, 'bss-1.conf') - hostapd.add_bss('phy3', ifname2, 'bss-2.conf') + hostapd.add_bss(apdev[0], ifname1, 'bss-1.conf') + hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf') dev[0].connect("bss-1", key_mgmt="NONE", scan_freq="2412") dev[1].connect("bss-2", key_mgmt="NONE", scan_freq="2412") diff --git a/tests/hwsim/test_ap_ht.py b/tests/hwsim/test_ap_ht.py index e66f7a9..cd52578 100644 --- a/tests/hwsim/test_ap_ht.py +++ b/tests/hwsim/test_ap_ht.py @@ -702,9 +702,9 @@ def test_olbc_table_limit(dev, apdev): ifname1 = apdev[0]['ifname'] ifname2 = apdev[0]['ifname'] + '-2' ifname3 = apdev[0]['ifname'] + '-3' - hostapd.add_bss('phy3', ifname1, 'bss-1.conf') - hostapd.add_bss('phy3', ifname2, 'bss-2.conf') - hostapd.add_bss('phy3', ifname3, 'bss-3.conf') + hostapd.add_bss(apdev[0], ifname1, 'bss-1.conf') + hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf') + hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf') params = { "ssid": "test-olbc", "channel": "1", diff --git a/tests/hwsim/test_ap_wps.py b/tests/hwsim/test_ap_wps.py index ed1de58..aded40b 100644 --- a/tests/hwsim/test_ap_wps.py +++ b/tests/hwsim/test_ap_wps.py @@ -2287,7 +2287,7 @@ def test_ap_wps_auto_setup_with_config_file(dev, apdev): f.write("ssid=wps\n") f.write("eap_server=1\n") f.write("wps_state=1\n") - hostapd.add_bss('phy3', ifname, conffile) + hostapd.add_bss(apdev[0], ifname, conffile) hapd = hostapd.Hostapd(ifname) hapd.request("WPS_PBC") dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412") diff --git a/tests/hwsim/utils.py b/tests/hwsim/utils.py index 1661b20..5fb824e 100644 --- a/tests/hwsim/utils.py +++ b/tests/hwsim/utils.py @@ -6,6 +6,7 @@ import os import time +import remotehost def get_ifnames(): ifnames = [] @@ -80,3 +81,24 @@ def skip_with_fips(dev, reason="Not supported in FIPS mode"): res = dev.get_capability("fips") if res and 'FIPS' in res: raise HwsimSkip(reason) + +def get_phy(ap, ifname=None): + phy = "phy3" + try: + hostname = ap['hostname'] + except: + hostname = None + host = remotehost.Host(hostname) + + if ifname == None: + ifname = ap['ifname'] + status, buf = host.execute("iw dev " + ifname + " info") + if status != 0: + raise Exception("iw " + ifname + " info failed") + lines = buf.split("\n") + for line in lines: + if "wiphy" in line: + words = line.split() + phy = "phy" + words[1] + break + return phy