overlay: run unionmount testsuite test cases
[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 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
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 here=`pwd`
28 tmp=/tmp/$$
29 status=1        # failure is the default!
30 trap "_cleanup ; exit \$status" 0 1 2 3 15
31
32 # get standard environment, filters and checks
33 . ./common/rc
34 . ./common/filter
35
36 # real QA test starts here
37 _supported_fs xfs
38 _supported_os Linux
39
40 _log()
41 {
42     echo "--- $*"
43     echo "--- $*" >> $seqres.full
44 }
45
46 _require_nonexternal
47 _require_scratch_nocheck
48 _require_no_large_scratch_dev
49 _require_loop
50 _require_ext2
51
52 rm -f $seqres.full
53
54 echo "(dev=$SCRATCH_DEV, mount=$SCRATCH_MNT)" >> $seqres.full
55 echo "" >> $seqres.full
56
57 echo "--- mounts" >> $seqres.full
58 mount >> $seqres.full
59
60 _log "Create ext2 fs on scratch"
61 mkfs -t ext2 -F $SCRATCH_DEV >> $seqres.full 2>&1 \
62     || _fail "!!! failed to mkfs ext2"
63
64 _log "Mount ext2 fs on scratch"
65 mount -t ext2 $SCRATCH_DEV $SCRATCH_MNT >> $seqres.full 2>&1 \
66     || _fail "!!! failed to mount"
67
68 _log "Create xfs fs in file on scratch"
69 ${MKFS_XFS_PROG} -f -dfile,name=$SCRATCH_MNT/test.xfs,size=40m \
70     >> $seqres.full 2>&1 \
71     || _fail "!!! failed to mkfs xfs"
72
73 _log "Make mount points"
74 mkdir $SCRATCH_MNT/test $SCRATCH_MNT/test2 >> $seqres.full 2>&1 \
75     || _fail "!!! failed to make mount points"
76
77 _log "Mount xfs via loop"
78 mount -t xfs -o loop $SCRATCH_MNT/test.xfs $SCRATCH_MNT/test >> $seqres.full 2>&1 \
79     || _fail "!!! failed to loop mount xfs"
80
81 _log "stress"
82 $FSSTRESS_PROG -d $SCRATCH_MNT/test -n 1000 $FSSTRESS_AVOID >> $seqres.full 2>&1 \
83     || _fail "!!! stress failed"
84
85 _log "clean"
86 rm -rf $SCRATCH_MNT/test/* >> $seqres.full 2>&1 \
87     || _fail "!!! clean failed"
88
89 _log "create file for ext2 fs"
90 dd if=/dev/zero of=$SCRATCH_MNT/test/test.ext2 bs=1024 count=10240 >> $seqres.full 2>&1 \
91     || _fail "!!! create file failed"
92
93 _log "Create ext2 fs in file on looped xfs"
94 echo y | mkfs -t ext2 $SCRATCH_MNT/test/test.ext2 >> $seqres.full 2>&1 \
95     || _fail "!!! failed to mkfs ext2 on xfs"
96
97 _log "Mount ext2 on xfs via loop"
98 mount -t ext2 -o loop $SCRATCH_MNT/test/test.ext2 $SCRATCH_MNT/test2 >> $seqres.full 2>&1 \
99     || _fail "!!! failed to loop mount xfs"
100
101 _log "stress ext2 on xfs via loop"
102 $FSSTRESS_PROG -d $SCRATCH_MNT/test2 -n 1000 $FSSTRESS_AVOID >> $seqres.full 2>&1 \
103     || _fail "!!! stress ext2 failed"
104
105 _log "clean"
106 rm -rf $SCRATCH_MNT/test/* >> $seqres.full 2>&1 \
107     || _fail "!!! clean failed"
108
109 _log "umount ext2 on xfs"
110 umount $SCRATCH_MNT/test2 >> $seqres.full 2>&1 \
111     || _fail "!!! umount ext2 failed"
112
113 _log "umount xfs"
114 umount $SCRATCH_MNT/test >> $seqres.full 2>&1 \
115     || _fail "!!! umount xfs failed"
116
117 echo "--- mounts at end (before cleanup)" >> $seqres.full
118 mount >> $seqres.full
119
120 # success, all done
121 status=0
122 exit