dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / test / zfs-tests / tests / functional / mdb / mdb_001_pos.ksh
blob7f6faf690e8e9ba513ac611c7f4df95ed1b4e69d
1 #!/bin/ksh -p
3 # CDDL HEADER START
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
20 # CDDL HEADER END
24 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
32 . $STF_SUITE/include/libtest.shlib
35 # DESCRIPTION:
36 # Verify that the ZFS mdb dcmds and walkers are working as expected.
38 # STRATEGY:
39 # 1) Given a list of dcmds and walkers
40 # 2) Step through each element of the list
41 # 3) Verify the output by checking for "mdb:" in the output string
44 function cleanup
46 rm -f $OUTFILE
49 verify_runnable "global"
50 log_onexit cleanup
52 tmpfile=$(mktemp)
53 log_must zpool scrub $TESTPOOL
55 typeset spa=$(mdb -ke "::spa" | awk "/$TESTPOOL/ {print \$1}")
56 typeset off_ub=$(mdb -ke "::offsetof spa_t spa_uberblock | =J")
57 typeset off_rbp=$(mdb -ke "::offsetof uberblock_t ub_rootbp | =J")
58 typeset bp=$(mdb -ke "$spa + $off_ub + $off_rbp =J")
60 # dcmds and walkers skipped due to being DEBUG only or difficult to run:
61 # ::zfs_params
62 # ::refcount
64 set -A dcmds "::abuf_find 1 2" \
65 "::arc" \
66 "::arc -b" \
67 "::arc_compression_stats" \
68 "$bp ::blkptr" \
69 "$bp ::dva" \
70 "::walk spa" \
71 "::spa" \
72 "$spa ::spa " \
73 "$spa ::spa -c" \
74 "$spa ::spa -h" \
75 "$spa ::spa -v" \
76 "$spa ::spa -Mmh" \
77 "$spa ::spa_config" \
78 "$spa ::spa_space" \
79 "$spa ::spa_space -b" \
80 "$spa ::spa_vdevs" \
81 "$spa ::print spa_t spa_root_vdev | ::vdev" \
82 "$spa ::print spa_t spa_root_vdev | ::vdev -re" \
83 "$spa ::print -a spa_t spa_dsl_pool->dp_dirty_datasets | ::walk txg_list" \
84 "$spa ::print -a spa_t spa_uberblock.ub_rootbp | ::blkptr" \
85 "$spa ::walk metaslab" \
86 "$spa ::walk metaslab | ::head -1 | ::metaslab_weight" \
87 "$spa ::walk metaslab | ::head -1 | ::metaslab_trace" \
88 "$spa ::walk zio_root | ::zio -c" \
89 "$spa ::walk zio_root | ::zio -r" \
90 "$spa ::walk zms_freelist"
91 "$spa ::zfs_blkstats -v" \
92 "::dbufs" \
93 "::dbufs -n mos -o mdn -l 0 -b 0" \
94 "::dbufs | ::dbuf" \
95 "::dbuf_stats" \
96 "dbuf_cache ::walk multilist"
98 # The commands above were supplied by the ZFS development team. The idea is to
99 # do as much checking as possible without the need to hardcode addresses.
102 log_assert "Verify that the ZFS mdb dcmds and walkers are working as expected."
104 typeset -i RET=0
107 while (( $i < ${#dcmds[*]} )); do
108 log_note "Verifying: '${dcmds[i]}'"
109 echo "${dcmds[i]}" | mdb -k > $OUTFILE 2>&1
110 RET=$?
111 if (( $RET != 0 )); then
112 log_fail "mdb '${dcmds[i]}' returned error $RET"
116 # mdb prefixes all errors with "mdb: " so we check the output.
118 grep "mdb:" $OUTFILE > /dev/null 2>&1
119 RET=$?
120 if (( $RET == 0 )); then
121 echo "mdb '${dcmds[i]}' contained 'mdb:'"
122 # Using tail limits the number of lines in the log
123 tail -100 $OUTFILE
124 log_fail "mdb walker or dcmd failed"
127 ((i = i + 1))
128 done
130 log_pass "The ZFS mdb dcmds and walkers are working as expected."