generic/556: add test case for top-level dir rename
authorEric Biggers <ebiggers@google.com>
Sat, 14 May 2022 18:01:46 +0000 (11:01 -0700)
committerZorro Lang <zlang@kernel.org>
Sat, 21 May 2022 18:51:35 +0000 (02:51 +0800)
Test renaming a casefolded directory located in the top-level directory,
while the cache is cold.  When $MOUNT_OPTIONS contains
test_dummy_encryption, this detects an f2fs bug.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/generic/556

index 1296e241552c45e064e9e003c674ba4254f18f66..404a3243afa5ead3dc8526dc26984b24da644488 100755 (executable)
@@ -353,6 +353,21 @@ test_file_rename()
                echo "Name shouldn't change."
 }
 
+test_toplevel_dir_rename()
+{
+       local dir=${SCRATCH_MNT}/dir_rename
+
+       # With the cache cold, rename a casefolded directory located in the
+       # top-level directory.  If $MOUNT_OPTIONS contains
+       # test_dummy_encryption, this detects the bug that was fixed by
+       # 'f2fs: don't use casefolded comparison for "." and ".."'.
+       mkdir ${dir}
+       _casefold_set_attr ${dir}
+       sync
+       echo 2 > /proc/sys/vm/drop_caches
+       mv ${dir} ${dir}.new
+}
+
 # Test openfd with casefold.
 # 1. Delete a file after gettings its fd.
 # 2. Then create new dir with same name
@@ -491,6 +506,7 @@ test_dir_name_preserve
 test_name_reuse
 test_create_with_same_name
 test_file_rename
+test_toplevel_dir_rename
 test_casefold_openfd
 test_casefold_openfd2
 test_hard_link_lookups