common/fuzzy: if the fuzz verb is random, keep fuzzing until we get a new value
[xfstests-dev.git] / common / punch
index f2d538c1d3e73656ede38c30715f1b77391bea9b..c4ed26192a2219e232202ecda9486e55a432f90d 100644 (file)
@@ -115,7 +115,7 @@ _test_punch() {
        local filename=punch_test_file
 
        cd /
-       umount $SCRATCH_MNT >/dev/null 2>&1
+       _scratch_unmount >/dev/null 2>&1
 
        _scratch_mkfs_xfs -bsize=$blksize >/dev/null 2>&1 \
                || _fail "mkfs failed"
@@ -203,12 +203,12 @@ _coalesce_extents()
 
 _filter_fiemap()
 {
-       awk --posix '
+       $AWK_PROG '
                $3 ~ /hole/ {
                        print $1, $2, $3;
                        next;
                }
-               $5 ~ /0x[[:xdigit:]]*8[[:xdigit:]]{2}/ {
+               $5 ~ /0x[[:xdigit:]]*8[[:xdigit:]][[:xdigit:]]/ {
                        print $1, $2, "unwritten";
                        next;
                }
@@ -218,12 +218,29 @@ _filter_fiemap()
        _coalesce_extents
 }
 
+_filter_fiemap_flags()
+{
+       $AWK_PROG '
+               $3 ~ /hole/ {
+                       print $1, $2, $3;
+                       next;
+               }
+               $5 ~ /0x[[:xdigit:]]*8[[:xdigit:]][[:xdigit:]]/ {
+                       print $1, $2, "unwritten";
+                       next;
+               }
+               $5 ~ /0x[[:xdigit:]]+/ {
+                       print $1, $2, $5;
+               }' |
+       _coalesce_extents
+}
+
 # Filters fiemap output to only print the 
 # file offset column and whether or not
 # it is an extent or a hole
 _filter_hole_fiemap()
 {
-       awk --posix '
+       $AWK_PROG '
                $3 ~ /hole/ {
                        print $1, $2, $3; 
                        next;
@@ -234,6 +251,11 @@ _filter_hole_fiemap()
        _coalesce_extents
 }
 
+#     10000 Unwritten preallocated extent
+#     01000 Doesn't begin on stripe unit
+#     00100 Doesn't end   on stripe unit
+#     00010 Doesn't begin on stripe width
+#     00001 Doesn't end   on stripe width
 _filter_bmap()
 {
        awk '
@@ -241,11 +263,11 @@ _filter_bmap()
                        print $1, $2, $3;
                        next;
                }
-               $7 ~ /10000/ {
+               $7 ~ /1[01][01][01][01]/ {
                        print $1, $2, "unwritten";
                        next;
                }
-               $7 ~ /00000/ {
+               $7 ~ /0[01][01][01][01]/ {
                        print $1, $2, "data"
                }' |
        _coalesce_extents
@@ -527,6 +549,11 @@ _test_generic_punch()
                return
        fi
 
+       # If zero_cmd is finsert, don't check unaligned offsets
+       if [ "$zero_cmd" == "finsert" ]; then
+               return
+       fi
+
        echo "  16. data -> cache cold ->hole"
        if [ "$remove_testfile" ]; then
                rm -f $testfile
@@ -557,7 +584,7 @@ _test_generic_punch()
        if [ "$remove_testfile" ]; then
                rm -f $testfile
        fi
-       block_size=`stat -f $TEST_DIR | grep "Block size" | cut -d " " -f3`
+       block_size=`_get_block_size $TEST_DIR`
        $XFS_IO_PROG -f -c "truncate $block_size" \
                -c "pwrite 0 $block_size" $sync_cmd \
                -c "$zero_cmd 128 128" \