From patchwork Tue Jun 5 08:08:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10447797 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 887C060467 for ; Tue, 5 Jun 2018 08:07:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C99228CB5 for ; Tue, 5 Jun 2018 08:07:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70FB328E22; Tue, 5 Jun 2018 08:07:28 +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=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, 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 052EB28CB5 for ; Tue, 5 Jun 2018 08:07:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751530AbeFEIH1 (ORCPT ); Tue, 5 Jun 2018 04:07:27 -0400 Received: from mail-wr0-f180.google.com ([209.85.128.180]:43063 "EHLO mail-wr0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751507AbeFEIH0 (ORCPT ); Tue, 5 Jun 2018 04:07:26 -0400 Received: by mail-wr0-f180.google.com with SMTP id d2-v6so1305181wrm.10 for ; Tue, 05 Jun 2018 01:07:25 -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; bh=kKpwjoux8n0PBJA8s71nNvK8275JukW74ic4ohfAr08=; b=jcbVaKTHHBoWVWidnMKWRAWUxrzvrJxYLERWGMDwSEdR+dLW1w8mNVFH6RHGTTqqEP 6DcqdLj0xV0a2xRes7ui1KTLlZdqsP4KN1HjfyrIdir6P6uHXmNeV9XzLeDORNWakt/n XYCnF6OeA6B8bDzFHsqEYSFkWG9xTOlytxGybMcmeqA7ndA88Sc3pcDOCDda2nUABynl +rYewg5u6AlMm2Zt38rMLO1hiBx6aM2oLNV2Le0T0q6iLfqBA2SjAZ6X7OaQ+LN8Osgu DUuwHMZqNXTEwaP/Oak/QV84vLVkr5hJhhHXa4zQ4PfftGAwJx0VxBn+/GWKQY0jrnvk 76pA== 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; bh=kKpwjoux8n0PBJA8s71nNvK8275JukW74ic4ohfAr08=; b=EaFyPedtUODkhCKeX09N1uKztPdU9th/I0PIUpV7a/hLvYeUDjuEeiz1WLso9F0de+ GQUzAW+YOGx+xig9aBOGvzIeUk3o/DmLoYEko98W7fr0jUoRYSqzeIzTy9vnltGJzz2a TXXa+LU4SSXpY+2B5MABpBKC/6wsppJ1ep94HHvePO08/1+HkHannMUrDmoC6IiyfCXX 1KJfwUOzp5IvbhTyzfdsaStQKSrBEGEpz9GsNws67m/H4nKd/8ZkJEehUNdUlWZSEbEy +jwYgpWA/ENVFu/QA70BFhvDT0EydebOibtmCQSWL0yqIeTdKRyoqvOV0G2U5Gf+7yfQ /gdw== X-Gm-Message-State: ALKqPwemTJ3+F4lzd1ixzryCmyJ0T0NCuRikaphb1n3hIAenVqv/xfjv c4/6Cee5YbAcUG7HnpnDZUxxdA== X-Google-Smtp-Source: ADUXVKLgFNxrEJD/lbrA395MmktRKO5CX3i0OjMDEc8aItsBPaNFXH+egrGtPQ1Ioks+G81X28Nvbw== X-Received: by 2002:adf:de08:: with SMTP id b8-v6mr18247763wrm.39.1528186045288; Tue, 05 Jun 2018 01:07:25 -0700 (PDT) Received: from amir-VirtualBox.ctera.local (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id u89-v6sm1132199wma.4.2018.06.05.01.07.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Jun 2018 01:07:24 -0700 (PDT) From: Amir Goldstein To: Eryu Guan , Xu Huan Cc: fstests@vger.kernel.org Subject: [PATCH v3] generic/401: fix test in case of no filetype support Date: Tue, 5 Jun 2018 11:08:50 +0300 Message-Id: <1528186130-22854-1-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Xu Huan reported that this test fails on nfs in some setup. Apparently, the assumptions made about xfs/ext* do not hold for nfs. Relax the verification of filetype not supported case to allow either DT_UNKNOWN or actual file type on all files and not only on special dir entires "." and "..". Convert the unknown d_type replacement code from awk to bash so it is a bit more readable and flexible. Reported-by: Xu Huan Signed-off-by: Amir Goldstein Tested-by:Xu Huan --- Xu, Please check if this patch fixes your problem. I prefer to keep the test coverage of unsupported case. I tested with xfs/ext4 with/without filetype support. Thanks, Amir. tests/generic/401 | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/tests/generic/401 b/tests/generic/401 index 74f2bea..34ce76e 100755 --- a/tests/generic/401 +++ b/tests/generic/401 @@ -4,14 +4,13 @@ # Test filetype feature # # This test does NOT require that file system support the d_type feature. -# It verifies that either all file types are reported as DT_UNKNOWN -# or all file types are reported correctly. +# It verifies that file types are reported as either DT_UNKNOWN or as +# the actual file type. For example, special dir entries . and .. MAY be +# reported as DT_UNKNOWN IF filetype feature is disabled (ext4), but MAY +# also be reported as DT_DIR in this case (xfs). # # For fs for which we know how to test the filetype feature (xfs|ext*) # verify getting DT_UNKNOWN IFF feature is disabled. -# Special dir entries . and .. MAY be reported as DT_UNKNOWN IF filetype -# feature is disabled (ext4), but MAY also be reported as DT_DIR in this -# case (xfs). # #----------------------------------------------------------------------- # @@ -73,23 +72,22 @@ mknod $testdir/c c 1 1 mknod $testdir/b b 1 1 mknod $testdir/p p -# Test d_type of . and .. -# it must be DT_DIR on fs with filetype support and it could be -# either DR_DIR or DT_UNKNOWN on fs without filetype support -src/t_dir_type $testdir d | grep -F '.' | sort - -# Test that either all file types are unknown or all are correct -if _supports_filetype $SCRATCH_MNT; then - # print real file types - src/t_dir_type $testdir | grep -vF '.' | sort -else - # print fake dir file type for . and .. if they are DT_UNKNOWN - src/t_dir_type $testdir u | grep -F '.' | \ - awk '{ print $1, "d" }' | sort - # list unknown files and print filename as fake file type - src/t_dir_type $testdir u | grep -vF '.' | \ - awk '{ print $1, $1 }' | sort -fi +# Test d_type of test files - it must be the actual file type on fs +# with filetype support and it could be either the actual file type +# or DT_UNKNOWN on fs without filetype support +ftype= +_supports_filetype $SCRATCH_MNT && ftype=1 +src/t_dir_type $testdir | \ +while read name type; do + if [ "$ftype" != 1 -a "$type" = u ]; then + if [ "$name" = "." -o "$name" = ".." ]; then + type=d + else + type=$name + fi + fi + echo $name $type +done | sort status=0 exit