diff --git a/BM/runtests.py b/BM/runtests.py index 5812367f..0c094eae 100755 --- a/BM/runtests.py +++ b/BM/runtests.py @@ -3,6 +3,7 @@ import subprocess import argparse import os +import shlex from avocado.core.job import Job from avocado.core.nrunner.runnable import Runnable from avocado.core.suite import TestSuite @@ -59,6 +60,16 @@ def dependency_check(ftests): except subprocess.CalledProcessError: print(f"Warning: {reason_info}") +def parse_cmd_line(cmd: str) -> list[str]: + cmd_str = shlex.shlex(cmd, posix=True) + cmd_str.whitespace_split = True + cmd_str.whitespace = ' ' + try: + return list(cmd_str) + except Exception as e: + print(f"Error while parsing cmd:{cmd} with err {e}") + return [] + # Read the tests file and create Runnable objects. def create_runnables_from_file(ftests): tests = [] @@ -67,10 +78,10 @@ def create_runnables_from_file(ftests): # Handle empty lines and comments. if not line.strip() or line.startswith('#'): continue + # Split command line parameters. - parts = line.strip().split() - # Create a Runnable object. - runnable = Runnable("exec-test", parts[0], *parts[1:]) + cmd_line = parse_cmd_line(line.strip()) + runnable = Runnable("exec-test", *cmd_line) tests.append(runnable) return tests