[testsuite] Add debug mode & search directory to runner

This commit is contained in:
Dan Čermák
2018-04-21 00:53:15 +02:00
parent 4656af73bc
commit c40c90141f
3 changed files with 57 additions and 1 deletions
+30
View File
@@ -80,6 +80,20 @@ class CasePreservingConfigParser(configparser.ConfigParser):
_parameters = {}
#: setting whether debug mode is enabled or not
_debug_mode = False
def set_debug_mode(debug):
""" Enable or disable debug mode
In debug mode the test suite will print out all commands that it runs, the
expected output and the actually obtained output
"""
global _debug_mode
_debug_mode = debug
def configure_suite(config_file):
"""
Populates a global datastructure with the parameters from the suite's
@@ -432,6 +446,14 @@ def test_run(self):
retval = int(retval)
timeout = {"flag": False}
if _debug_mode:
print(
'', "="*80, "will run: " + command, "expected stdout:", stdout,
"expected stderr:", stderr,
"expected return value: {:d}".format(retval),
sep='\n'
)
proc = subprocess.Popen(
_cmd_splitter(command),
stdout=subprocess.PIPE,
@@ -453,6 +475,14 @@ def test_run(self):
processed_stdout = _process_output_post(got_stdout.decode('utf-8'))
processed_stderr = _process_output_post(got_stderr.decode('utf-8'))
if _debug_mode:
print(
"got stdout:", processed_stdout, "got stderr:",
processed_stderr, "got return value: {:d}"
.format(proc.returncode),
sep='\n'
)
self.assertFalse(timeout["flag"] and "Timeout reached")
self.compare_stdout(i, command, processed_stdout, stdout)
self.compare_stderr(i, command, processed_stderr, stderr)