提交 170b8ffa 编写于 作者: B Brenda J. Butler 提交者: 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: NBrenda J. Butler <bjb@mojatatu.com>
Acked-by: NLucas Bates <lucasb@mojatatu.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 6c26c3fb
...@@ -179,15 +179,20 @@ def has_blank_ids(idlist): ...@@ -179,15 +179,20 @@ 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.
""" """
with open(filename) as test_data: try:
testlist = json.load(test_data, object_pairs_hook=OrderedDict) with open(filename) as test_data:
idlist = get_id_list(testlist) testlist = json.load(test_data, object_pairs_hook=OrderedDict)
if (has_blank_ids(idlist)): except json.JSONDecodeError as jde:
for k in testlist: print('IGNORING test case file {}\n\tBECAUSE: {}'.format(filename, jde))
k['filename'] = filename testlist = list()
else:
idlist = get_id_list(testlist)
if (has_blank_ids(idlist)):
for k in testlist:
k['filename'] = filename
return testlist return testlist
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册