xfs/419: remove irrelevant swapfile test
[xfstests-dev.git] / tests / xfs / 085
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 085
6 #
7 # Create and populate an XFS filesystem, corrupt a superblock, then see how
8 # the kernel and xfs_repair deal with it.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21     cd /
22     #rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/attr
29 . ./common/populate
30
31 # real QA test starts here
32 _supported_fs xfs
33
34 _require_scratch
35 test -n "${FORCE_FUZZ}" || _require_scratch_xfs_crc
36 _require_attrs
37 _require_populate_commands
38 _require_xfs_db_blocktrash_z_command
39
40 rm -f $seqres.full
41 TESTDIR="${SCRATCH_MNT}/scratchdir"
42 TESTFILE="${TESTDIR}/testfile"
43
44 echo "+ create scratch fs"
45 _scratch_mkfs_xfs > /dev/null
46
47 echo "+ mount fs image"
48 _scratch_mount
49 blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
50
51 echo "+ make some files"
52 mkdir -p "${TESTDIR}"
53 for x in `seq 1 1024`; do
54         touch "${SCRATCH_MNT}/junk.${x}"
55         inode="$(stat -c '%i' "${SCRATCH_MNT}/junk.${x}")"
56         if [ "$x" -gt 512 ] && [ "$((inode % 64))" -eq 0 ]; then
57                 mv "${SCRATCH_MNT}/junk.${x}" "${TESTFILE}.1"
58                 break
59         fi
60 done
61 for x in `seq 2 64`; do
62         touch "${TESTFILE}.${x}"
63 done
64 inode="$(stat -c '%i' "${TESTFILE}.1")"
65 agcount="$(_xfs_mount_agcount $SCRATCH_MNT)"
66 umount "${SCRATCH_MNT}"
67
68 echo "+ check fs"
69 _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
70
71 echo "+ corrupt image"
72 $XFS_IO_PROG -f -c "pwrite -S 0x62 32 4" "${SCRATCH_DEV}" >> $seqres.full
73
74 echo "+ mount image"
75 _try_scratch_mount 2>/dev/null && _fail "mount should not succeed"
76
77 echo "+ repair fs"
78 _scratch_xfs_repair >> $seqres.full 2>&1
79
80 echo "+ mount image (2)"
81 _scratch_mount
82
83 echo "+ chattr -R -i"
84 $CHATTR_PROG -R -f -i "${SCRATCH_MNT}/"
85
86 echo "+ modify files (2)"
87 broken=0
88 for x in `seq 1 64`; do
89         test -e "${TESTFILE}.${x}" || continue
90         echo moo | dd oflag=append conv=notrunc of="${TESTFILE}.${x}" 2>/dev/null
91         test $? -ne 0 && broken=1
92 done
93 echo "broken: ${broken}"
94 umount "${SCRATCH_MNT}"
95
96 echo "+ check fs (2)"
97 _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
98
99 status=0
100 exit