xfs: convert tests to SPDX license tags
[xfstests-dev.git] / tests / xfs / 041
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 041
6 #
7 # growfs QA tests - repeatedly fill/grow the filesystem
8 # check the filesystem contents after each operation
9 #
10 set +x
11
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19
20 _cleanup()
21 {
22     cd /
23     _scratch_unmount
24     rm -f $tmp.*
25 }
26 trap "_cleanup ; exit \$status" 0 1 2 3 15
27
28 # get standard environment, filters and checks
29 . ./common/rc
30 . ./common/filter
31
32 # real QA test starts here
33 _supported_fs xfs
34 _supported_os Linux
35
36 _require_scratch
37 _require_no_large_scratch_dev
38 _scratch_unmount 2>/dev/null
39
40 _fill()
41 {
42     if [ $# -ne 1 ]; then echo "Usage: _fill \"path\"" 1>&2 ; exit 1; fi
43     _do "Fill filesystem" \
44         "src/fill2fs --verbose --dir=$1 --seed=0 --filesize=65536 --stddev=32768 --list=- >>$tmp.manifest"
45 }
46
47 _do_die_on_error=message_only
48 rm -f $seqres.full
49 agsize=32
50 echo -n "Make $agsize megabyte filesystem on SCRATCH_DEV and mount... "
51 _scratch_mkfs_xfs -dsize=${agsize}m,agcount=1 2>&1 >/dev/null || _fail "mkfs failed"
52 bsize=`_scratch_mkfs_xfs -dsize=${agsize}m,agcount=1 2>&1 | _filter_mkfs 2>&1 \
53                 | perl -ne 'if (/dbsize=(\d+)/) {print $1;}'`
54 onemeginblocks=`expr 1048576 / $bsize`
55 _scratch_mount
56
57 echo "done"
58
59 # full allocation group -> partial; partial -> expand partial + new partial;
60 # partial -> expand partial; partial -> full
61 # cycle through 33m -> 67m -> 75m -> 96m
62 for size in 33 67 75 96
63 do
64     grow_size=`expr $size \* $onemeginblocks`
65     _fill $SCRATCH_MNT/fill_$size
66     _do "Grow filesystem to ${size}m" "xfs_growfs -D $grow_size $SCRATCH_MNT"
67     echo -n "Flush filesystem... "
68     _do "_scratch_unmount"
69     _do "_try_scratch_mount"
70     echo "done"
71     echo -n "Check files... "
72     if ! _do "src/fill2fs_check $tmp.manifest"; then
73       echo "fail (see $seqres.full)"
74       _do "cat $tmp.manifest"
75       _do "ls -altrR $SCRATCH_MNT"
76       _do "dd if=$SCRATCH_DEV bs=4096 count=$grow_size | gzip -9 > $seq.fsimage.gz"
77       status=1 ; exit
78     fi
79     echo "done"
80 done
81
82 # success, all done
83 echo "Growfs tests passed."
84 status=0 ; exit