fstests: move test group info to test files
[xfstests-dev.git] / tests / ext4 / 016
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. 016
6 #
7 # Create and populate an ext4 filesystem, corrupt a dirent block, then
8 # see how the kernel and e2fsck deal with it.
9 #
10 . ./common/preamble
11 _begin_fstest fuzzers
12
13 # Override the default cleanup function.
14 _cleanup()
15 {
16     cd /
17     #rm -f $tmp.*
18 }
19
20 # Import common functions.
21 . ./common/filter
22 . ./common/attr
23
24 # real QA test starts here
25 _supported_fs ext4
26
27 _require_scratch
28 test -n "${FORCE_FUZZ}" || _require_scratch_ext4_crc
29 _require_attrs
30
31 TESTDIR="${SCRATCH_MNT}/scratchdir"
32 TESTFILE="${TESTDIR}/testfile"
33
34 echo "+ create scratch fs"
35 _scratch_mkfs_ext4 > /dev/null 2>&1
36
37 echo "+ mount fs image"
38 _scratch_mount
39
40 echo "+ make some files"
41 for x in `seq 1 15`; do
42         mkdir -p "${SCRATCH_MNT}/test/d_${x}"
43 done
44 umount "${SCRATCH_MNT}"
45
46 echo "+ check fs"
47 e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
48
49 echo "+ corrupt image"
50 debugfs -w -R "zap -f /test 0" "${SCRATCH_DEV}" 2> /dev/null
51
52 echo "+ mount image"
53 _scratch_mount
54
55 echo "+ modify dirs"
56 mkdir -p "${SCRATCH_MNT}/test/newdir" 2> /dev/null && _fail "directory should be corrupt"
57 umount "${SCRATCH_MNT}"
58
59 echo "+ repair fs"
60 e2fsck -fy "${SCRATCH_DEV}" >> $seqres.full 2>&1
61
62 echo "+ mount image (2)"
63 _scratch_mount
64
65 echo "+ modify dirs (2)"
66 mkdir -p "${SCRATCH_MNT}/test/newdir" || _fail "directory should be corrupt"
67 umount "${SCRATCH_MNT}"
68
69 echo "+ check fs (2)"
70 e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
71
72 status=0
73 exit