Skip to content

Commit 8e64acf

Browse files
committed
opencsd: tests: Update test script
In the python test script ensure that only options after '--' are passed through to the trc_pkt_lister program. Unknown options before this will now result in a error and the script will fail Signed-off-by: Mike Leach <mike.leach@arm.com>
1 parent 62d66fe commit 8e64acf

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

decoder/docs/test_progs.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,18 @@ __Runner options__
9494
- `--memacc-req-trace` : set `OPENCSD_MEMACC_REQ_TRACE=1` for all test processes started by the script.
9595
- `--diff-only` : run only the result comparison step without running any tests.
9696

97-
Any additional arguments after the script options are passed through to
98-
`trc_pkt_lister`. Use `--` to separate runner options from the packet lister
99-
arguments when needed.
97+
Any additional arguments for `trc_pkt_lister` must appear after `--`. The
98+
Python runner validates all options before `--`, and any unknown option there
99+
is treated as an error instead of being passed through.
100100

101101
Example:
102102

103103
`python .\decoder\tests\run_pkt_decode_tests.py --suite ete -- --stats`
104104

105+
This will fail because `--stats` is before `--`:
106+
107+
`python .\decoder\tests\run_pkt_decode_tests.py --suite ete --stats`
108+
105109
__Result comparison__
106110

107111
The script can compare the results created by the current run against a

decoder/tests/run_pkt_decode_tests.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,7 @@ def run_ete_suite(
908908
def parse_args(argv: Sequence[str]) -> tuple[argparse.Namespace, list[str]]:
909909
parser = argparse.ArgumentParser(
910910
description="Run OpenCSD packet decode regression tests on Linux, macOS, or Windows.",
911+
epilog="Pass additional trc_pkt_lister arguments only after '--'.",
911912
)
912913
parser.add_argument(
913914
"--suite",
@@ -977,9 +978,14 @@ def parse_args(argv: Sequence[str]) -> tuple[argparse.Namespace, list[str]]:
977978
help="Set OPENCSD_MEMACC_REQ_TRACE=1 for every test process started by this runner.",
978979
)
979980

980-
namespace, passthrough = parser.parse_known_args(argv)
981-
if passthrough and passthrough[0] == "--":
982-
passthrough = passthrough[1:]
981+
passthrough: list[str] = []
982+
parseable_argv = list(argv)
983+
if "--" in parseable_argv:
984+
separator_index = parseable_argv.index("--")
985+
passthrough = parseable_argv[separator_index + 1 :]
986+
parseable_argv = parseable_argv[:separator_index]
987+
988+
namespace = parser.parse_args(parseable_argv)
983989

984990
diff_results_suffixes = namespace.diff_results_suffix or []
985991
if namespace.diff_previous and diff_results_suffixes:

0 commit comments

Comments
 (0)