Whamcloud - gitweb
LU-11604 tests: fix ACL-printing tests
[tools/e2fsprogs.git] / tests / m_rootdir_acl / script
1 test_description="create fs image from dir using inline_data and acls"
2 if ! test -x $DEBUGFS_EXE; then
3         echo "$test_name: $test_description: skipped (no debugfs)"
4         return 0
5 fi
6
7 if ! setfacl --help > /dev/null 2>&1 ; then
8         echo "$test_name: $test_description: skipped (no setfacl)"
9         return 0
10 fi
11
12 MKFS_DIR=$(mktemp -d ./$test_name-XXXXXX.tmp)
13 OUT=$test_name.log
14 EXP=$test_dir/expect
15
16 touch $MKFS_DIR/emptyfile
17 dd if=/dev/zero bs=1024 count=32 2> /dev/null | tr '\0' 'a' > $MKFS_DIR/bigfile
18 echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=1024 2> /dev/null
19 echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=524288 conv=notrunc 2> /dev/null
20 echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=1048576 conv=notrunc 2> /dev/null
21 echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=536870912 conv=notrunc 2> /dev/null
22 echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=1073741824 conv=notrunc 2> /dev/null
23 dd if=/dev/zero of=$MKFS_DIR/bigzerofile bs=1 count=1 seek=1073741824 2> /dev/null
24 ln $MKFS_DIR/bigzerofile $MKFS_DIR/bigzerofile_hardlink
25 ln -s /silly_bs_link $MKFS_DIR/silly_bs_link
26 mkdir $MKFS_DIR/emptydir
27 mkdir $MKFS_DIR/dir
28 echo "Test me" > $MKFS_DIR/dir/file
29 mkdir $MKFS_DIR/acl_dir
30 echo "Test me 2" > $MKFS_DIR/acl_dir/file
31
32 setfacl --restore=- <<EOF
33 # file: $MKFS_DIR/acl_dir
34 user::rwx
35 group::r-x
36 group:42:r-x
37 mask::r-x
38 other::r-x
39 default:user::rwx
40 default:group::r-x
41 default:group:4:r-x
42 default:mask::r-x
43 default:other::r-x
44 EOF
45 setfacl --restore=- <<EOF
46 # file: $MKFS_DIR/acl_dir/file
47 user::rwx
48 group::r-x
49 group:42:r-x
50 mask::r-x
51 other::r-x
52 EOF
53
54 if ! getfattr -d -m - $MKFS_DIR/acl_dir | grep -q posix_acl; then
55         echo "$test_name: $test_description: skipped (no posix_acl xattrs)"
56         rm -rf $MKFS_DIR
57         return 0
58 fi
59
60 # use 512-byte inodes so with/out security.selinux xattr doesn't fail
61 $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
62
63 $DUMPE2FS $TMPFILE >> $OUT 2>&1
64 cat > $TMPFILE.cmd << ENDL
65 stat /emptyfile
66 stat /bigfile
67 stat /sparsefile
68 stat /bigzerofile
69 stat /fifo
70 stat /emptydir
71 stat /dir
72 stat /dir/file
73 stat /acl_dir
74 stat /acl_dir/file
75 ENDL
76 $DEBUGFS -f $TMPFILE.cmd $TMPFILE 2>&1 | egrep "(stat|Size:|Type:)" >> $OUT
77
78 cat > $TMPFILE.cmd << ENDL
79 ea_list dir/file
80 ea_list acl_dir
81 ea_list acl_dir/file
82 ENDL
83 $DEBUGFS -f $TMPFILE.cmd $TMPFILE >> $OUT 2>&1
84
85 $FSCK -f -n $TMPFILE >> $OUT 2>&1
86
87 sed -f $cmd_dir/filter.sed -f $test_dir/output.sed -e "s;$TMPFILE;test.img;" < $OUT > $OUT.tmp
88 mv $OUT.tmp $OUT
89
90 # Do the verification
91 cmp -s $OUT $EXP
92 status=$?
93
94 if [ "$status" = 0 ] ; then
95         echo "$test_name: $test_description: ok"
96         touch $test_name.ok
97 else
98         echo "$test_name: $test_description: failed"
99         diff $DIFF_OPTS $EXP $OUT > $test_name.failed
100 fi
101
102 rm -rf $TMPFILE.cmd $MKFS_DIR
103 unset MKFS_DIR OUT EXP