Skip to content

Commit

Permalink
runtests.py: parse the command line with shelx
Browse files Browse the repository at this point in the history
Signed-off-by: Yi Sun <yi.sun@intelcom>
  • Loading branch information
Yi Sun committed Jul 4, 2024
1 parent 0f61ed5 commit 11fd97e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 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 @@ -67,13 +68,20 @@ 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:])
parts = parse_cmd_str(line.strip())
runnable = Runnable("exec-test", *parts)
tests.append(runnable)

return tests

def parse_cmd_str(cmd):
lexer = shlex.shlex(cmd, posix=True)
lexer.whitespace_split = True
lexer.whitespace = ' '
return list(lexer)

def main():
# Get the absolute directory of the tests file.
tests_abs = os.path.abspath(args.tests)
Expand Down

0 comments on commit 11fd97e

Please sign in to comment.