xfs: fix old fuzz test invocations of xfs_repair
[xfstests-dev.git] / tests / generic / 054
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 054
6 #
7 # To test log replay with version 2 logs
8 # Initially keep this simple with just creates.
9 # In another qa test we can do more e.g. use fsstress.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
19
20 # get standard environment, filters and checks
21 . ./common/rc
22 . ./common/filter
23 . ./common/log
24
25 # real QA test starts here
26 _supported_fs generic
27
28 rm -f $seqres.full $tmp.*
29 _require_scratch
30 _require_scratch_shutdown
31 _require_logstate
32
33 echo "*** init FS"
34 _scratch_unmount >/dev/null 2>&1
35
36 _scratch_mkfs >/dev/null 2>&1
37 _require_metadata_journaling $SCRATCH_DEV
38
39 _get_log_configs > $tmp.seq.params
40
41 # Do the work for various log params which
42 # should not effect the data content of the log
43 # Try with and without sync'ing - sync'ing will mean that
44 # the log will be written out unfilled and thus the log
45 # stripe can have an effect.
46 #
47 for s in sync nosync ; do
48     cat $tmp.seq.params \
49     | while read mkfs mnt restofline
50     do
51         if [ "$mkfs" = "#" ]; then
52             continue
53         fi
54
55         echo "--- mkfs=$mkfs, mnt=$mnt, sync=$s ---" >>$seqres.full
56         export MKFS_OPTIONS="-l $mkfs"
57         export MOUNT_OPTIONS="-o $mnt"
58
59         # mkfs the FS
60         _echofull "mkfs"
61         _scratch_mkfs >>$seqres.full 2>&1
62         if [ $? -ne 0 ] ; then
63             _echofull "mkfs failed: $MKFS_OPTIONS"
64             continue
65         fi
66
67         # mount the FS
68         _echofull "mount"
69         if ! _try_scratch_mount >>$seqres.full 2>&1; then
70             _echofull "mount failed: $MOUNT_OPTIONS"
71             continue
72         fi
73
74         # create the metadata
75         if [ $s = "sync" ]; then
76             # generate some log traffic - but not too much
77             # add some syncs to get the log flushed to disk
78             for file in $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}; do
79                 touch $file
80                 sync
81             done
82         else
83             # generate some log traffic - but not too much - life gets a little
84             # more complicated if the log wraps around. This traffic is
85             # pretty much arbitary, but could probably be made better than this.
86             touch $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
87         fi
88
89         # check before on what FS should look like
90         _echofull "ls SCRATCH_MNT"
91         ls $SCRATCH_MNT | _filter_lostfound
92
93         _echofull "godown"
94         _scratch_shutdown -v -f >> $seqres.full
95
96         _echofull "unmount"
97         _scratch_unmount >>$seqres.full 2>&1 \
98             || _fail "umount failed"
99
100         _echofull "logprint after going down..."
101         _print_logstate
102
103         _echofull "mount with replay"
104         _try_scratch_mount >>$seqres.full 2>&1 \
105             || _fail "mount failed: $MOUNT_OPTIONS"
106
107         # check on what FS looks like after log recovery
108         _echofull "ls SCRATCH_MNT"
109         ls $SCRATCH_MNT | _filter_lostfound
110
111         _echofull "unmount"
112         _scratch_unmount
113
114         _echofull "logprint after mount and replay..."
115         _print_logstate
116
117         if _check_scratch_fs; then
118             _echofull "filesystem is checked ok"
119         else
120             _echofull "filesystem is NOT ok"
121         fi
122     done
123 done
124
125 status=0
126 exit