Whamcloud - gitweb
LU-11604 tests: fix ACL-printing tests
[tools/e2fsprogs.git] / tests / d_print_acl / script
1 test_description="decode and print Access Control Lists in debugfs"
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 mkdir $MKFS_DIR/acl_dir
17
18 setfacl --restore=- <<EOF
19 # file: $MKFS_DIR/acl_dir
20 user::rwx
21 group::r-x
22 group:42:r-x
23 mask::r-x
24 other::r-x
25 default:user::rwx
26 default:group::r-x
27 default:group:4:r-x
28 default:mask::r-x
29 default:other::r-x
30 EOF
31
32 if ! getfattr -d -m - $MKFS_DIR/acl_dir | grep -q posix_acl; then
33         echo "$test_name: $test_description: skipped (no posix_acl xattrs)"
34         rm -rf $MKFS_DIR
35         return 0
36 fi
37
38 $MKE2FS -q -F -o Linux -T ext4 -b 1024 -d $MKFS_DIR $TMPFILE 16384 > $OUT.new 2>&1
39
40 $DEBUGFS -w -R "ea_list /acl_dir" $TMPFILE >> $OUT.new 2>&1
41 sed -f $cmd_dir/filter.sed $OUT.new > $OUT
42 rm -rf $MKFS_DIR $TMPFILE $OUT.new
43
44 cmp -s $OUT $EXP
45 status=$?
46
47 if [ "$status" = 0 ] ; then
48         echo "$test_name: $test_description: ok"
49         touch $test_name.ok
50 else
51         echo "$test_name: $test_description: failed"
52         diff $DIFF_OPTS $EXP $OUT > $test_name.failed
53 fi
54
55 unset MKFS_DIR OUT EXP