Skip to content

Commit

Permalink
runtests.py: correctly parse the command line without being affected …
Browse files Browse the repository at this point in the history
…by quotes and so on

Reported-by: Haoliang Zhu <[email protected]>
Co-developed-by: Yi Sun <[email protected]>
Signed-off-by: Pengfei Xu <[email protected]>
  • Loading branch information
xupengfe committed Jul 4, 2024
1 parent c4f27dd commit fd9ca3a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions BM/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -59,6 +60,14 @@ def dependency_check(ftests):
except subprocess.CalledProcessError:
print(f"Warning: {reason_info}")

def parse_cmd_line(cmd: str) -> list[str]:
cmd_str =shlex.split(cmd)
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 = []
Expand All @@ -67,10 +76,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

Expand Down

0 comments on commit fd9ca3a

Please sign in to comment.