fstests: convert remaining tests to SPDX license tags
[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 _supported_os Linux
28
29 rm -f $seqres.full $tmp.*
30 _require_scratch
31 _require_scratch_shutdown
32 _require_logstate
33
34 echo "*** init FS"
35 _scratch_unmount >/dev/null 2>&1
36
37 _scratch_mkfs >/dev/null 2>&1
38 _require_metadata_journaling $SCRATCH_DEV
39
40 _get_log_configs > $tmp.seq.params
41
42 # Do the work for various log params which
43 # should not effect the data content of the log
44 # Try with and without sync'ing - sync'ing will mean that
45 # the log will be written out unfilled and thus the log
46 # stripe can have an effect.
47 #
48 for s in sync nosync ; do
49     cat $tmp.seq.params \
50     | while read mkfs mnt restofline
51     do
52         if [ "$mkfs" = "#" ]; then
53             continue
54         fi
55
56         echo "--- mkfs=$mkfs, mnt=$mnt, sync=$s ---" >>$seqres.full
57         export MKFS_OPTIONS="-l $mkfs"
58         export MOUNT_OPTIONS="-o $mnt"
59
60         # mkfs the FS
61         _echofull "mkfs"
62         _scratch_mkfs >>$seqres.full 2>&1
63         if [ $? -ne 0 ] ; then
64             _echofull "mkfs failed: $MKFS_OPTIONS"
65             continue
66         fi
67
68         # mount the FS
69         _echofull "mount"
70         if ! _try_scratch_mount >>$seqres.full 2>&1; then
71             _echofull "mount failed: $MOUNT_OPTIONS"
72             continue
73         fi
74
75         # create the metadata
76         if [ $s = "sync" ]; then
77             # generate some log traffic - but not too much
78             # add some syncs to get the log flushed to disk
79             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
80                 touch $file
81                 sync
82             done
83         else
84             # generate some log traffic - but not too much - life gets a little
85             # more complicated if the log wraps around. This traffic is
86             # pretty much arbitary, but could probably be made better than this.
87             touch $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
88         fi
89
90         # check before on what FS should look like
91         _echofull "ls SCRATCH_MNT"
92         ls $SCRATCH_MNT | _filter_lostfound
93
94         _echofull "godown"
95         _scratch_shutdown -v -f >> $seqres.full
96
97         _echofull "unmount"
98         _scratch_unmount >>$seqres.full 2>&1 \
99             || _fail "umount failed"
100
101         _echofull "logprint after going down..."
102         _print_logstate
103
104         _echofull "mount with replay"
105         _try_scratch_mount >>$seqres.full 2>&1 \
106             || _fail "mount failed: $MOUNT_OPTIONS"
107
108         # check on what FS looks like after log recovery
109         _echofull "ls SCRATCH_MNT"
110         ls $SCRATCH_MNT | _filter_lostfound
111
112         _echofull "unmount"
113         _scratch_unmount
114
115         _echofull "logprint after mount and replay..."
116         _print_logstate
117
118         if _check_scratch_fs; then
119             _echofull "filesystem is checked ok"
120         else
121             _echofull "filesystem is NOT ok"
122         fi
123     done
124 done
125
126 status=0
127 exit