generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / xfs / 049
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. 049
6 #
7 # XFS on loop test
8 #
9 . ./common/preamble
10 _begin_fstest rw auto quick
11
12 # Override the default cleanup function.
13 _cleanup()
14 {
15     cd /
16     umount $SCRATCH_MNT/test2 > /dev/null 2>&1
17     umount $SCRATCH_MNT/test > /dev/null 2>&1
18     rm -f $tmp.*
19
20     if [ -w $seqres.full ]
21     then
22         echo "--- mounts at end (after cleanup)" >> $seqres.full
23         mount >> $seqres.full
24     fi
25 }
26
27 # Import common functions.
28 . ./common/filter
29
30 # real QA test starts here
31 _supported_fs xfs
32
33 _log()
34 {
35     echo "--- $*"
36     echo "--- $*" >> $seqres.full
37 }
38
39 _require_nonexternal
40 _require_scratch_nocheck
41 _require_no_large_scratch_dev
42 _require_loop
43 _require_extra_fs ext2
44
45 echo "(dev=$SCRATCH_DEV, mount=$SCRATCH_MNT)" >> $seqres.full
46 echo "" >> $seqres.full
47
48 echo "--- mounts" >> $seqres.full
49 mount >> $seqres.full
50
51 _log "Create ext2 fs on scratch"
52 mkfs -t ext2 -F $SCRATCH_DEV >> $seqres.full 2>&1 \
53     || _fail "!!! failed to mkfs ext2"
54
55 _log "Mount ext2 fs on scratch"
56 mount -t ext2 $SCRATCH_DEV $SCRATCH_MNT >> $seqres.full 2>&1 \
57     || _fail "!!! failed to mount"
58
59 _log "Create xfs fs in file on scratch"
60 ${MKFS_XFS_PROG} -f -dfile,name=$SCRATCH_MNT/test.xfs,size=40m \
61     >> $seqres.full 2>&1 \
62     || _fail "!!! failed to mkfs xfs"
63
64 _log "Make mount points"
65 mkdir $SCRATCH_MNT/test $SCRATCH_MNT/test2 >> $seqres.full 2>&1 \
66     || _fail "!!! failed to make mount points"
67
68 _log "Mount xfs via loop"
69 mount -t xfs -o loop $SCRATCH_MNT/test.xfs $SCRATCH_MNT/test >> $seqres.full 2>&1 \
70     || _fail "!!! failed to loop mount xfs"
71
72 _log "stress"
73 $FSSTRESS_PROG -d $SCRATCH_MNT/test -n 1000 $FSSTRESS_AVOID >> $seqres.full 2>&1 \
74     || _fail "!!! stress failed"
75
76 _log "clean"
77 rm -rf $SCRATCH_MNT/test/* >> $seqres.full 2>&1 \
78     || _fail "!!! clean failed"
79
80 _log "create file for ext2 fs"
81 dd if=/dev/zero of=$SCRATCH_MNT/test/test.ext2 bs=1024 count=10240 >> $seqres.full 2>&1 \
82     || _fail "!!! create file failed"
83
84 _log "Create ext2 fs in file on looped xfs"
85 echo y | mkfs -t ext2 $SCRATCH_MNT/test/test.ext2 >> $seqres.full 2>&1 \
86     || _fail "!!! failed to mkfs ext2 on xfs"
87
88 _log "Mount ext2 on xfs via loop"
89 mount -t ext2 -o loop $SCRATCH_MNT/test/test.ext2 $SCRATCH_MNT/test2 >> $seqres.full 2>&1 \
90     || _fail "!!! failed to loop mount xfs"
91
92 _log "stress ext2 on xfs via loop"
93 $FSSTRESS_PROG -d $SCRATCH_MNT/test2 -n 1000 $FSSTRESS_AVOID >> $seqres.full 2>&1 \
94     || _fail "!!! stress ext2 failed"
95
96 _log "clean"
97 rm -rf $SCRATCH_MNT/test/* >> $seqres.full 2>&1 \
98     || _fail "!!! clean failed"
99
100 _log "umount ext2 on xfs"
101 umount $SCRATCH_MNT/test2 >> $seqres.full 2>&1 \
102     || _fail "!!! umount ext2 failed"
103
104 _log "umount xfs"
105 umount $SCRATCH_MNT/test >> $seqres.full 2>&1 \
106     || _fail "!!! umount xfs failed"
107
108 echo "--- mounts at end (before cleanup)" >> $seqres.full
109 mount >> $seqres.full
110
111 # success, all done
112 status=0
113 exit