Whamcloud - gitweb
LU-11604 tests: fix ACL-printing tests 24/46024/3
authorAndreas Dilger <adilger@whamcloud.com>
Sat, 8 Jan 2022 01:21:40 +0000 (18:21 -0700)
committerLi Dongyang <dongyangli@ddn.com>
Mon, 24 Jan 2022 22:36:55 +0000 (22:36 +0000)
Fix the ACL-printing tests to be more flexible for different systems.
If the MKFS_DIR is on tmpfs, it will not list "system.posix_acl*"
xattrs, so they will not be copied.  Create this on a real filesystem
or skip the test if that doesn't work.

Filter out the security.selinux xattr if it is printed, since this
depends on the selinux configuration of the host system.  However,
this also spills xattrs for "acl_dir/file" into an external xattr
block, and causes the test to fail due to different block allocations.
Increase the filesystem inode size so that the allocation is the same
regardless of whether selinux is enabled or not.

Print out the contents of failed test files in case of errors.

Fix warning in print_acl() from printing "void *" instead of "char *".

Fixes: 8631879536 ("LU-11604 debugfs: add support for printing ACL")
Fixes: 67e6ae0a35 ("mke2fs: fix a importing a directory with an ACL and inline data")
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I62512c457bb3f1d2a59038c7f02e5c27e6916a54
Reviewed-on: https://review.whamcloud.com/46024
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Artem Blagodarenko <artem.blagodarenko@hpe.com>
Reviewed-by: Li Dongyang <dongyangli@ddn.com>
debugfs/xattrs.c
tests/d_print_acl/script
tests/filter.sed
tests/m_rootdir_acl/expect
tests/m_rootdir_acl/script
tests/test_post

index e1fd2e8..6c266fb 100644 (file)
@@ -85,7 +85,7 @@ static void print_xattr(FILE *f, char *name, char *value, size_t value_len,
        fputc('\n', f);
 }
 
-static int print_acl(FILE *f, void *name, void *value, size_t value_len)
+static int print_acl(FILE *f, char *name, void *value, size_t value_len)
 {
        const ext4_acl_header *ext_acl = (const ext4_acl_header *)value;
        const char *cp;
@@ -155,7 +155,7 @@ static int print_acl(FILE *f, void *name, void *value, size_t value_len)
        return 0;
 }
 
-static int print_fidstr(FILE *f, void *name, void *value, size_t value_len)
+static int print_fidstr(FILE *f, char *name, void *value, size_t value_len)
 {
        struct filter_fid_old *ff = value;
        int stripe;
@@ -207,7 +207,7 @@ static int print_fidstr(FILE *f, void *name, void *value, size_t value_len)
        return 0;
 }
 
-static int print_lmastr(FILE *f, void *name, void *value, size_t value_len)
+static int print_lmastr(FILE *f, char *name, void *value, size_t value_len)
 {
        struct lustre_mdt_attrs *lma = value;
        struct lustre_ost_attrs *loa = value;
@@ -263,7 +263,7 @@ static void print_name(FILE *f, const char *cp, int len)
        }
 }
 
-static int print_linkea(FILE *f, void *name, void *value, size_t value_len)
+static int print_linkea(FILE *f, char *name, void *value, size_t value_len)
 {
        struct link_ea_header *leh = value;
        struct link_ea_entry *lee;
@@ -315,7 +315,7 @@ static int print_linkea(FILE *f, void *name, void *value, size_t value_len)
 
 struct dump_attr_pretty {
        const char *dap_name;
-       int (*dap_print)(FILE *f, void *name, void *value, size_t value_len);
+       int (*dap_print)(FILE *f, char *name, void *value, size_t value_len);
 } dumpers[] = {
        {
                .dap_name = "system.posix_acl_access",
index 481003b..d5cbd62 100644 (file)
@@ -9,12 +9,10 @@ if ! setfacl --help > /dev/null 2>&1 ; then
        return 0
 fi
 
-MKFS_DIR=$TMPFILE.dir
+MKFS_DIR=$(mktemp -d ./$test_name-XXXXXX.tmp)
 OUT=$test_name.log
 EXP=$test_dir/expect
 
-rm -rf $MKFS_DIR
-mkdir -p $MKFS_DIR
 mkdir $MKFS_DIR/acl_dir
 
 setfacl --restore=- <<EOF
@@ -31,6 +29,12 @@ default:mask::r-x
 default:other::r-x
 EOF
 
+if ! getfattr -d -m - $MKFS_DIR/acl_dir | grep -q posix_acl; then
+       echo "$test_name: $test_description: skipped (no posix_acl xattrs)"
+       rm -rf $MKFS_DIR
+       return 0
+fi
+
 $MKE2FS -q -F -o Linux -T ext4 -b 1024 -d $MKFS_DIR $TMPFILE 16384 > $OUT.new 2>&1
 
 $DEBUGFS -w -R "ea_list /acl_dir" $TMPFILE >> $OUT.new 2>&1
index a1cf16d..0115213 100644 (file)
@@ -20,6 +20,7 @@ s/\\015//g
 /^Maximum mount count:/d
 /^Next check after:/d
 /^Suggestion:/d
+/security.selinux/d
 /Reserved blocks uid:/s/ (user .*)//
 /Reserved blocks gid:/s/ (group .*)//
 /whichever comes first/d
index 50f32a9..26f9db0 100644 (file)
@@ -10,8 +10,8 @@ Filesystem OS type:       Linux
 Inode count:              1024
 Block count:              16384
 Reserved block count:     819
-Overhead clusters:        2567
-Free blocks:              13764
+Overhead clusters:        2823
+Free blocks:              13509
 Free inodes:              1003
 First block:              1
 Block size:               1024
@@ -21,14 +21,14 @@ Reserved GDT blocks:      127
 Blocks per group:         8192
 Fragments per group:      8192
 Inodes per group:         512
-Inode blocks per group:   128
+Inode blocks per group:   256
 Flex block group size:    16
 Mount count:              0
 Check interval:           15552000 (6 months)
 Reserved blocks uid:      0
 Reserved blocks gid:      0
 First inode:              11
-Inode size:              256
+Inode size:              512
 Required extra isize:     32
 Desired extra isize:      32
 Journal inode:            8
@@ -49,16 +49,16 @@ Group 0: (Blocks 1-8192)
   Reserved GDT blocks at 3-129
   Block bitmap at 130 (+129)
   Inode bitmap at 132 (+131)
-  Inode table at 134-261 (+133)
-  7750 free blocks, 491 free inodes, 5 directories, 491 unused inodes
-  Free blocks: 443-8192
+  Inode table at 134-389 (+133)
+  7495 free blocks, 491 free inodes, 5 directories, 491 unused inodes
+  Free blocks: 698-8192
   Free inodes: 22-512
 Group 1: (Blocks 8193-16383) [INODE_UNINIT]
   Backup superblock at 8193, Group descriptors at 8194-8194
   Reserved GDT blocks at 8195-8321
   Block bitmap at 131 (bg #0 + 130)
   Inode bitmap at 133 (bg #0 + 132)
-  Inode table at 262-389 (bg #0 + 261)
+  Inode table at 390-645 (bg #0 + 389)
   6014 free blocks, 512 free inodes, 0 directories, 512 unused inodes
   Free blocks: 10370-16383
   Free inodes: 513-1024
@@ -131,4 +131,4 @@ Pass 2: Checking directory structure
 Pass 3: Checking directory connectivity
 Pass 4: Checking reference counts
 Pass 5: Checking group summary information
-test.img: 21/1024 files (0.0% non-contiguous), 2620/16384 blocks
+test.img: 21/1024 files (0.0% non-contiguous), 2875/16384 blocks
index 2a2a4c6..df90332 100644 (file)
@@ -9,12 +9,10 @@ if ! setfacl --help > /dev/null 2>&1 ; then
        return 0
 fi
 
-MKFS_DIR=$TMPFILE.dir
+MKFS_DIR=$(mktemp -d ./$test_name-XXXXXX.tmp)
 OUT=$test_name.log
 EXP=$test_dir/expect
 
-rm -rf $MKFS_DIR
-mkdir -p $MKFS_DIR
 touch $MKFS_DIR/emptyfile
 dd if=/dev/zero bs=1024 count=32 2> /dev/null | tr '\0' 'a' > $MKFS_DIR/bigfile
 echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=1024 2> /dev/null
@@ -53,7 +51,14 @@ mask::r-x
 other::r-x
 EOF
 
-$MKE2FS -q -F -o Linux -T ext4 -O metadata_csum,inline_data,64bit -E lazy_itable_init=1 -b 1024 -d $MKFS_DIR $TMPFILE 16384 > $OUT 2>&1
+if ! getfattr -d -m - $MKFS_DIR/acl_dir | grep -q posix_acl; then
+       echo "$test_name: $test_description: skipped (no posix_acl xattrs)"
+       rm -rf $MKFS_DIR
+       return 0
+fi
+
+# use 512-byte inodes so with/out security.selinux xattr doesn't fail
+$MKE2FS -q -F -o Linux -T ext4 -I 512 -O metadata_csum,inline_data,64bit -E lazy_itable_init=1 -b 1024 -d $MKFS_DIR $TMPFILE 16384 > $OUT 2>&1
 
 $DUMPE2FS $TMPFILE >> $OUT 2>&1
 cat > $TMPFILE.cmd << ENDL
index 1251266..c9acffb 100755 (executable)
@@ -10,7 +10,8 @@ test "$num_failed" -eq 0 && exit 0
 
 echo -n "Tests failed: "
 for fname in $(ls *.failed); do
-       echo -n "${fname%%.failed} "
+       echo "${fname%%.failed} "
+       cat $fname
 done
 echo ""