btrfs/012: check free size of scratch device before copying files
[xfstests-dev.git] / tests / xfs / 262
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 262
6 #
7 # Copy xfs_scrub to the scratch device, then run xfs_scrub in forced
8 # repair mode (which will rebuild the data forks of the running scrub
9 # executable and libraries!) to see what happens.
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 "_cleanup; exit \$status" 0 1 2 3 7 15
19
20 _cleanup()
21 {
22         cd /
23         rm -rf $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29 . ./common/fuzzy
30 . ./common/inject
31
32 # real QA test starts here
33 _supported_fs xfs
34 _require_command "$LDD_PROG" ldd
35 _require_scrub
36 _require_scratch
37 # xfs_scrub will turn on error injection itself
38 _require_xfs_io_error_injection "force_repair"
39
40 echo "Format and populate"
41 _scratch_mkfs > "$seqres.full" 2>&1
42 _scratch_mount
43 cp $XFS_SCRUB_PROG $SCRATCH_MNT/xfs_scrub
44 $LDD_PROG $XFS_SCRUB_PROG | sed -e '/\//!d;/linux-gate/d;/=>/ {s/.*=>[[:blank:]]*\([^[:blank:]]*\).*/\1/};s/[[:blank:]]*\([^[:blank:]]*\) (.*)/\1/' | while read lib; do
45         cp $lib $SCRATCH_MNT/
46 done
47 LD_LIBRARY_PATH=$SCRATCH_MNT $LDD_PROG $SCRATCH_MNT/xfs_scrub >> $seqres.full
48
49 echo "Force online repairs"
50 XFS_SCRUB_FORCE_REPAIR=1 LD_LIBRARY_PATH=$SCRATCH_MNT $SCRATCH_MNT/xfs_scrub -dTv $SCRATCH_MNT >> $seqres.full
51
52 # success, all done
53 status=0
54 exit