[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190506185941.10570-1-krisman@collabora.com>
Date: Mon, 6 May 2019 14:59:40 -0400
From: Gabriel Krisman Bertazi <krisman@...labora.com>
To: fstests@...r.kernel.org
Cc: tytso@....edu, linux-ext4@...r.kernel.org,
Gabriel Krisman Bertazi <krisman@...labora.com>
Subject: [PATCH xfstests 1/2] common/casefold: Add infrastructure to test filename casefold feature
Add a set of basic helper functions to simplify the testing of
casefolding capable filesystems.
Signed-off-by: Gabriel Krisman Bertazi <krisman@...labora.com>
---
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 <krisman@...labora.com>
+#
+# 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
Powered by blists - more mailing lists