xref: /freebsd/tools/test/stress2/misc/1st.sh (revision 43a5ec4eb41567cc92586503212743d89686d78f)
1#!/bin/sh
2
3#
4# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
5#
6# Copyright (c) 2021 Peter Holm <pho@FreeBSD.org>
7#
8# Redistribution and use in source and binary forms, with or without
9# modification, are permitted provided that the following conditions
10# are met:
11# 1. Redistributions of source code must retain the above copyright
12#    notice, this list of conditions and the following disclaimer.
13# 2. Redistributions in binary form must reproduce the above copyright
14#    notice, this list of conditions and the following disclaimer in the
15#    documentation and/or other materials provided with the distribution.
16#
17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27# SUCH DAMAGE.
28#
29
30# stress2 config test:
31# Check that diskimage and RUNDIR has not been clobbered in `hostname`.
32# Variables must be set like this: var=${var:-value}
33
34export diskimage=dummy
35export RUNDIR=dummy
36. ../default.cfg
37
38[ "`sysctl -in debug.vmem_check`" = "1" ] &&
39    echo "debug.vmem_check must be set to 0"
40[ "`sysctl -in debug.vmmap_check`" = "0" ] &&
41    echo "debug.vmmap_check must be set to 1"
42
43if [ "$diskimage" != "dummy" ]; then
44	echo "FATAL: diskimage was overwritten with \"$diskimage\""
45	exit 1
46fi
47if [ "$RUNDIR" != "dummy" ]; then
48	echo "FATAL: RUNDIR was overwritten with \"$RUNDIR\""
49	exit 1
50fi
51if [ "`dirname $mntpoint`" != "/" ]; then
52	echo "FATAL: mntpoint \"$mntpoint\" must be a root directory"
53	exit 1
54fi
55[ -z "`which ruby 2>/dev/null`" ] && echo "Consider installing ruby"
56[ -z "`type mke2fs 2>/dev/null`" ] && echo "Consider installing e2fsprogs"
57[ -z "`type mkisofs 2>/dev/null`" ] && echo "Consider installing cdrtools"
58[ -z "`type mDNSNetMonitor 2>/dev/null`" ] && echo "Consider installing mDNSResponder"
59[ ! -x /usr/local/lib/libmill.so ] && echo "Consider installing libmill"
60
61# Random sanity checks
62
63df -k $(dirname $diskimage) | tail -1 | awk '{print $4}' |
64    grep -Eq '^[0-9]+$' || { echo FATAL; df -k $(dirname $diskimage); }
65
66grep -Eq "^discard" /etc/inetd.conf ||
67    echo "Discard is not enabled in /etc/inetd.conf"
68pgrep -Sq inetd || echo "inetd is not running"
69
70[ `sysctl -n kern.maxvnodes` -le 2000 ] &&
71    echo "FATAL kern.maxvnodes is too small"
72
73exit 0
74