Commit 7f6661a7 authored by Lucas Bates's avatar Lucas Bates Committed by David S. Miller

tc-testing: fix the -l argument bug in tdc.py

This patch fixes a bug in the tdc script, where executing tdc
with the -l argument would cause the tests to start running
as opposed to listing all the known test cases.
Signed-off-by: default avatarLucas Bates <lucasb@mojatatu.com>
Acked-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cf797ac4
...@@ -49,7 +49,7 @@ def exec_cmd(command, nsonly=True): ...@@ -49,7 +49,7 @@ def exec_cmd(command, nsonly=True):
stderr=subprocess.PIPE) stderr=subprocess.PIPE)
(rawout, serr) = proc.communicate() (rawout, serr) = proc.communicate()
if proc.returncode != 0: if proc.returncode != 0 and len(serr) > 0:
foutput = serr.decode("utf-8") foutput = serr.decode("utf-8")
else: else:
foutput = rawout.decode("utf-8") foutput = rawout.decode("utf-8")
...@@ -203,7 +203,7 @@ def set_args(parser): ...@@ -203,7 +203,7 @@ def set_args(parser):
help='Run tests only from the specified category, or if no category is specified, list known categories.') help='Run tests only from the specified category, or if no category is specified, list known categories.')
parser.add_argument('-f', '--file', type=str, parser.add_argument('-f', '--file', type=str,
help='Run tests from the specified file') help='Run tests from the specified file')
parser.add_argument('-l', '--list', type=str, nargs='?', const="", metavar='CATEGORY', parser.add_argument('-l', '--list', type=str, nargs='?', const="++", metavar='CATEGORY',
help='List all test cases, or those only within the specified category') help='List all test cases, or those only within the specified category')
parser.add_argument('-s', '--show', type=str, nargs=1, metavar='ID', dest='showID', parser.add_argument('-s', '--show', type=str, nargs=1, metavar='ID', dest='showID',
help='Display the test case with specified id') help='Display the test case with specified id')
...@@ -357,10 +357,10 @@ def set_operation_mode(args): ...@@ -357,10 +357,10 @@ def set_operation_mode(args):
testcases = get_categorized_testlist(alltests, ucat) testcases = get_categorized_testlist(alltests, ucat)
if args.list: if args.list:
if (len(args.list) == 0): if (args.list == "++"):
list_test_cases(alltests) list_test_cases(alltests)
exit(0) exit(0)
elif(len(args.list > 0)): elif(len(args.list) > 0):
if (args.list not in ucat): if (args.list not in ucat):
print("Unknown category " + args.list) print("Unknown category " + args.list)
print("Available categories:") print("Available categories:")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment