From 58a77d2a33fd36ae3166534a7ff968dce9aa28d8 Mon Sep 17 00:00:00 2001 From: Vincent Fu Date: Tue, 26 May 2020 16:54:44 -0400 Subject: [PATCH] t/run-fio-tests: pass-through arguments to test scripts Add an option to pass-through arguments to specified test scripts. This can be used to alter the behavior of tests on different platforms. Signed-off-by: Vincent Fu --- t/run-fio-tests.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/t/run-fio-tests.py b/t/run-fio-tests.py index 763e0103..e7063d3e 100755 --- a/t/run-fio-tests.py +++ b/t/run-fio-tests.py @@ -122,10 +122,7 @@ class FioExeTest(FioTest): def run(self): """Execute the binary or script described by this instance.""" - if self.parameters: - command = [self.exe_path] + self.parameters - else: - command = [self.exe_path] + command = [self.exe_path] + self.parameters command_file = open(self.command_file, "w+") command_file.write("%s\n" % command) command_file.close() @@ -797,6 +794,8 @@ def parse_args(): help='provide debug output') parser.add_argument('-k', '--skip-req', action='store_true', help='skip requirements checking') + parser.add_argument('-p', '--pass-through', action='append', + help='pass-through an argument to an executable test') args = parser.parse_args() return args @@ -811,6 +810,17 @@ def main(): else: logging.basicConfig(level=logging.INFO) + pass_through = {} + if args.pass_through: + for arg in args.pass_through: + if not ':' in arg: + print("Invalid --pass-through argument '%s'" % arg) + print("Syntax for --pass-through is TESTNUMBER:ARGUMENT") + return + split = arg.split(":",1) + pass_through[int(split[0])] = split[1] + logging.debug("Pass-through arguments: %s" % pass_through) + if args.fio_root: fio_root = args.fio_root else: @@ -874,13 +884,12 @@ def main(): if config['parameters']: parameters = [p.format(fio_path=fio_path) for p in config['parameters']] else: - parameters = None + parameters = [] if Path(exe_path).suffix == '.py' and platform.system() == "Windows": - if parameters: - parameters.insert(0, exe_path) - else: - parameters = [exe_path] + parameters.insert(0, exe_path) exe_path = "python.exe" + if config['test_id'] in pass_through: + parameters += pass_through[config['test_id']].split() test = config['test_class'](exe_path, parameters, config['success']) else: -- 2.25.1