generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / common / attr
index 669909d6007233df73517ba8da1d5ee776373f63..3ebba682c894f6f85f12189f675c61c5ec24e45f 100644 (file)
@@ -26,13 +26,29 @@ _acl_get_max()
                echo 8191
                ;;
        f2fs)
-               _fs_options $TEST_DEV | grep "inline_xattr" >/dev/null 2>&1
+               # If noinline_xattr is enabled, max xattr size should be:
+               # (4096 - 24) - (24 + 4) = 4044
+               # then ACL_MAX_ENTRIES should be:
+               # (4044 - (4 + 4 * 4)) / 8 + 4 = 507
+               _fs_options $TEST_DEV | grep "noinline_xattr" >/dev/null 2>&1
                if [ $? -eq 0 ]; then
-                       echo 531
+                       echo 507
                else
-                       echo 506
+                       # If inline_xattr is enabled, max xattr size should be:
+                       # (4096 - 24 + 200) - (24 + 4) = 4244
+                       # then ACL_MAX_ENTRIES should be:
+                       # (4244 - (4 + 4 * 4)) / 8 + 4 = 532
+                       _fs_options $TEST_DEV | grep "inline_xattr" >/dev/null 2>&1
+                       if [ $? -eq 0 ]; then
+                               echo 532
+                       else
+                               echo 507
+                       fi
                fi
                ;;
+       bcachefs)
+               echo 251
+               ;;
        *)
                echo 0
                ;;
@@ -56,10 +72,10 @@ _acl_setup_ids()
         j=1
         for(i=1; i<1000000 && j<=3;i++){
           if (! (i in ids)) {
-            printf "acl%d=%d;", j, i;           
+            printf "acl%d=%d;", j, i;
             j++
           }
-        }      
+        }
       }'`
 }
 
@@ -98,7 +114,7 @@ _getfacl_filter_id()
 _acl_ls()
 {
     _ls_l -n $* | awk '{ print $1, $3, $4, $NF }' | _acl_filter_id
-} 
+}
 
 # create an ACL with n ACEs in it
 #
@@ -125,7 +141,7 @@ _filter_aces()
        BEGIN {
            FS=":"
            while ( getline <tmpfile > 0 ) {
-               idlist[$1] = $3 
+               idlist[$1] = $3
            }
        }
        /^user/ { if ($2 in idlist) sub($2, idlist[$2]); print; next}
@@ -147,13 +163,12 @@ _require_acls()
     [ -n "$CHACL_PROG" ] || _notrun "chacl command not found"
 
     #
-    # Test if chacl is able to list ACLs on the target filesystems.  On really
-    # old kernels the system calls might not be implemented at all, but the
-    # more common case is that the tested filesystem simply doesn't support
-    # ACLs.
+    # Test if chacl is able to set an ACL on a file.  On really old kernels
+    # the system calls might not be implemented at all, but the more common
+    # case is that the tested filesystem simply doesn't support ACLs.
     #
     touch $TEST_DIR/syscalltest
-    chacl -l $TEST_DIR/syscalltest > $TEST_DIR/syscalltest.out 2>&1
+    chacl 'u::rw-,g::---,o::---' $TEST_DIR/syscalltest > $TEST_DIR/syscalltest.out 2>&1
     cat $TEST_DIR/syscalltest.out >> $seqres.full
 
     if grep -q 'Function not implemented' $TEST_DIR/syscalltest.out; then
@@ -177,17 +192,17 @@ _require_attrs()
 {
        local args
        local nsp
-       
+
        if [ $# -eq 0 ]; then
                args="user"
        else
                args="$*"
        fi
-       
+
        [ -n "$ATTR_PROG" ] || _notrun "attr command not found"
        [ -n "$GETFATTR_PROG" ] || _notrun "getfattr command not found"
        [ -n "$SETFATTR_PROG" ] || _notrun "setfattr command not found"
-       
+
        for nsp in $args; do
                #
                # Test if chacl is able to write an attribute on the target
@@ -201,14 +216,14 @@ _require_attrs()
                touch $TEST_DIR/syscalltest
                $SETFATTR_PROG -n "$nsp.xfstests" -v "attr" $TEST_DIR/syscalltest > $TEST_DIR/syscalltest.out 2>&1
                cat $TEST_DIR/syscalltest.out >> $seqres.full
-               
+
                if grep -q 'Function not implemented' $TEST_DIR/syscalltest.out; then
                        _notrun "kernel does not support attrs"
                fi
                if grep -q 'Operation not supported' $TEST_DIR/syscalltest.out; then
                        _notrun "attr namespace $nsp not supported by this filesystem type: $FSTYP"
                fi
-               
+
                rm -f $TEST_DIR/syscalltest.out
        done
 }
@@ -248,38 +263,5 @@ _getfattr()
        return ${PIPESTATUS[0]}
 }
 
-# set maximum total attr space based on fs type
-case "$FSTYP" in
-xfs|udf|pvfs2|9p|ceph|nfs)
-       MAX_ATTRS=1000
-       ;;
-*)
-       # Assume max ~1 block of attrs
-       BLOCK_SIZE=`_get_block_size $TEST_DIR`
-       # user.attribute_XXX="value.XXX" is about 32 bytes; leave some overhead
-       let MAX_ATTRS=$BLOCK_SIZE/40
-esac
-
-export MAX_ATTRS
-
-# Set max attr value size based on fs type
-case "$FSTYP" in
-xfs|udf|btrfs)
-       MAX_ATTRVAL_SIZE=64
-       ;;
-pvfs2)
-       MAX_ATTRVAL_SIZE=8192
-       ;;
-9p|ceph|nfs)
-       MAX_ATTRVAL_SIZE=65536
-       ;;
-*)
-       # Assume max ~1 block of attrs
-       BLOCK_SIZE=`_get_block_size $TEST_DIR`
-       # leave a little overhead
-       let MAX_ATTRVAL_SIZE=$BLOCK_SIZE-256
-esac
-
-export MAX_ATTRVAL_SIZE
 # make sure this script returns success
 /bin/true