overlay: run unionmount testsuite test cases
[xfstests-dev.git] / tests / xfs / 506
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0+
3 # Copyright (c) 2019, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 506
6 #
7 # Basic tests of the xfs_spaceman health command.
8
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1    # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         cd /
21         rm -f $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/fuzzy
27 . ./common/filter
28
29 # real QA test starts here
30 _supported_fs xfs
31 _supported_os Linux
32 _require_scratch_nocheck
33 _require_scrub
34 _require_xfs_spaceman_command "health"
35
36 rm -f $seqres.full
37
38 _scratch_mkfs > $seqres.full 2>&1
39 _scratch_mount
40
41 # Haven't checked anything, it should tell us to run scrub
42 $XFS_SPACEMAN_PROG -c "health" $SCRATCH_MNT
43
44 # Run scrub to collect health info.
45 _scratch_scrub -n >> $seqres.full
46
47 query() {
48         $XFS_SPACEMAN_PROG -c "$@" $SCRATCH_MNT | tee -a $seqres.full
49 }
50
51 query_health() {
52         query "$@" | grep -q ": ok$"
53 }
54
55 query_sick() {
56         query "$@" | grep -q ": unhealthy$"
57 }
58
59 # Let's see if we get at least one healthy rating for each health reporting
60 # group.
61 query_health "health -f" || \
62         echo "Didn't see a single healthy fs metadata?"
63
64 query_health "health -a 0" || \
65         echo "Didn't see a single healthy ag metadata?"
66
67 query_health "health $SCRATCH_MNT" || \
68         echo "Didn't see a single healthy file metadata?"
69
70 # Unmount, corrupt filesystem
71 _scratch_unmount
72 _scratch_xfs_db -x -c 'sb 1' -c 'fuzz -d magicnum random' >> $seqres.full
73
74 # Now let's see what the AG report says
75 _scratch_mount
76 _scratch_scrub -n >> $seqres.full 2>&1
77 query_sick "health -a 1" || \
78         echo "Didn't see the expected unhealthy metadata?"
79
80 # success, all done
81 status=0
82 exit