tests: Use cmd_execute() for iw station get command

The hwsim tests used to execute shell commands in the tests using the
subprocess python module. Use the cmd_execute() general function for
executing "iw ... station get" 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-23 20:16:29 +03:00 committed by Jouni Malinen
parent 525f8293e5
commit 137fd05099

View file

@ -5,7 +5,6 @@
# See README for more details. # See README for more details.
import time import time
import subprocess
import logging import logging
logger = logging.getLogger() logger = logging.getLogger()
@ -413,9 +412,8 @@ def _test_ap_pmf_toggle(dev, apdev):
sta = hapd.get_sta(addr) sta = hapd.get_sta(addr)
if '[MFP]' in sta['flags']: if '[MFP]' in sta['flags']:
raise Exception("MFP flag unexpectedly present for STA") raise Exception("MFP flag unexpectedly present for STA")
cmd = subprocess.Popen(['iw', 'dev', apdev[0]['ifname'], 'station', 'get', err, data = hapd.cmd_execute(['iw', 'dev', apdev[0]['ifname'], 'station',
addr], stdout=subprocess.PIPE) 'get', addr])
(data,err) = cmd.communicate()
if "yes" in [l for l in data.splitlines() if "MFP" in l][0]: if "yes" in [l for l in data.splitlines() if "MFP" in l][0]:
raise Exception("Kernel STA entry had MFP enabled") raise Exception("Kernel STA entry had MFP enabled")
@ -426,9 +424,8 @@ def _test_ap_pmf_toggle(dev, apdev):
sta = hapd.get_sta(addr) sta = hapd.get_sta(addr)
if '[MFP]' not in sta['flags']: if '[MFP]' not in sta['flags']:
raise Exception("MFP flag not present for STA") raise Exception("MFP flag not present for STA")
cmd = subprocess.Popen(['iw', 'dev', apdev[0]['ifname'], 'station', 'get', err, data = hapd.cmd_execute(['iw', 'dev', apdev[0]['ifname'], 'station',
addr], stdout=subprocess.PIPE) 'get', addr])
(data,err) = cmd.communicate()
if "yes" not in [l for l in data.splitlines() if "MFP" in l][0]: if "yes" not in [l for l in data.splitlines() if "MFP" in l][0]:
raise Exception("Kernel STA entry did not have MFP enabled") raise Exception("Kernel STA entry did not have MFP enabled")