xref: /freebsd/tools/test/stress2/misc/all.debug.inc (revision e0c4386e)
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	[ $((debug_new - debug_freework)) -gt 0 -a $debug_new -gt 100 ] &&
53	    { printf "stress2: freework leak: %d/%d.\r\n" \
54	        $((debug_new - debug_freework)) $debug_new > $console
55		debug_freework=$debug_new; }
56
57	debug_new=`vmstat -m | grep -w newblk | awk '{print $2}'`
58	[ $((debug_new - debug_newblk)) -gt 0 -a $debug_new -gt 100 ] &&
59	    { printf "stress2: newblk leak: %d/%d.\r\n" \
60	        $((debug_new - debug_newblk)) $debug_new > $console
61		debug_newblk=$debug_new; }
62
63	debug_new=`vmstat -m | grep -w pts | awk '{print $2}'`
64	[ $((debug_new - debug_pts)) -gt 0 ] &&
65	    { printf "stress2: pts leak: %d/%d\r\n" \
66	        $((debug_new - debug_pts)) $debug_new > $console
67		debug_pts=$debug_new; }
68
69	debug_new=`vmstat -m | grep -w routetbl | awk '{print $2}'`
70	[ $((debug_new - debug_routetbl)) -gt 0 ] &&
71	    { printf "stress2: routetbl leak: %d/%d\r\n" \
72	        $((debug_new - debug_routetbl)) $debug_new > $console
73		debug_routetbl=$debug_new; }
74
75	debug_new=`vmstat -m | awk '/  mount/{print $2}'`
76	[ $((debug_new - debug_mount)) -gt 0 ] &&
77	    { printf "stress2: mount leak: %d/%d\r\n" \
78	        $((debug_new - debug_mount)) $debug_new > $console
79		debug_mount=$debug_new; }
80
81	debug_new=`vmstat -m | awk '/GEOM/{print $2}'`
82	[ $((debug_new - debug_geom)) -gt 0 ] &&
83	    { printf "stress2: GEOM leak: %d/%d\r\n" \
84	        $((debug_new - debug_geom)) $debug_new > $console
85		debug_geom=$debug_new; }
86
87#	debug_new=`vmstat -m | awk '/indirdep/{print $2}'`
88#	[ $((debug_new - debug_indirdep)) -gt 100 -a $debug_new -gt 100 ] &&
89#	    { printf "stress2: indirdep leak: %d/%d\r\n" \
90#	        $((debug_new - debug_indirdep)) $debug_new > $console
91#		debug_indirdep=$debug_new; }
92}
93
94all_debug=1
95