Commit 170b8ffa authored by Brenda J. Butler's avatar Brenda J. Butler Committed by David S. Miller

tc-testing: better test case file error reporting

tdc.py reads a bunch of test cases in json files.  When a json file
cannot be parsed, tdc just exits and does not run any tests.

This patch will cause tdc to print a message with the file name and
line number, then that file will be ignored and the rest of the tests
will be processed.
Signed-off-by: default avatarBrenda J. Butler <bjb@mojatatu.com>
Acked-by: default avatarLucas Bates <lucasb@mojatatu.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6c26c3fb
...@@ -179,11 +179,16 @@ def has_blank_ids(idlist): ...@@ -179,11 +179,16 @@ def has_blank_ids(idlist):
def load_from_file(filename): def load_from_file(filename):
""" """
Open the JSON file containing the test cases and return them as an Open the JSON file containing the test cases and return them
ordered dictionary object. as list of ordered dictionary objects.
""" """
try:
with open(filename) as test_data: with open(filename) as test_data:
testlist = json.load(test_data, object_pairs_hook=OrderedDict) testlist = json.load(test_data, object_pairs_hook=OrderedDict)
except json.JSONDecodeError as jde:
print('IGNORING test case file {}\n\tBECAUSE: {}'.format(filename, jde))
testlist = list()
else:
idlist = get_id_list(testlist) idlist = get_id_list(testlist)
if (has_blank_ids(idlist)): if (has_blank_ids(idlist)):
for k in testlist: for k in testlist:
......
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