tests/remote: Fix execution of setup_hw

The code contained some places that used an additional argument for
setup_hw after -R and also contained places where setup_hw cmdline was
passed as a string instead of an argument list. It also contained places
where the ifname was only treated as a single interface and disregarded
the possiblity of multiple interfaces. This commit fixes these issues
and executes setup_hw from a single function for all cases.

Signed-off-by: Jonathan Afek <jonathanx.afek@intel.com>
This commit is contained in:
Jonathan Afek 2016-05-19 16:06:50 +03:00 committed by Jouni Malinen
parent 8efc83d4e7
commit 483053b9d8
3 changed files with 32 additions and 39 deletions

View file

@ -7,6 +7,7 @@
import time import time
from remotehost import Host from remotehost import Host
import config import config
import rutils
import re import re
import traceback import traceback
import logging import logging
@ -36,10 +37,7 @@ def create(devices, setup_params, refs, duts, monitors):
try: try:
host.execute(["iw", "reg", "set", setup_params['country']]) host.execute(["iw", "reg", "set", setup_params['country']])
setup_hw = setup_params['setup_hw'] rutils.setup_hw_host(host, setup_params, True)
ifaces = re.split('; | |, ', host.ifname)
for iface in ifaces:
host.execute(setup_hw + " -I " + iface + " -R 1")
except: except:
pass pass
mhosts.append(host) mhosts.append(host)

View file

@ -4,6 +4,7 @@
# This software may be distributed under the terms of the BSD license. # This software may be distributed under the terms of the BSD license.
# See README for more details. # See README for more details.
import re
import time import time
from remotehost import Host from remotehost import Host
import hostapd import hostapd
@ -26,23 +27,32 @@ def get_host(devices, dev_name):
return host return host
# run setup_hw - hw specyfic # run setup_hw - hw specyfic
def setup_hw(hosts, setup_params): def setup_hw_host_iface(host, iface, setup_params, force_restart=False):
for host in hosts:
setup_hw_host(host, setup_params)
def setup_hw_host(host, setup_params):
try: try:
setup_hw = setup_params['setup_hw'] setup_hw = setup_params['setup_hw']
restart = "" restart = ""
try: try:
if setup_params['restart_device'] == True: if setup_params['restart_device'] == True:
restart = " -R " restart = "-R"
except: except:
pass pass
host.execute([setup_hw, "-I", host.ifname, restart])
if force_restart:
restart = "-R"
host.execute([setup_hw, "-I", iface, restart])
except: except:
pass pass
def setup_hw_host(host, setup_params, force_restart=False):
ifaces = re.split('; | |, ', host.ifname)
for iface in ifaces:
setup_hw_host_iface(host, iface, setup_params, force_restart)
def setup_hw(hosts, setup_params, force_restart=False):
for host in hosts:
setup_hw_host(host, setup_params, force_restart)
# get traces - hw specific # get traces - hw specific
def trace_start(hosts, setup_params): def trace_start(hosts, setup_params):
for host in hosts: for host in hosts:

View file

@ -35,26 +35,21 @@ def show_devices(devices, setup_params):
else: else:
print "[" + host.name + "] - ssh communication: OK" print "[" + host.name + "] - ssh communication: OK"
# check setup_hw works correctly # check setup_hw works correctly
try: rutils.setup_hw_host(host, setup_params)
setup_hw = setup_params['setup_hw']
try:
restart_device = setup_params['restart_device']
except:
restart_device = "0"
host.execute([setup_hw, "-I", host.ifname, "-R", restart_device])
except:
pass
# show uname # show uname
status, buf = host.execute(["uname", "-s", "-n", "-r", "-m", "-o"]) status, buf = host.execute(["uname", "-s", "-n", "-r", "-m", "-o"])
print "\t" + buf print "\t" + buf
# show ifconfig # show ifconfig
status, buf = host.execute(["ifconfig", host.ifname]) ifaces = re.split('; | |, ', host.ifname)
if status != 0: for iface in ifaces:
print "\t" + host.ifname + " failed\n" status, buf = host.execute(["ifconfig", iface])
continue if status != 0:
lines = buf.splitlines() print "\t" + iface + " failed\n"
for line in lines: continue
print "\t" + line lines = buf.splitlines()
for line in lines:
print "\t" + line
# check hostapd, wpa_supplicant, iperf exist # check hostapd, wpa_supplicant, iperf exist
status, buf = host.execute([setup_params['wpa_supplicant'], "-v"]) status, buf = host.execute([setup_params['wpa_supplicant'], "-v"])
if status != 0: if status != 0:
@ -88,19 +83,9 @@ def check_device(devices, setup_params, dev_name, monitor=False):
if status != 0: if status != 0:
raise Exception(dev_name + " - ssh communication FAILED: " + buf) raise Exception(dev_name + " - ssh communication FAILED: " + buf)
ifaces = re.split('; | |, ', host.ifname) rutils.setup_hw_host(host, setup_params)
# try to setup host/ifaces
for iface in ifaces:
try:
setup_hw = setup_params['setup_hw']
try:
restart_device = setup_params['restart_device']
except:
restart_device = "0"
host.execute(setup_hw + " -I " + iface + " -R " + restart_device)
except:
pass
ifaces = re.split('; | |, ', host.ifname)
# check interfaces (multi for monitor) # check interfaces (multi for monitor)
for iface in ifaces: for iface in ifaces:
status, buf = host.execute(["ifconfig", iface]) status, buf = host.execute(["ifconfig", iface])