summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorBrenda J. Butler <bjb@mojatatu.com>2017-10-31 14:29:03 -0400
committerDavid S. Miller <davem@davemloft.net>2017-11-01 11:04:47 +0900
commit170b8ffa71412eeacb20589b807f4bc75a61e507 (patch)
tree94cb539f6536fae1a08fccfc9e4a4c3d8fd4e3bf /tools
parent6c26c3fbc3295ce71f5e03caccc9eeb7369123ca (diff)
downloadlinux-170b8ffa71412eeacb20589b807f4bc75a61e507.tar.gz
linux-170b8ffa71412eeacb20589b807f4bc75a61e507.tar.bz2
linux-170b8ffa71412eeacb20589b807f4bc75a61e507.zip
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: Brenda J. Butler <bjb@mojatatu.com> Acked-by: Lucas Bates <lucasb@mojatatu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/testing/selftests/tc-testing/tdc.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/tools/testing/selftests/tc-testing/tdc.py b/tools/testing/selftests/tc-testing/tdc.py
index 5508730ee1ea..a674fe9a7f1e 100755
--- a/tools/testing/selftests/tc-testing/tdc.py
+++ b/tools/testing/selftests/tc-testing/tdc.py
@@ -179,15 +179,20 @@ def has_blank_ids(idlist):
def load_from_file(filename):
"""
- Open the JSON file containing the test cases and return them as an
- ordered dictionary object.
- """
- with open(filename) as test_data:
- testlist = json.load(test_data, object_pairs_hook=OrderedDict)
- idlist = get_id_list(testlist)
- if (has_blank_ids(idlist)):
- for k in testlist:
- k['filename'] = filename
+ Open the JSON file containing the test cases and return them
+ as list of ordered dictionary objects.
+ """
+ try:
+ with open(filename) as test_data:
+ 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)
+ if (has_blank_ids(idlist)):
+ for k in testlist:
+ k['filename'] = filename
return testlist