From patchwork Wed Jun 21 14:14:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 9801939 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 330E460329 for ; Wed, 21 Jun 2017 14:16:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23D2D269A3 for ; Wed, 21 Jun 2017 14:16:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 186EB28389; Wed, 21 Jun 2017 14:16:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B3B38284FF for ; Wed, 21 Jun 2017 14:16:36 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNgOp-0004x4-GI; Wed, 21 Jun 2017 14:14:27 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNgOo-0004vn-6u for xen-devel@lists.xenproject.org; Wed, 21 Jun 2017 14:14:26 +0000 Received: from [85.158.143.35] by server-6.bemta-6.messagelabs.com id 8A/B7-03920-14F7A495; Wed, 21 Jun 2017 14:14:25 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrPLMWRWlGSWpSXmKPExsXitHSDva5jvVe kwbfzjBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bmq1eYC7YLV1y+9J+pgfEGXxcjJ4eEgL/E z7ONzCA2m4CuRNOWv2xdjBwcIgIqErf3GoCYzAKhEjteWIKYwgK+ErfanUGKWQRUJU5ffcoIY vMKeElM+nmaFWKgnMT54z+ZQco5geKLH/mDmEICnhLzT/lBmGoSc9fHQzQKSpyc+YQFxGYWkJ A4+OIF8wRG3llIUrOQpBYwMq1i1ChOLSpLLdI1tNRLKspMzyjJTczM0TU0MNPLTS0uTkxPzUl MKtZLzs/dxAgMGAYg2MH4Y1nAIUZJDiYlUd5yb69IIb6k/JTKjMTijPii0pzU4kOMMhwcShK8 enVAOcGi1PTUirTMHGDowqQlOHiURHjXlACleYsLEnOLM9MhUqcYFaXEeV1B+gRAEhmleXBts Hi5xCgrJczLCHSIEE9BalFuZgmq/CtGcQ5GJWHegzVAU3gy80rgpr8CWswEtPjFEQ+QxSWJCC mpBsYS/lVJnGe/5rtYVk9aO/9W+Ppz384dEgnxmPkg8r3g/XWqT3WC2t/x7GMKFDu48vpr2xS +z6+N1sgorekI1T//WkfLlYlRdk9nW8ox6xPWj059NJba9sPJQH/Z00lxTv++dv46I7Xr1u+V /tayN3WamdXkWtw/P9jCFcyzQtVF5mxd+bzTR3qUWIozEg21mIuKEwEWN0T1kgIAAA== X-Env-Sender: prvs=33896ecda=Ian.Jackson@citrix.com X-Msg-Ref: server-7.tower-21.messagelabs.com!1498054457!75035220!4 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 51367 invoked from network); 21 Jun 2017 14:14:24 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-7.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 21 Jun 2017 14:14:24 -0000 X-IronPort-AV: E=Sophos;i="5.39,369,1493683200"; d="scan'208";a="437315138" From: Ian Jackson To: Date: Wed, 21 Jun 2017 15:14:03 +0100 Message-ID: <1498054447-11281-12-git-send-email-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1498054447-11281-1-git-send-email-ian.jackson@eu.citrix.com> References: <1498054447-11281-1-git-send-email-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Cc: Ian Jackson Subject: [Xen-devel] [OSSTEST PATCH 11/15] sg-run-job: Make catching-otherwise honour $ok X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This is more regular and abolishes a number of explicit $ok tests in run-job. Of the call sites: * "catching-otherwise blocked check-not-blocked" near the top of run-job is soon after $ok is set, so NFC. * The other call sites in run-job all test $ok explicitly, so NFC. * The one call site outside run-job (in examine-host-examine) contains only calls to run-ts, and to examine-host-install-* which itself only contains similar calls. These all therefore honour $ok already. So NFC. While we are here: * Add a doc comment. * Do some slight whitespace fixups. Overall, no functional change. Signed-off-by: Ian Jackson --- sg-run-job | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/sg-run-job b/sg-run-job index 66c2c19..654ba83 100755 --- a/sg-run-job +++ b/sg-run-job @@ -62,7 +62,7 @@ proc run-job {job} { } set nested_layers_hosts {} - catching-otherwise blocked check-not-blocked + catching-otherwise blocked check-not-blocked if {!$ok} return if {[llength $need_xen_hosts]} { @@ -73,19 +73,18 @@ proc run-job {job} { if {$ok} { setstatus running } - if {$ok && ![catch { info args prep-job/$jobinfo(recipe) }]} \ - { catching-otherwise fail prep-job/$jobinfo(recipe) } + if {![catch { info args prep-job/$jobinfo(recipe) }]} \ + { catching-otherwise fail prep-job/$jobinfo(recipe) } if {$ok} { set syslog [spawn-ts broken = | ts-syslog-server] } - if {$ok && $need_build_host} \ - { catching-otherwise broken prepare-build-host } + if {$need_build_host} { catching-otherwise broken prepare-build-host } per-host-ts broken host-install/@(*) ts-host-install-twice per-host-prep - if {$ok} { catching-otherwise fail run-job/$jobinfo(recipe) } + catching-otherwise fail run-job/$jobinfo(recipe) while 1 { per-host-finish @@ -126,8 +125,15 @@ proc run-job {job} { } proc catching-otherwise {failst script} { + # Executes $script. + # If job is already a failure (ie not $ok), skips it (ie does nothing). + # If any Tcl exception is thrown, declares the job a failure. + # (ie sets job status to $failst, and sets anyfailed to 1 and ok to 0) + global anyfailed flight jobinfo ok + if {!$ok} return + if {[catch { uplevel 1 $script } emsg]} {