common/rc: add _scratch_{u}mount_idmapped() helpers
[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_fs xfs
31 _require_scratch_nocheck
32 _require_command "$XFS_DB_PROG" "xfs_db"
33 _require_xfs_db_command "fuzz"
34
35 rm -f "$seqres.full"
36
37 echo "Format"
38 _scratch_mkfs | _filter_mkfs 2>$tmp.mkfs >> "$seqres.full"
39 source $tmp.mkfs
40
41 do_xfs_db()
42 {
43         local cmd=$1
44         if [ $_fs_has_crcs -eq 0 ]; then
45                 echo "Allowing $cmd of corrupted data with good CRC"
46         fi
47         _scratch_xfs_db -x -c 'sb 0' -c "$*"
48 }
49
50 # Make sure that each fuzz verb works.  For the firstbit/middlebit/lastbit
51 # tests, we depend on 'ones' having set the field to all ones.
52 field="fdblocks"
53 do_xfs_db write -d ${field} 0
54 SCRATCH_XFS_LIST_FUZZ_VERBS= _scratch_xfs_list_fuzz_verbs | while read verb; do
55         test "${verb}" = "random" && continue
56         echo "Test verb ${verb}"
57         do_xfs_db fuzz -d ${field} ${verb}
58 done
59
60 echo "Test verb random"
61 before="$(_scratch_xfs_get_metadata_field "${field}" 'sb 0')"
62 do_xfs_db fuzz -d ${field} random >> $seqres.full
63 after="$(_scratch_xfs_get_metadata_field "${field}" 'sb 0')"
64 test "${before}" != "${after}" && echo "${field} changed"
65
66 echo "Done"
67 # success, all done
68 status=0
69 exit