Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2816146yba; Mon, 6 May 2019 12:00:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqy8+TxgeXErjuc4x8wtSqhDMu+s7yiIGyW9bddwAeV6EygLsC2E9yeHnype78S6oZGtvmSH X-Received: by 2002:a17:902:7b97:: with SMTP id w23mr35127870pll.335.1557169226946; Mon, 06 May 2019 12:00:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557169226; cv=none; d=google.com; s=arc-20160816; b=I9+GsajR52Q/+vS8vBXWYr/URhc3PyDh3t0slMLpVVnE+P6csloogD/hBpwiu2yws4 8WloCGdDxHN/rJuQCwF2eqQ+TMMa+PF7oOi2KyaFnATErO2Z1SFr7uDx+FPgbgyxQk0Z 31uOp8K1jCp9goT3pep7N65AChK9/toog+fQEcksTgwG+uA5ZNlSBx0CeIjHNvhI3qdj D/W1kiYLqePeOAl5jt8QEbsUJC9l89aY8jkgN4y+o44O0XPOe53XwVX5H8FRGwZXib3y 6SJdWVujIxVefl7LG6aElo9ygBMHi4J9bf3gGE/kEQFdLStB/Mmq9/u1ofjhLk5aq75k WWMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Kk5u9hJUFXjnYAyP8JZ5V0H6+XQbiy+LxhZCo8HTFh0=; b=TUHsRpIrrQsPl3SNRzGwXYhrcG+MORLh9lA0oS8QmwaeJMweR0ibPeTw6clW+uIfeE 4t7vC/JpGR+46xaa37ra7Qkei+k+e3spbIkoJh2/sDIDAfhtaZjHGRfzULRTnSRj5jsC AuIcXbT4/a286zviRT1e2eeVzaWtwdsdQCwVBCtWy9g5jb8f2AAZX8ltfNtTyTYnbH2X AZMAcscakKwQov6hiE25AKZVYniAjLUHnidTYX5lMDk+dCDyvcQtoW9bE4eXUtpvK++G D2fC0a0pWCxAS2dO+Lw+GaKFVkwrSxCkAf4WXfmx4BTGtbrZozj3tZUIoMjOSopp0u6J 7aug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f193si8214547pgc.144.2019.05.06.12.00.04; Mon, 06 May 2019 12:00:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726413AbfEFS76 (ORCPT + 99 others); Mon, 6 May 2019 14:59:58 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:33078 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726145AbfEFS76 (ORCPT ); Mon, 6 May 2019 14:59:58 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id CAAC32735FD From: Gabriel Krisman Bertazi To: fstests@vger.kernel.org Cc: tytso@mit.edu, linux-ext4@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH xfstests 1/2] common/casefold: Add infrastructure to test filename casefold feature Date: Mon, 6 May 2019 14:59:40 -0400 Message-Id: <20190506185941.10570-1-krisman@collabora.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Add a set of basic helper functions to simplify the testing of casefolding capable filesystems. Signed-off-by: Gabriel Krisman Bertazi --- common/casefold | 74 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 common/casefold diff --git a/common/casefold b/common/casefold new file mode 100644 index 000000000000..c2436179265e --- /dev/null +++ b/common/casefold @@ -0,0 +1,74 @@ +#----------------------------------------------------------------------- +# +# Common functions for testing filename casefold feature +# +#----------------------------------------------------------------------- +# Copyright (c) 2018 Collabora, Ltd. All Rights Reserved. +# +# Author: Gabriel Krisman Bertazi +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- + +_has_casefold_feature() { + dumpe2fs -h "$1" 2>&1 | grep -Gq "Filesystem features.*casefold" +} + +_require_test_casefold_feature () { + _has_casefold_feature $TEST_DEV || \ + _notrun "Feature casefold required for this test" +} +_require_scratch_casefold_feature () { + _has_casefold_feature $SCRATCH_DEV || \ + _notrun "Feature casefold required for this test" +} +_exclude_test_casefold_feature () { + _has_casefold_feature $TEST_DEV && \ + _notrun "Feature casefold forbidden for this test" +} +_exclude_scratch_casefold_feature () { + _has_casefold_feature $SCRATCH_DEV && \ + _notrun "Feature casefold forbidden for this test" +} + +_casefold_check_exact_name () { + # To get the exact disk name, we need some method that does a + # getdents() on the parent directory, such that we don't get + # normalized/casefolded results. 'Find' works ok. + basedir=$1 + exact_name=$2 + find ${basedir} | grep -q ${exact_name} +} + +_try_set_casefold_attr () { + chattr +F "${1}" &>/dev/null +} + +_try_unset_casefold_attr () { + chattr -F "${1}" &>/dev/null +} + +_set_casefold_attr () { + _try_set_casefold_attr "${1}" || \ + _fail "Unable to set casefold attribute on ${1}" +} + +_unset_casefold_attr () { + _try_unset_casefold_attr "${1}" || \ + _fail "Unable to unset casefold attribute on ${1}" +} + +_is_casefolded_dir () { + lsattr -ld "${1}" | grep -q "Casefold" +} -- 2.20.1