tests: Use the cmd_execute() function in ap_ht for iw reg set

The ap_ht tests used to execute iw reg set command using the subprocess
python module. Start using the cmd_execute() general function for
executing shell commands so that this would also work on remote setups.

Signed-off-by: Jonathan Afek <jonathanx.afek@intel.com>
This commit is contained in:
Jonathan Afek 2016-06-07 16:42:41 +03:00 committed by Jouni Malinen
parent 6b4300d0c6
commit 113b8a1a3c

View file

@ -22,6 +22,14 @@ def clear_scan_cache(apdev):
time.sleep(0.1) time.sleep(0.1)
subprocess.call(['ifconfig', ifname, 'down']) subprocess.call(['ifconfig', ifname, 'down'])
def set_world_reg(apdev0=None, apdev1=None, dev0=None):
if apdev0:
hostapd.cmd_execute(apdev0, ['iw', 'reg', 'set', '00'])
if apdev1:
hostapd.cmd_execute(apdev1, ['iw', 'reg', 'set', '00'])
if dev0:
dev0.cmd_execute(['iw', 'reg', 'set', '00'])
def test_ap_ht40_scan(dev, apdev): def test_ap_ht40_scan(dev, apdev):
"""HT40 co-ex scan""" """HT40 co-ex scan"""
clear_scan_cache(apdev[0]) clear_scan_cache(apdev[0])
@ -393,7 +401,7 @@ def test_ap_ht40_5ghz_match(dev, apdev):
hapd.request("DISABLE") hapd.request("DISABLE")
if hapd2: if hapd2:
hapd2.request("DISABLE") hapd2.request("DISABLE")
subprocess.call(['iw', 'reg', 'set', '00']) set_world_reg(apdev[0], apdev[1], dev[0])
dev[0].flush_scan_cache() dev[0].flush_scan_cache()
def test_ap_ht40_5ghz_switch(dev, apdev): def test_ap_ht40_5ghz_switch(dev, apdev):
@ -447,7 +455,7 @@ def test_ap_ht40_5ghz_switch(dev, apdev):
hapd.request("DISABLE") hapd.request("DISABLE")
if hapd2: if hapd2:
hapd2.request("DISABLE") hapd2.request("DISABLE")
subprocess.call(['iw', 'reg', 'set', '00']) set_world_reg(apdev[0], apdev[1], dev[0])
def test_ap_ht40_5ghz_switch2(dev, apdev): def test_ap_ht40_5ghz_switch2(dev, apdev):
"""HT40 co-ex scan on 5 GHz switching pri/sec channel (2)""" """HT40 co-ex scan on 5 GHz switching pri/sec channel (2)"""
@ -509,7 +517,7 @@ def test_ap_ht40_5ghz_switch2(dev, apdev):
hapd.request("DISABLE") hapd.request("DISABLE")
if hapd2: if hapd2:
hapd2.request("DISABLE") hapd2.request("DISABLE")
subprocess.call(['iw', 'reg', 'set', '00']) set_world_reg(apdev[0], apdev[1], dev[0])
dev[0].flush_scan_cache() dev[0].flush_scan_cache()
def test_obss_scan(dev, apdev): def test_obss_scan(dev, apdev):
@ -756,7 +764,7 @@ def test_olbc_5ghz(dev, apdev):
hapd.request("DISABLE") hapd.request("DISABLE")
if hapd2: if hapd2:
hapd2.request("DISABLE") hapd2.request("DISABLE")
subprocess.call(['iw', 'reg', 'set', '00']) set_world_reg(apdev[0], apdev[1], None)
def test_ap_require_ht(dev, apdev): def test_ap_require_ht(dev, apdev):
"""Require HT""" """Require HT"""
@ -929,7 +937,7 @@ def test_ap_ht40_csa(dev, apdev):
dev[0].request("DISCONNECT") dev[0].request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") hapd.request("DISABLE")
subprocess.call(['iw', 'reg', 'set', '00']) set_world_reg(apdev[0], None, dev[0])
dev[0].flush_scan_cache() dev[0].flush_scan_cache()
def test_ap_ht40_csa2(dev, apdev): def test_ap_ht40_csa2(dev, apdev):
@ -973,7 +981,7 @@ def test_ap_ht40_csa2(dev, apdev):
dev[0].request("DISCONNECT") dev[0].request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") hapd.request("DISABLE")
subprocess.call(['iw', 'reg', 'set', '00']) set_world_reg(apdev[0], None, dev[0])
dev[0].flush_scan_cache() dev[0].flush_scan_cache()
def test_ap_ht40_csa3(dev, apdev): def test_ap_ht40_csa3(dev, apdev):
@ -1017,7 +1025,7 @@ def test_ap_ht40_csa3(dev, apdev):
dev[0].request("DISCONNECT") dev[0].request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") hapd.request("DISABLE")
subprocess.call(['iw', 'reg', 'set', '00']) set_world_reg(apdev[0], None, dev[0])
dev[0].flush_scan_cache() dev[0].flush_scan_cache()
def test_ap_ht_smps(dev, apdev): def test_ap_ht_smps(dev, apdev):
@ -1131,7 +1139,7 @@ def test_ap_ht40_5ghz_invalid_pair(dev, apdev):
if sec != "0": if sec != "0":
raise Exception("Invalid 40 MHz channel accepted") raise Exception("Invalid 40 MHz channel accepted")
finally: finally:
subprocess.call(['iw', 'reg', 'set', '00']) set_world_reg(apdev[0], None, None)
def test_ap_ht40_5ghz_disabled_sec(dev, apdev): def test_ap_ht40_5ghz_disabled_sec(dev, apdev):
"""HT40 on 5 GHz with disabled secondary channel""" """HT40 on 5 GHz with disabled secondary channel"""
@ -1151,7 +1159,7 @@ def test_ap_ht40_5ghz_disabled_sec(dev, apdev):
if sec != "0": if sec != "0":
raise Exception("Invalid 40 MHz channel accepted") raise Exception("Invalid 40 MHz channel accepted")
finally: finally:
subprocess.call(['iw', 'reg', 'set', '00']) set_world_reg(apdev[0], None, None)
def test_ap_ht40_scan_broken_ap(dev, apdev): def test_ap_ht40_scan_broken_ap(dev, apdev):
"""HT40 co-ex scan and broken legacy/HT AP""" """HT40 co-ex scan and broken legacy/HT AP"""