2 # SPDX-License-Identifier: GPL-2.0+
3 # Copyright (c) 2019, Oracle and/or its affiliates. All Rights Reserved.
7 # Basic tests of the xfs_spaceman health command.
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
24 # get standard environment, filters and checks
29 # real QA test starts here
31 _require_scratch_nocheck
33 _require_xfs_spaceman_command "health"
37 _scratch_mkfs > $seqres.full 2>&1
40 # Haven't checked anything, it should tell us to run scrub
41 $XFS_SPACEMAN_PROG -c "health" $SCRATCH_MNT
43 # Run scrub to collect health info.
44 _scratch_scrub -n >> $seqres.full
47 $XFS_SPACEMAN_PROG -c "$@" $SCRATCH_MNT | tee -a $seqres.full
51 query "$@" | grep -q ": ok$"
55 query "$@" | grep -q ": unhealthy$"
58 # Let's see if we get at least one healthy rating for each health reporting
60 query_health "health -f" || \
61 echo "Didn't see a single healthy fs metadata?"
63 query_health "health -a 0" || \
64 echo "Didn't see a single healthy ag metadata?"
66 query_health "health $SCRATCH_MNT" || \
67 echo "Didn't see a single healthy file metadata?"
69 # Unmount, corrupt filesystem
71 _scratch_xfs_db -x -c 'sb 1' -c 'fuzz -d magicnum random' >> $seqres.full
73 # Now let's see what the AG report says
75 _scratch_scrub -n >> $seqres.full 2>&1
76 query_sick "health -a 1" || \
77 echo "Didn't see the expected unhealthy metadata?"