fstests: check for filesystem FS_IOC_FSSETXATTR support
[xfstests-dev.git] / tests / xfs / 058
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 058
6 #
7 # Ensure that xfs_db fuzz command works as advertised.
8 #
9 seq=`basename "$0"`
10 seqres="$RESULT_DIR/$seq"
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1    # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         cd /
21         rm -rf "$tmp".*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27 . ./common/fuzzy
28
29 # real QA test starts here
30 _supported_os Linux
31 _supported_fs xfs
32 _require_scratch_nocheck
33 _require_command "$XFS_DB_PROG" "xfs_db"
34 _require_xfs_db_command "fuzz"
35
36 rm -f "$seqres.full"
37
38 echo "Format"
39 _scratch_mkfs | _filter_mkfs 2>$tmp.mkfs >> "$seqres.full"
40 source $tmp.mkfs
41
42 do_xfs_db()
43 {
44         local cmd=$1
45         if [ $_fs_has_crcs -eq 0 ]; then
46                 echo "Allowing $cmd of corrupted data with good CRC"
47         fi
48         _scratch_xfs_db -x -c 'sb 0' -c "$*"
49 }
50
51 # Make sure that each fuzz verb works.  For the firstbit/middlebit/lastbit
52 # tests, we depend on 'ones' having set the field to all ones.
53 field="fdblocks"
54 do_xfs_db write -d ${field} 0
55 SCRATCH_XFS_LIST_FUZZ_VERBS= _scratch_xfs_list_fuzz_verbs | while read verb; do
56         test "${verb}" = "random" && continue
57         echo "Test verb ${verb}"
58         do_xfs_db fuzz -d ${field} ${verb}
59 done
60
61 echo "Test verb random"
62 before="$(_scratch_xfs_get_metadata_field "${field}" 'sb 0')"
63 do_xfs_db fuzz -d ${field} random >> $seqres.full
64 after="$(_scratch_xfs_get_metadata_field "${field}" 'sb 0')"
65 test "${before}" != "${after}" && echo "${field} changed"
66
67 echo "Done"
68 # success, all done
69 status=0
70 exit