From patchwork Thu Mar 5 12:12:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 45454 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 86145204BC for ; Thu, 5 Mar 2015 12:12:56 +0000 (UTC) Received: by lams18 with SMTP id s18sf39179528lam.1 for ; Thu, 05 Mar 2015 04:12:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=9sm0iEBXRxBAx6BR8UujB7LDjP3SFyIdQzzoybala70=; b=cA/lUYYk+tTGPwhvJefNaYVjIqcvWWNV2kaJQXg9jnFUDWRGd7P2vBqfRK8Qm7Vpd3 pSnpMSa0ryex50uj+TuioCaQaYiRY7gwN1uoqabH20zgjm9Elf86bx4PwrOB7u6TTMHE AweLWSshn1Id2RMOfcMBqd8O06ikIUp0VDJwwNkAIwka1XrdH4tHBGzwghySM5disqgi JnffwHqS87deTrfRgKSF7Ui85K6AGbcvT6A09YCZGDSidcvgZ1gFVOtfHKUQPbKAxnvS AZxN7b+6E5KBtos88mR8RvnBa6gNc5PLfL/VM2yeFD6xbivIlppUQnqrpwf37owfZIlS 2Evw== X-Gm-Message-State: ALoCoQm4nlMeXp8NOE08nD3LksetoPaB7d9ctco/KCvr2cWU0S9ed1+CD5oEmszKDlOI2e0AWn5V X-Received: by 10.194.11.70 with SMTP id o6mr1464985wjb.6.1425557575519; Thu, 05 Mar 2015 04:12:55 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.231 with SMTP id bb7ls315343lab.50.gmail; Thu, 05 Mar 2015 04:12:55 -0800 (PST) X-Received: by 10.152.4.136 with SMTP id k8mr7464151lak.103.1425557575346; Thu, 05 Mar 2015 04:12:55 -0800 (PST) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id g2si4314008lag.149.2015.03.05.04.12.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Mar 2015 04:12:55 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by labgf13 with SMTP id gf13so26390023lab.5 for ; Thu, 05 Mar 2015 04:12:55 -0800 (PST) X-Received: by 10.112.64.193 with SMTP id q1mr7616635lbs.88.1425557574946; Thu, 05 Mar 2015 04:12:54 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp442768lbj; Thu, 5 Mar 2015 04:12:54 -0800 (PST) X-Received: by 10.140.149.23 with SMTP id 23mr12435444qhv.10.1425557573261; Thu, 05 Mar 2015 04:12:53 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id d109si5807722qge.52.2015.03.05.04.12.51 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 05 Mar 2015 04:12:53 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YTUe1-0002hs-Ev; Thu, 05 Mar 2015 12:12:49 +0000 Received: from mail-wi0-f172.google.com ([209.85.212.172]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YTUdw-0002gf-6U for lng-odp@lists.linaro.org; Thu, 05 Mar 2015 12:12:44 +0000 Received: by wiwl15 with SMTP id l15so2402624wiw.1 for ; Thu, 05 Mar 2015 04:12:38 -0800 (PST) X-Received: by 10.194.171.136 with SMTP id au8mr18531177wjc.6.1425557558737; Thu, 05 Mar 2015 04:12:38 -0800 (PST) Received: from e106441.cambridge.arm.com ([2001:41d0:a:3cb4::1]) by mx.google.com with ESMTPSA id dq1sm8172797wib.20.2015.03.05.04.12.37 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Mar 2015 04:12:38 -0800 (PST) From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Thu, 5 Mar 2015 12:12:31 +0000 Message-Id: <1425557551-14684-1-git-send-email-stuart.haslam@linaro.org> X-Mailer: git-send-email 2.1.1 X-Topics: patch Subject: [lng-odp] [PATCH] validation: pktio: prevent race when using veth pair X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: stuart.haslam@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 There's a potential race condition whereby the test case could start running before the virtual ethernet interfaces are fully brought up. So replace the the arbitrary delay with a check for the interface's operational state before kicking off the test. Signed-off-by: Stuart Haslam --- test/validation/odp_pktio_run | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/test/validation/odp_pktio_run b/test/validation/odp_pktio_run index 08288e6..b051be1 100755 --- a/test/validation/odp_pktio_run +++ b/test/validation/odp_pktio_run @@ -34,6 +34,28 @@ IF1=pktio-p1 # exit codes expected by automake for skipped tests TEST_SKIPPED=77 +# wait for a network interface's operational state to be "up" +wait_for_iface_up() +{ + iface=$1 + cnt=0 + + while [ $cnt -lt 50 ]; do + read operstate < /sys/class/net/$iface/operstate + + if [ $? != 0 ]; then + break + elif [ "$operstate" = "up" ]; then + return 0 + fi + + sleep 0.1 + cnt=$[$cnt+1] + done + + return 1 +} + setup_env1() { ip link show $IF0 2> /dev/null @@ -59,8 +81,14 @@ setup_env1() ip link set $IF0 up ip link set $IF1 up - # network needs a little time to come up - sleep 1 + # check that the interface has come up before starting the test + for iface in $IF0 $IF1; do + wait_for_iface_up $iface + if [ $? != 0 ]; then + echo "pktio: interface $iface failed to come up" + exit 1 + fi + done } cleanup_env1()