From patchwork Fri Apr 28 08:24:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9704029 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 8AE98602B7 for ; Fri, 28 Apr 2017 08:25:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7AB8F28602 for ; Fri, 28 Apr 2017 08:25:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6EF9528663; Fri, 28 Apr 2017 08:25:02 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 11DE528602 for ; Fri, 28 Apr 2017 08:25:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1034814AbdD1IZB (ORCPT ); Fri, 28 Apr 2017 04:25:01 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:33143 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1034792AbdD1IYr (ORCPT ); Fri, 28 Apr 2017 04:24:47 -0400 Received: by mail-wm0-f65.google.com with SMTP id y10so9444869wmh.0; Fri, 28 Apr 2017 01:24:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cMCeE2vZWZbPuHgo758Cfz6BG9jMQh2naLjMF6BV7Lc=; b=nWSSLlTARrEoZDPF9NOkoPR7IMSqhY2UIoLTD/4PYpYwoUghxW7zggV6Jl0xdOaR3X GGYzlbu4GqJQb4LUz7bleWLR4nsRXXCuTUdx3GzBIGa9nbBBx+RqtMJMxNUMgt8hXndk 1nEQETyulLbd+qLAhZ+V80dUvDgslDJy0oZ4kwK/kNiJRmkAjdARkjMM3Ccqiy1A8tob uObPQelw8ixO/EhHgBMdfLh3RT/E/j3Z+/qnYsm4nt+aTWH6EiQl7qzsCKFwZGm2aMvp bwgnwrOLJZNsRDnuYlzaDrafknaPfAy4nzuLn0c9sqrnf25B6zDGrj6ENQ/rQ7UDPms/ t5bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cMCeE2vZWZbPuHgo758Cfz6BG9jMQh2naLjMF6BV7Lc=; b=ICLZnETeUKUmau4jF3D/m/splAV842pzH1G8iLx1OV7XoLw6m6cvkKLuMkdi7+uS6C RFRAZXF5ILe0QK9Mn4XPOCT3KpflDu0fRj+d+K8G75AjLs1JnLwD9fFY+8DU5nEhvzFD lYRsUuB/tH1BgoUS2Tds3zMlRcN12Ob19kFk0P5wIDOQPo+RgJ9VQxPbHhbjuefBW0tX YiB97RBQXnJ55DZnDGrOm8DVm6ySieptcACOLT1VgdtXaP8cRCyHi4HyyFnM5w/vhZX6 eOQIppGf4CiZHz2D0E2rQ8jpE8DhiMubge6r6H7d6eECasmCygBpTPNJJP2wgqvll4rk cWFg== X-Gm-Message-State: AN3rC/49EJrPn2+9dDIGwTrNkizh7sRRGkAq6QQbReLUErbBiqLl28/u Tn4MuLFi4H3msg== X-Received: by 10.28.54.151 with SMTP id y23mr5149688wmh.90.1493367885477; Fri, 28 Apr 2017 01:24:45 -0700 (PDT) Received: from amir-VirtualBox.lan (bzq-79-179-55-127.red.bezeqint.net. [79.179.55.127]) by smtp.gmail.com with ESMTPSA id e67sm637836wma.9.2017.04.28.01.24.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Apr 2017 01:24:44 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: Miklos Szeredi , Xiong Zhou , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH v2 4/6] overlay/017: create helpers to record and check inode numbers Date: Fri, 28 Apr 2017 11:24:46 +0300 Message-Id: <1493367888-26550-5-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493367888-26550-1-git-send-email-amir73il@gmail.com> References: <1493367888-26550-1-git-send-email-amir73il@gmail.com> Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use helpers to records and check inode numbers so we can repeat the same test after rename and mount cycle. Suggested-by: Eryu Guan Signed-off-by: Amir Goldstein --- tests/overlay/017 | 57 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/tests/overlay/017 b/tests/overlay/017 index 779907d..3ff429f 100755 --- a/tests/overlay/017 +++ b/tests/overlay/017 @@ -72,32 +72,59 @@ mknod $lowerdir/blkdev b 1 1 mknod $lowerdir/fifo p $here/src/af_unix $lowerdir/socket +FILES="dir file symlink chrdev blkdev fifo socket" + +# Record inode numbers in format +function record_inode_numbers() +{ + dir=$1 + outfile=$2 + + for f in $FILES; do + ls -id $dir/$f + done | \ + while read ino file; do + echo $ino `basename $file` >> $outfile + done +} + +# Check inode numbers match recorder inode numbers +function check_inode_numbers() +{ + dir=$1 + before=$2 + after=$2 + + record_inode_numbers $dir $after + + # Test constant stat(2) st_ino - + # Compare before..after - expect silence + # We use diff -u so out.bad will tell us which stage failed + diff -u $before $after + + # Test constant readdir(3)/getdents(2) d_ino - + # Expect to find file by inode number + cat $before | while read ino f; do + find $dir/ -maxdepth 1 -inum $ino | grep -q $f || \ + echo "$f not found by ino $ino (from $before)" + done +} _scratch_mount rm -f $tmp.* -# Test stable stat(2) st_ino +# Record inode numbers before copy up +record_inode_numbers $SCRATCH_MNT $tmp.before -# Record inode numbers before and after copy up -for f in dir file symlink chrdev blkdev fifo socket; do - ls -id $SCRATCH_MNT/$f >> $tmp.before +for f in $FILES; do # chown -h modifies all those file types chown -h 100 $SCRATCH_MNT/$f - ls -id $SCRATCH_MNT/$f >> $tmp.after -done - -# Test stable readdir(3)/getdents(2) d_ino - -# find by inode number - expect to find file by inode number -cat $tmp.before | while read ino f; do - find $SCRATCH_MNT/ -maxdepth 1 -inum $ino | grep -q $f || \ - echo "$f not found by ino $ino" done -# Compare before..after - expect silence -diff $tmp.before $tmp.after +# Compare inode numbers before/after copy up +check_inode_numbers $SCRATCH_MNT $tmp.before $tmp.after_copyup echo "Silence is golden" status=0