3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-21 22:09:23 +01:00

test-runner: Fix parsing for some arguments

Currently the parameter values reach run-tests by first being parsed by
runner.py's RunnerArgParser, then the resulting object members being
encoded as a commandline string, then as environment variables, then the
environment being converted to a python string list and passed to
RunnerCoreArgParser again.  Where argument names (like --sub-tests) had
dashes, the object members had underscores (.sub_tests), this wasn't
taken into account when building the python string list from environment
variables so convert all underscores to dashes and hope that all the
names match now.

Additionally some arguments used nargs='1' or nargs='*' which resulted
in their python values becoming lists.  They were converted back to command
line arguments such as: --sub_tests ['static_test.py'], and when parsed
by RunnerCoreArgParser again, the values ended up being lists of lists.
In all three cases it seems the actual user of the parsed value actually
expects a single string with comma-separated substrings in it so just drop
the nargs= uses.
This commit is contained in:
Andrew Zaborowski 2022-06-16 02:02:21 +02:00 committed by Denis Kenzior
parent 8237264848
commit 00e41eb0ff

View File

@ -108,7 +108,7 @@ class RunnerCoreArgParse(ArgumentParser):
help='Enables iwmon output to file')
self.add_argument('--sub-tests', '-S',
metavar='<subtests>',
type=str, nargs=1, help='List of subtests to run',
type=str, help='List of subtests to run',
default=None, dest='sub_tests')
self.add_argument('--result', '-e',
type=os.path.abspath,
@ -131,8 +131,6 @@ class RunnerCoreArgParse(ArgumentParser):
auto_unit_group.add_argument('--unit-tests', '-U',
metavar='<tests>',
type=str,
nargs='?',
const='*',
help='List of unit tests to run',
dest='unit_tests')
@ -141,7 +139,6 @@ class RunnerCoreArgParse(ArgumentParser):
valgrind_gdb_group.add_argument('--gdb', '-g',
metavar='<exec>',
type=str,
nargs=1,
help='Run gdb on specified executable',
dest='gdb')
valgrind_gdb_group.add_argument('--valgrind', '-V',
@ -156,7 +153,7 @@ class RunnerCoreArgParse(ArgumentParser):
options = []
for k, v in os.environ.items():
options.append('--' + k)
options.append('--' + k.replace('_', '-'))
options.append(v)
return self.parse_known_args(args=options, namespace=RunnerNamespace())[0]