From patchwork Mon Mar 16 12:27:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 45835 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9AD2D21547 for ; Mon, 16 Mar 2015 12:28:28 +0000 (UTC) Received: by lbvn10 with SMTP id n10sf26360115lbv.1 for ; Mon, 16 Mar 2015 05:28:27 -0700 (PDT) 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=oq7touT929xws9S9nZNVmrGnHjwd4ClLYXerw5sZfsI=; b=a8wBocAcQs2ZqcfGwxLCcaeRkdW8+DMWD0CGhxx+tMi1302WvXpY1bVul0qi0dozcv W0dcNk0rIBw1vG7xukzpPfa+HDX6DeA08+vLOxX5gpuVh2QRcth0C5OAkIwXR0XJ1wen uIDPFI16V6ULakFSug38LIdBrmzApcHu95mE6Eu4aHhHDRc//I9n5ROCeMyZ5dkszh1d ZDCJ8Q50rB4JPTbSnY/Nz7kRHMozCrUL5pSWRhC1cSA0r2SjKMpcTpuBZUiZiB//oqye pHjzdh9AY4CxJh9uFn0GXNrj4IuZQB1ex0u8suP90YdZVMl/er+vc96e257Clj2KYR3E i4yw== X-Gm-Message-State: ALoCoQnEcReRu9fiKNALTxhrmbxyxXOKEO1gWAaFHxsX2iChz3IQVttgFQKtRpqFzXZhIxkqYNry X-Received: by 10.180.150.115 with SMTP id uh19mr6074471wib.7.1426508907526; Mon, 16 Mar 2015 05:28:27 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.10.132 with SMTP id i4ls635194lab.25.gmail; Mon, 16 Mar 2015 05:28:27 -0700 (PDT) X-Received: by 10.112.141.168 with SMTP id rp8mr28633628lbb.46.1426508907221; Mon, 16 Mar 2015 05:28:27 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id zu3si8015745lbb.11.2015.03.16.05.28.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Mar 2015 05:28:27 -0700 (PDT) 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 lagg8 with SMTP id g8so38253317lag.1 for ; Mon, 16 Mar 2015 05:28:27 -0700 (PDT) X-Received: by 10.152.43.51 with SMTP id t19mr54278506lal.73.1426508907138; Mon, 16 Mar 2015 05:28:27 -0700 (PDT) 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 h5csp2547941lbj; Mon, 16 Mar 2015 05:28:26 -0700 (PDT) X-Received: by 10.55.42.37 with SMTP id q37mr106216868qkh.90.1426508905800; Mon, 16 Mar 2015 05:28:25 -0700 (PDT) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id b4si9754872qcq.36.2015.03.16.05.28.24 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 16 Mar 2015 05:28:25 -0700 (PDT) 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 1YXU85-0003e8-N5; Mon, 16 Mar 2015 12:28:21 +0000 Received: from mail-wg0-f53.google.com ([74.125.82.53]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YXU80-0003e3-4m for lng-odp@lists.linaro.org; Mon, 16 Mar 2015 12:28:16 +0000 Received: by wgdm6 with SMTP id m6so38559840wgd.2 for ; Mon, 16 Mar 2015 05:28:10 -0700 (PDT) X-Received: by 10.194.210.103 with SMTP id mt7mr124144133wjc.103.1426508890683; Mon, 16 Mar 2015 05:28:10 -0700 (PDT) Received: from e106441.cambridge.arm.com ([2001:41d0:a:3cb4::1]) by mx.google.com with ESMTPSA id lj13sm15166209wic.9.2015.03.16.05.28.09 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Mar 2015 05:28:09 -0700 (PDT) From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Mon, 16 Mar 2015 12:27:43 +0000 Message-Id: <1426508863-20529-1-git-send-email-stuart.haslam@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [PATCHv2] 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 --- Changes in v2; rebased and fixed non-POSIX shell arithmetic expansion 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 6177caa..204b440 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=`expr $cnt + 1` + done + + return 1 +} + setup_env1() { ip link show $IF0 2> /dev/null @@ -61,8 +83,14 @@ setup_env1() ifconfig $IF0 -arp ifconfig $IF1 -arp - # 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()