xref: /freebsd/tools/test/stress2/misc/all.debug.inc (revision 9768746b)
1#
2# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
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# $FreeBSD$
28#
29
30# Example debug include file for misc/all.sh
31
32pre_debug() {
33	debug_statfs=`vmstat -m | grep -w statfs | awk '{print $2}'`
34	debug_freework=`vmstat -m | grep -w freework | awk '{print $2}'`
35	debug_newblk=`vmstat -m | grep -w newblk | awk '{print $2}'`
36	debug_pts=`vmstat -m | grep -w pts | awk '{print $2}'`
37	debug_routetbl=`vmstat -m | grep -w routetbl | awk '{print $2}'`
38	debug_mount=`vmstat -m | awk '/  mount/{print $2}'`
39	debug_geom=`vmstat -m | grep -w GEOM | awk '{print $2}'`
40#	debug_indirdep=`vmstat -m | grep -w indirdep | awk '{print $2}'`
41}
42
43post_debug() {
44	local debug_new
45
46	debug_new=`vmstat -m | grep -w statfs | awk '{print $2}'`
47	[ $((debug_new - debug_statfs)) -gt 0 ] &&
48	    { printf "stress2: statfs leak: %d/%d.\r\n" \
49	        $((debug_new - debug_statfs)) $debug_new > $console
50		debug_statfs=$debug_new; }
51
52	debug_new=`vmstat -m | grep -w freework | awk '{print $2}'`
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	[ $((debug_new - debug_newblk)) -gt 0 -a $debug_new -gt 100 ] &&
60	    { printf "stress2: newblk leak: %d/%d.\r\n" \
61	        $((debug_new - debug_newblk)) $debug_new > $console
62		debug_newblk=$debug_new; }
63
64	debug_new=`vmstat -m | grep -w pts | awk '{print $2}'`
65	[ $((debug_new - debug_pts)) -gt 0 ] &&
66	    { printf "stress2: pts leak: %d/%d\r\n" \
67	        $((debug_new - debug_pts)) $debug_new > $console
68		debug_pts=$debug_new; }
69
70	debug_new=`vmstat -m | grep -w routetbl | awk '{print $2}'`
71	[ $((debug_new - debug_routetbl)) -gt 0 ] &&
72	    { printf "stress2: routetbl leak: %d/%d\r\n" \
73	        $((debug_new - debug_routetbl)) $debug_new > $console
74		debug_routetbl=$debug_new; }
75
76	debug_new=`vmstat -m | awk '/  mount/{print $2}'`
77	[ $((debug_new - debug_mount)) -gt 0 ] &&
78	    { printf "stress2: mount leak: %d/%d\r\n" \
79	        $((debug_new - debug_mount)) $debug_new > $console
80		debug_mount=$debug_new; }
81
82	debug_new=`vmstat -m | awk '/GEOM/{print $2}'`
83	[ $((debug_new - debug_geom)) -gt 0 ] &&
84	    { printf "stress2: GEOM leak: %d/%d\r\n" \
85	        $((debug_new - debug_geom)) $debug_new > $console
86		debug_geom=$debug_new; }
87
88#	debug_new=`vmstat -m | awk '/indirdep/{print $2}'`
89#	[ $((debug_new - debug_indirdep)) -gt 100 -a $debug_new -gt 100 ] &&
90#	    { printf "stress2: indirdep leak: %d/%d\r\n" \
91#	        $((debug_new - debug_indirdep)) $debug_new > $console
92#		debug_indirdep=$debug_new; }
93}
94
95all_debug=1
96