tests: remote: Add run_monitor test case
This is useful to run monitor quickly: ./run-tests.py -t run_monitor -m mon:36,20,36,0:1,20,1,0 In such example we will get one PCAP for 36/20 and 1/20. After execution, PCAP file is in the log directory, e.g.: ./logs/2019_11_11_13_36_24/run_monitor_mon_wlp3s0_wlp5s0.pcap Signed-off-by: Janusz Dziedzic <janusz.dziedzic@gmail.com>
This commit is contained in:
parent
c203897a88
commit
48e4680dae
1 changed files with 52 additions and 0 deletions
52
tests/remote/test_monitor.py
Normal file
52
tests/remote/test_monitor.py
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
# Monitor support
|
||||||
|
#
|
||||||
|
# This software may be distributed under the terms of the BSD license.
|
||||||
|
# See README for more details.
|
||||||
|
|
||||||
|
import remotehost
|
||||||
|
import config
|
||||||
|
import rutils
|
||||||
|
import monitor
|
||||||
|
import time
|
||||||
|
import os
|
||||||
|
|
||||||
|
import logging
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
def run_monitor(devices, setup_params, refs, duts, monitors, seconds=None):
|
||||||
|
try:
|
||||||
|
air_monitor = []
|
||||||
|
output = "\n\tPCAP files:\n"
|
||||||
|
# setup log dir
|
||||||
|
local_log_dir = setup_params['local_log_dir']
|
||||||
|
|
||||||
|
# add/run monitors if requested
|
||||||
|
air_monitors = monitor.create(devices, setup_params, refs, duts,
|
||||||
|
monitors)
|
||||||
|
for air_monitor in air_monitors:
|
||||||
|
monitor.setup(air_monitor)
|
||||||
|
monitor.run(air_monitor, setup_params)
|
||||||
|
logger.warning(air_monitor.name + " - monitor started ...")
|
||||||
|
|
||||||
|
if seconds != None:
|
||||||
|
time.sleep(int(seconds))
|
||||||
|
else:
|
||||||
|
input("\tPress Enter to end capturing...")
|
||||||
|
|
||||||
|
# destroy monitor / get pcap
|
||||||
|
monitor.destroy(devices, air_monitors)
|
||||||
|
for air_monitor in air_monitors:
|
||||||
|
for log in air_monitor.logs:
|
||||||
|
head, tail = os.path.split(log)
|
||||||
|
output = output + "\t" + local_log_dir + "/" + tail + "\n"
|
||||||
|
air_monitor.get_logs(local_log_dir)
|
||||||
|
return output
|
||||||
|
except:
|
||||||
|
for air_monitor in air_monitors:
|
||||||
|
monitor.destroy(devices, air_monitors)
|
||||||
|
air_monitor.get_logs(local_log_dir)
|
||||||
|
raise
|
||||||
|
|
||||||
|
def test_run_monitor(devices, setup_params, refs, duts, monitors):
|
||||||
|
"""TC run standalone monitor"""
|
||||||
|
return run_monitor(devices, setup_params, refs, duts, monitors)
|
Loading…
Reference in a new issue