tests: remotehost: Use correct name

While we start thread use:
 - thread_run
 - therad_stop
 - thread_wait

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@gmail.com>
This commit is contained in:
Janusz Dziedzic 2020-11-07 11:49:14 +01:00 committed by Jouni Malinen
parent be96f4e8d2
commit 11b3af3dad
4 changed files with 16 additions and 16 deletions

View file

@ -99,7 +99,7 @@ class Host():
return status, buf.decode() return status, buf.decode()
# async execute # async execute
def execute_run(self, command, res, use_reaper=True): def thread_run(self, command, res, use_reaper=True):
if use_reaper: if use_reaper:
filename = gen_reaper_file("reaper") filename = gen_reaper_file("reaper")
self.send_file(filename, filename) self.send_file(filename, filename)
@ -113,13 +113,13 @@ class Host():
cmd = _command cmd = _command
else: else:
cmd = ["ssh", self.user + "@" + self.host, ' '.join(_command)] cmd = ["ssh", self.user + "@" + self.host, ' '.join(_command)]
_cmd = self.name + " execute_run: " + ' '.join(cmd) _cmd = self.name + " thread_run: " + ' '.join(cmd)
logger.debug(_cmd) logger.debug(_cmd)
t = threading.Thread(target=execute_thread, name=filename, args=(cmd, res)) t = threading.Thread(target=execute_thread, name=filename, args=(cmd, res))
t.start() t.start()
return t return t
def execute_stop(self, t): def thread_stop(self, t):
if t.name.find("reaper") == -1: if t.name.find("reaper") == -1:
raise Exception("use_reaper required") raise Exception("use_reaper required")
@ -148,13 +148,13 @@ class Host():
self.execute(["rm", pid_file]) self.execute(["rm", pid_file])
self.execute(["rm", t.name]) self.execute(["rm", t.name])
def wait_execute_complete(self, t, wait=None): def thread_wait(self, t, wait=None):
if wait == None: if wait == None:
wait_str = "infinite" wait_str = "infinite"
else: else:
wait_str = str(wait) + "s" wait_str = str(wait) + "s"
logger.debug(self.name + " wait_execute_complete(" + wait_str + "): ") logger.debug(self.name + " thread_wait(" + wait_str + "): ")
if t.isAlive(): if t.isAlive():
t.join(wait) t.join(wait)

View file

@ -29,7 +29,7 @@ class Wlantest:
return return
cls.remote_host.execute(["killall", "-9", "wlantest"]) cls.remote_host.execute(["killall", "-9", "wlantest"])
cls.remote_host.wait_execute_complete(cls.exe_thread, 5) cls.remote_host.thread_wait(cls.exe_thread, 5)
cls.exe_thread = None cls.exe_thread = None
cls.exe_res = [] cls.exe_res = []
@ -64,7 +64,7 @@ class Wlantest:
pcap_file, log_file) pcap_file, log_file)
cls.remote_host.add_log(log_file) cls.remote_host.add_log(log_file)
cls.remote_host.add_log(pcap_file) cls.remote_host.add_log(pcap_file)
cls.exe_thread = cls.remote_host.execute_run(cmd.split(), cls.exe_res) cls.exe_thread = cls.remote_host.thread_run(cmd.split(), cls.exe_res)
# Give wlantest a chance to start working # Give wlantest a chance to start working
time.sleep(1) time.sleep(1)

View file

@ -110,7 +110,7 @@ def run(host, setup_params):
log = log_dir + tc_name + "_" + host.name + log_monitor + ".pcap" log = log_dir + tc_name + "_" + host.name + log_monitor + ".pcap"
host.add_log(log) host.add_log(log)
thread = host.execute_run([tshark, "-w", log], monitor_res) thread = host.thread_run([tshark, "-w", log], monitor_res)
host.thread = thread host.thread = thread
@ -122,7 +122,7 @@ def stop(host):
if host.thread is None: if host.thread is None:
return return
host.execute_stop(host.thread) host.thread_stop(host.thread)
host.thread = None host.thread = None
# Add monitor to existing interface # Add monitor to existing interface

View file

@ -342,11 +342,11 @@ def ping_run(host, ip, result, ifname=None, addr_type="ipv4", deadline="5", qos=
flush_arp_cache(host) flush_arp_cache(host)
thread = host.execute_run(ping, result) thread = host.thread_run(ping, result)
return thread return thread
def ping_wait(host, thread, timeout=None): def ping_wait(host, thread, timeout=None):
host.wait_execute_complete(thread, timeout) host.thread_wait(thread, timeout)
if thread.isAlive(): if thread.isAlive():
raise Exception("ping thread still alive") raise Exception("ping thread still alive")
@ -496,23 +496,23 @@ def iperf_run(server, client, server_ip, client_res, server_res,
flush_arp_cache(server) flush_arp_cache(server)
flush_arp_cache(client) flush_arp_cache(client)
server_thread = server.execute_run(iperf_server, server_res) server_thread = server.thread_run(iperf_server, server_res)
time.sleep(1) time.sleep(1)
client_thread = client.execute_run(iperf_client, client_res) client_thread = client.thread_run(iperf_client, client_res)
return server_thread, client_thread return server_thread, client_thread
def iperf_wait(server, client, server_thread, client_thread, timeout=None, iperf="iperf"): def iperf_wait(server, client, server_thread, client_thread, timeout=None, iperf="iperf"):
client.wait_execute_complete(client_thread, timeout) client.thread_wait(client_thread, timeout)
if client_thread.isAlive(): if client_thread.isAlive():
raise Exception("iperf client thread still alive") raise Exception("iperf client thread still alive")
server.wait_execute_complete(server_thread, 5) server.thread_wait(server_thread, 5)
if server_thread.isAlive(): if server_thread.isAlive():
server.execute(["killall", "-s", "INT", iperf]) server.execute(["killall", "-s", "INT", iperf])
time.sleep(1) time.sleep(1)
server.wait_execute_complete(server_thread, 5) server.thread_wait(server_thread, 5)
if server_thread.isAlive(): if server_thread.isAlive():
raise Exception("iperf server thread still alive") raise Exception("iperf server thread still alive")