From patchwork Tue Sep 29 18:17:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 523977 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (li376-54.members.linode.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 6EE3214016A for ; Wed, 30 Sep 2015 04:17:29 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 91E3710663; Tue, 29 Sep 2015 11:17:28 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e4.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id 773FD1065F for ; Tue, 29 Sep 2015 11:17:27 -0700 (PDT) Received: from bar5.cudamail.com (unknown [192.168.21.12]) by mx1e4.cudamail.com (Postfix) with ESMTPS id E550B1E0098 for ; Tue, 29 Sep 2015 12:17:26 -0600 (MDT) X-ASG-Debug-ID: 1443550646-09eadd11e06ba370001-byXFYA Received: from mx1-pf1.cudamail.com ([192.168.24.1]) by bar5.cudamail.com with ESMTP id 8hkwNmECBEnouhgf (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 29 Sep 2015 12:17:26 -0600 (MDT) X-Barracuda-Envelope-From: blp@nicira.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.1 Received: from unknown (HELO mail-pa0-f49.google.com) (209.85.220.49) by mx1-pf1.cudamail.com with ESMTPS (RC4-SHA encrypted); 29 Sep 2015 18:17:26 -0000 Received-SPF: unknown (mx1-pf1.cudamail.com: Multiple SPF records returned) X-Barracuda-RBL-Trusted-Forwarder: 209.85.220.49 Received: by pacfv12 with SMTP id fv12so13251187pac.2 for ; Tue, 29 Sep 2015 11:17:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=OiVCfIiJ83BPwxzAyhy5ZyMlO4l0LkS11YffQaGOPPI=; b=Ikv9DvPY75Zba1moFi200S+i8UCF2rPocJbLpcnrHVqs2hc9dUtZwAIRVx7uW33yD2 6DPgE0mNePQABsMYI4S/t9uFPwNo91aG91h9wnAKUngBq6dKd9+PpX3Fkuve7S02zlVu ZVoMD3ZEXgb5n5gcZfq5rwGN9hRHFC1GiZR0klstYL4qZ73sirNAyaw0F1X51fcd9EWi J+tPS8kZ8YGphNwQBbheM2fSp52RdiRKJyWFxPXCSNF1WGUJrhxBwAEuvZFPijO6chDc oM6qkpjIzUTLv7JJ9Kjy3ChXCY4qDSiWcSZSZR7HK1Bzc/ZIJ0b7EJZNluy2jt9ALsVf l5KQ== X-Gm-Message-State: ALoCoQmEz1DiycF7RZ+fnZFGCM4DQRwnWwlZRQ0sGTBx0MK/kYr9YZeMJmsW9jPhkMVVH8Kq89JQ X-Received: by 10.66.164.132 with SMTP id yq4mr34987720pab.8.1443550645495; Tue, 29 Sep 2015 11:17:25 -0700 (PDT) Received: from sigabrt.benpfaff.org ([208.91.2.4]) by smtp.gmail.com with ESMTPSA id vw7sm26982027pab.15.2015.09.29.11.17.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Sep 2015 11:17:23 -0700 (PDT) X-CudaMail-Envelope-Sender: blp@nicira.com X-Barracuda-Apparent-Source-IP: 208.91.2.4 From: Ben Pfaff To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-E1-928077701 X-CudaMail-DTE: 092915 X-CudaMail-Originating-IP: 209.85.220.49 Date: Tue, 29 Sep 2015 11:17:13 -0700 X-ASG-Orig-Subj: [##CM-E1-928077701##][PATCH repost 1/3] tests: Run OVS_WAIT_WHILE, OVS_WAIT_UNTIL in main shell environment. Message-Id: <1443550635-29312-1-git-send-email-blp@nicira.com> X-Mailer: git-send-email 2.1.3 X-Barracuda-Connect: UNKNOWN[192.168.24.1] X-Barracuda-Start-Time: 1443550646 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Cc: Ben Pfaff Subject: [ovs-dev] [PATCH repost 1/3] tests: Run OVS_WAIT_WHILE, OVS_WAIT_UNTIL in main shell environment. X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" AT_CHECK runs its commands in a subshell. That means that (among other effects), any variable assignments within its commands will disappear after the commands' completion. That doesn't matter for any of the existing users, which don't do the sorts of things that affect an outer shell environment anyhow, but an upcoming user wants to make a shell assignment that persists. This commit makes that possible, by using AT_CHECK (actually AT_FAIL_IF but it's moot) only upon failure instead of bracketing the entire test. Signed-off-by: Ben Pfaff Reviewed-by: Simon Horman Acked-by: Flavio Leitner --- tests/ovs-macros.at | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/ovs-macros.at b/tests/ovs-macros.at index 058830b..535d923 100644 --- a/tests/ovs-macros.at +++ b/tests/ovs-macros.at @@ -31,13 +31,14 @@ ovs_wait () { # in the normal case. POSIX doesn't require fractional times to # work, so this might not work. sleep 0.1 - ovs_wait_cond && exit 0 + ovs_wait_cond && return 0 + # Then wait up to 10 seconds. for d in 0 1 2 3 4 5 6 7 8 9; do sleep 1 - ovs_wait_cond && exit 0 + ovs_wait_cond && return 0 done - exit 1 + return 1 } # Prints the integers from $1 to $2, increasing by $3 (default 1) on stdout. @@ -87,11 +88,16 @@ fi ] m4_divert_pop([PREPARE_TESTS]) -m4_define([OVS_WAIT], - [AT_CHECK( - [ovs_wait_cond () { $1 +m4_define([OVS_WAIT], [dnl +ovs_wait_cond () { + $1 } -ovs_wait], [0], [ignore], [ignore], [$2])]) +if ovs_wait; then : +else + $2 + AT_FAIL_IF([:]) +fi +]) m4_define([OVS_WAIT_UNTIL], [OVS_WAIT([$1], [$2])]) m4_define([OVS_WAIT_WHILE], [OVS_WAIT([if $1; then return 1; else return 0; fi], [$2])])