generic/077: fall back to /usr if /lib/modules doesn't exist
[xfstests-dev.git] / tests / xfs / 302
1 #! /bin/bash
2 # FS QA Test No. 302
3 #
4 # Dump and restore partialmax + 1 wholly-sparse files
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2013 SGI.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #-----------------------------------------------------------------------
22 #
23
24 seq=`basename $0`
25 seqres=$RESULT_DIR/$seq
26 echo "QA output created by $seq"
27
28 here=`pwd`
29 tmp=/tmp/$$
30 status=1        # failure is the default!
31 trap "_cleanup; exit \$status" 0 1 2 3 15
32
33 _cleanup()
34 {
35     cd /
36     rm -f $tmp.*
37 }
38
39 # get standard environment, filters and checks
40 . ./common/rc
41 . ./common/filter
42 . ./common/dump
43
44 # real QA test starts here
45
46 # Modify as appropriate.
47 _supported_fs xfs
48 _supported_os Linux
49 _require_scratch
50
51 rm -f $seqres.full
52
53 echo "Silence is golden."
54 _wipe_fs
55 mkdir $dump_dir >> $seqres.full 2>&1 || _fail "mkdir \"$dump_dir\" failed"
56 for i in `seq 1 4`; do
57         $XFS_IO_PROG -f -c "truncate 1t" $dump_dir/sparsefile$i \
58                 >> $seqres.full 2>&1 || _fail "failed to create sparsefile\"$i\""
59 done
60 # Dump and restore the files
61 _prepare_restore_dir
62 $XFSDUMP_PROG -L session -M label1 -M label2 -f $tmp.stream1 \
63         -f $tmp.stream2 $SCRATCH_MNT -s $dump_sdir \
64         >> $seqres.full 2>&1 || _fail "dump failed"
65 $XFSRESTORE_PROG -F -f $tmp.stream1 -f $tmp.stream2 $restore_dir \
66         >> $seqres.full 2>&1 || _fail "restore failed"
67 status=0
68 exit