mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-25 00:38:24 -05:00
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:
parent
be96f4e8d2
commit
11b3af3dad
@ -99,7 +99,7 @@ class Host():
|
||||
return status, buf.decode()
|
||||
|
||||
# async execute
|
||||
def execute_run(self, command, res, use_reaper=True):
|
||||
def thread_run(self, command, res, use_reaper=True):
|
||||
if use_reaper:
|
||||
filename = gen_reaper_file("reaper")
|
||||
self.send_file(filename, filename)
|
||||
@ -113,13 +113,13 @@ class Host():
|
||||
cmd = _command
|
||||
else:
|
||||
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)
|
||||
t = threading.Thread(target=execute_thread, name=filename, args=(cmd, res))
|
||||
t.start()
|
||||
return t
|
||||
|
||||
def execute_stop(self, t):
|
||||
def thread_stop(self, t):
|
||||
if t.name.find("reaper") == -1:
|
||||
raise Exception("use_reaper required")
|
||||
|
||||
@ -148,13 +148,13 @@ class Host():
|
||||
self.execute(["rm", pid_file])
|
||||
self.execute(["rm", t.name])
|
||||
|
||||
def wait_execute_complete(self, t, wait=None):
|
||||
def thread_wait(self, t, wait=None):
|
||||
if wait == None:
|
||||
wait_str = "infinite"
|
||||
else:
|
||||
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():
|
||||
t.join(wait)
|
||||
|
||||
|
@ -29,7 +29,7 @@ class Wlantest:
|
||||
return
|
||||
|
||||
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_res = []
|
||||
|
||||
@ -64,7 +64,7 @@ class Wlantest:
|
||||
pcap_file, log_file)
|
||||
cls.remote_host.add_log(log_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
|
||||
time.sleep(1)
|
||||
|
||||
|
@ -110,7 +110,7 @@ def run(host, setup_params):
|
||||
|
||||
log = log_dir + tc_name + "_" + host.name + log_monitor + ".pcap"
|
||||
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
|
||||
|
||||
|
||||
@ -122,7 +122,7 @@ def stop(host):
|
||||
if host.thread is None:
|
||||
return
|
||||
|
||||
host.execute_stop(host.thread)
|
||||
host.thread_stop(host.thread)
|
||||
host.thread = None
|
||||
|
||||
# Add monitor to existing interface
|
||||
|
@ -342,11 +342,11 @@ def ping_run(host, ip, result, ifname=None, addr_type="ipv4", deadline="5", qos=
|
||||
|
||||
flush_arp_cache(host)
|
||||
|
||||
thread = host.execute_run(ping, result)
|
||||
thread = host.thread_run(ping, result)
|
||||
return thread
|
||||
|
||||
def ping_wait(host, thread, timeout=None):
|
||||
host.wait_execute_complete(thread, timeout)
|
||||
host.thread_wait(thread, timeout)
|
||||
if thread.isAlive():
|
||||
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(client)
|
||||
|
||||
server_thread = server.execute_run(iperf_server, server_res)
|
||||
server_thread = server.thread_run(iperf_server, server_res)
|
||||
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
|
||||
|
||||
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():
|
||||
raise Exception("iperf client thread still alive")
|
||||
|
||||
server.wait_execute_complete(server_thread, 5)
|
||||
server.thread_wait(server_thread, 5)
|
||||
if server_thread.isAlive():
|
||||
server.execute(["killall", "-s", "INT", iperf])
|
||||
time.sleep(1)
|
||||
|
||||
server.wait_execute_complete(server_thread, 5)
|
||||
server.thread_wait(server_thread, 5)
|
||||
if server_thread.isAlive():
|
||||
raise Exception("iperf server thread still alive")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user