xref: /freebsd/tools/test/stress2/misc/all.debug.inc (revision 6e5b990c509777544b790cc8e490965166d04684)
1#
2# SPDX-License-Identifier: BSD-2-Clause
3#
4# Copyright (c) 2020 Peter Holm <pho@FreeBSD.org>
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9# 1. Redistributions of source code must retain the above copyright
10#    notice, this list of conditions and the following disclaimer.
11# 2. Redistributions in binary form must reproduce the above copyright
12#    notice, this list of conditions and the following disclaimer in the
13#    documentation and/or other materials provided with the distribution.
14#
15# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25# SUCH DAMAGE.
26#
27#
28
29# Example debug include file for misc/all.sh
30
31pre_debug() {
32	debug_statfs=`vmstat -m | grep -w statfs | awk '{print $2}'`
33	debug_freework=`vmstat -m | grep -w freework | awk '{print $2}'`
34	debug_newblk=`vmstat -m | grep -w newblk | awk '{print $2}'`
35	debug_pts=`vmstat -m | grep -w pts | awk '{print $2}'`
36	debug_routetbl=`vmstat -m | grep -w routetbl | awk '{print $2}'`
37	debug_mount=`vmstat -m | awk '/  mount/{print $2}'`
38	debug_geom=`vmstat -m | grep -w GEOM | awk '{print $2}'`
39#	debug_indirdep=`vmstat -m | grep -w indirdep | awk '{print $2}'`
40}
41
42post_debug() {
43	local debug_new
44
45	debug_new=`vmstat -m | grep -w statfs | awk '{print $2}'`
46	[ $((debug_new - debug_statfs)) -gt 0 ] &&
47	    { printf "stress2: statfs leak: %d/%d.\r\n" \
48	        $((debug_new - debug_statfs)) $debug_new > $console
49		debug_statfs=$debug_new; }
50
51	debug_new=`vmstat -m | grep -w freework | awk '{print $2}'`
52	[ -n "$debug_new" ] &&
53        [ $((debug_new - debug_freework)) -gt 0 -a $debug_new -gt 100 ] &&
54	    { printf "stress2: freework leak: %d/%d.\r\n" \
55	        $((debug_new - debug_freework)) $debug_new > $console
56		debug_freework=$debug_new; }
57
58	debug_new=`vmstat -m | grep -w newblk | awk '{print $2}'`
59	[ -n "$debug_new" ] &&
60        [ $((debug_new - debug_newblk)) -gt 0 -a $debug_new -gt 100 ] &&
61	    { printf "stress2: newblk leak: %d/%d.\r\n" \
62	        $((debug_new - debug_newblk)) $debug_new > $console
63		debug_newblk=$debug_new; }
64
65	debug_new=`vmstat -m | grep -w pts | awk '{print $2}'`
66	[ $((debug_new - debug_pts)) -gt 0 ] &&
67	    { printf "stress2: pts leak: %d/%d\r\n" \
68	        $((debug_new - debug_pts)) $debug_new > $console
69		debug_pts=$debug_new; }
70
71	debug_new=`vmstat -m | grep -w routetbl | awk '{print $2}'`
72	[ $((debug_new - debug_routetbl)) -gt 0 ] &&
73	    { printf "stress2: routetbl leak: %d/%d\r\n" \
74	        $((debug_new - debug_routetbl)) $debug_new > $console
75		debug_routetbl=$debug_new; }
76
77	debug_new=`vmstat -m | awk '/  mount/{print $2}'`
78	[ $((debug_new - debug_mount)) -gt 0 ] &&
79	    { printf "stress2: mount leak: %d/%d\r\n" \
80	        $((debug_new - debug_mount)) $debug_new > $console
81		debug_mount=$debug_new; }
82
83	debug_new=`vmstat -m | awk '/GEOM/{print $2}'`
84	[ $((debug_new - debug_geom)) -gt 0 ] &&
85	    { printf "stress2: GEOM leak: %d/%d\r\n" \
86	        $((debug_new - debug_geom)) $debug_new > $console
87		debug_geom=$debug_new; }
88
89#	debug_new=`vmstat -m | awk '/indirdep/{print $2}'`
90#	[ $((debug_new - debug_indirdep)) -gt 100 -a $debug_new -gt 100 ] &&
91#	    { printf "stress2: indirdep leak: %d/%d\r\n" \
92#	        $((debug_new - debug_indirdep)) $debug_new > $console
93#		debug_indirdep=$debug_new; }
94}
95
96all_debug=1
97