xref: /freebsd/tools/test/stress2/misc/buildworld3.sh (revision 19261079b74319502c6ffa1249920079f0f69a72)
1#!/bin/sh
2
3#
4# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
5#
6# Copyright (c) 2018 Dell EMC Isilon
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# Buildworld / quota test scenario.
31
32# "panic: chkdquot: missing dquot" seen
33# https://people.freebsd.org/~pho/stress/log/kostik1113.txt
34# Fixed in r338798 + r338799
35
36. ../default.cfg
37
38[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
39
40[ "`sysctl -in kern.features.ufs_quota`" != "1" ] && exit 0
41[ -d /usr/src/sys ] || exit 0
42mount | grep -q "on $mntpoint " && umount $mntpoint
43mdconfig -a -t swap -s 2g -u $mdstart
44bsdlabel -w md$mdstart auto
45newfs $newfs_flags md${mdstart}$part > /dev/null
46
47export PATH_FSTAB=/tmp/fstab
48trap "rm -f $PATH_FSTAB" EXIT INT
49echo "/dev/md${mdstart}$part $mntpoint ufs rw,userquota 2 2" > $PATH_FSTAB
50mount $mntpoint
51set `df -ik $mntpoint | tail -1 | awk '{print $4,$7}'`
52export QK=$(($1 / 2))
53export QI=$(($2 / 2))
54edquota -u -f $mntpoint -e \
55    ${mntpoint}:$((QK - 50)):$QK:$((QI - 50 )):$QI $testuser
56quotaon $mntpoint
57mount | grep $mntpoint
58
59cd /usr/src
60export MAKEOBJDIRPREFIX=$mntpoint/obj
61export TMPDIR=$mntpoint/tmp
62mkdir $TMPDIR $MAKEOBJDIRPREFIX
63chmod 0777 $TMPDIR $MAKEOBJDIRPREFIX
64
65p=$((`sysctl -n hw.ncpu`+ 1))
66su $testuser -c \
67    "make -i -j $p buildworld  DESTDIR=$mntpoint TARGET=amd64 \
68    TARGET_ARCH=amd64 > /dev/null" &
69sleep 2
70start=`date +%s`
71while [ $((`date +%s` - start)) -lt 1200 ]; do
72	kill -0 $! > /dev/null 2>&1 || break
73	sleep 2
74done
75kill $! > /dev/null 2>&1
76# Let make run 50% of the time so quotaoff runs on an active FS
77[ `jot -r 1 0 1` -eq 1 ] &&
78	pkill -U$testuser make
79wait
80
81while ! quotaoff $mntpoint; do
82	sync
83	sleep 5
84done
85pgrep -q -U$testuser make && pkill -U$testuser make
86export tmp=/tmp/$(basename $0).$$
87quotacheck -v $mntpoint > $tmp 2>&1
88grep -q failed $tmp && { cat $tmp; s=1; }
89while mount | grep -q "on $mntpoint "; do
90	umount $mntpoint || sleep 1
91done
92checkfs /dev/md$mdstart || s=$?
93mdconfig -d -u $mdstart
94rm -f $PATH_FSTAB
95exit $s
96