From b830a59fc8c05a92b874252cb8f6cb96ded46bb5 Mon Sep 17 00:00:00 2001 From: Martin Klozik Date: Mon, 11 Dec 2017 13:37:40 +0000 Subject: teststeps: Improvements of step driven TC This patch adds support of access to VMs deployed automatically by deployment scenario (e.g. pvp, pvvp4, etc.). It also modifies filter for checking output of executed commands to correctly handle different end of line encodings (i.e. \n vs. \n\r). JIRA: VSPERF-539 Change-Id: Ifc796d992b90e316bad5853aaefce79e439e294d Signed-off-by: Martin Klozik Reviewed-by: Al Morton Reviewed-by: Christian Trautman Reviewed-by: Sridhar Rao Reviewed-by: Trevor Cooper --- tools/functions.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'tools') diff --git a/tools/functions.py b/tools/functions.py index c0d1e5f7..d35f1f84 100644 --- a/tools/functions.py +++ b/tools/functions.py @@ -190,17 +190,15 @@ def filter_output(output, regex): """ result = [] if isinstance(output, str): - for line in output.split('\n'): + for line in output.splitlines(): result += re.findall(regex, line) - return result - elif isinstance(output, list) or isinstance(output, tuple): - tmp_res = [] + elif isinstance(output, (list, tuple)): for item in output: - tmp_res.append(filter_output(item, regex)) - return tmp_res + result.append(filter_output(item, regex)) else: raise RuntimeError('Only strings and lists are supported by filter_output(), ' 'but output has type {}'.format(type(output))) + return result def format_description(desc, length): """ Split description into multiple lines based on given line length. -- cgit 1.2.3-korg