From patchwork Wed Mar 2 01:58:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bird, Tim" X-Patchwork-Id: 8476041 Return-Path: X-Original-To: patchwork-ltsi-dev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D6FCD9F2F0 for ; Wed, 2 Mar 2016 01:59:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1A576202B8 for ; Wed, 2 Mar 2016 01:59:01 +0000 (UTC) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3BE3620377 for ; Wed, 2 Mar 2016 01:59:00 +0000 (UTC) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 0897EDBB; Wed, 2 Mar 2016 01:59:00 +0000 (UTC) X-Original-To: ltsi-dev@lists.linuxfoundation.org Delivered-To: ltsi-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 0ED79DBA for ; Wed, 2 Mar 2016 01:58:59 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from SELDSEGREL01.sonyericsson.com (seldsegrel01.sonyericsson.com [37.139.156.29]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 498E5170 for ; Wed, 2 Mar 2016 01:58:57 +0000 (UTC) To: "ltsi-dev@lists.linuxfoundation.org" From: Tim Bird Message-ID: <56D648D9.3050800@sonymobile.com> Date: Tue, 1 Mar 2016 17:58:49 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org Cc: Dmitry Cherkasov Subject: [LTSI-dev] [PATCH] Add filename output in case of json parse errors X-BeenThere: ltsi-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: "A list to discuss patches, development, and other things related to the LTSI project" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ltsi-dev-bounces@lists.linuxfoundation.org Errors-To: ltsi-dev-bounces@lists.linuxfoundation.org X-Virus-Scanned: ClamAV using ClamSMTP Put the json.load() routines in a try/except clause, and print out the file that failed to parse correctly. I found this handy for debugging json errors in the test specs and test plan files. --- engine/scripts/ovgen/ovgen.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/engine/scripts/ovgen/ovgen.py b/engine/scripts/ovgen/ovgen.py index 7f14795..37a73b8 100755 --- a/engine/scripts/ovgen/ovgen.py +++ b/engine/scripts/ovgen/ovgen.py @@ -475,7 +475,13 @@ def parseGenTestPlan(tpFilePath, fout, fname, specs): with open(tpFilePath) as f: debug_print("parsing `%s' TP" % (tpFilePath), 1) - jd = json.load(f) + try: + jd = json.load(f) + except: + print "Error parsing testplan file %s" % tpFilePath + f.seek(0) + js = json.load(f) + name = jd["testPlanName"] fout.write("#testplan: %s\n" % (name)) for t in jd["tests"]: @@ -504,7 +510,13 @@ def parseSpec(specFileName): debug_print("Parsing %s spec file" % (specFileName)) with open(specFileName) as f: - jd = json.load(f) + try: + jd = json.load(f) + except: + print "Error parsing spec file %s" % specFileName + f.seek(0) + jd = json.load(f) + name = jd["testName"] debug_print("parsing `%s' spec" % (name), 1)