Path: blob/main/tools/test/stress2/misc/buildworld3.sh
39536 views
#!/bin/sh12#3# SPDX-License-Identifier: BSD-2-Clause4#5# Copyright (c) 2018 Dell EMC Isilon6#7# Redistribution and use in source and binary forms, with or without8# modification, are permitted provided that the following conditions9# are met:10# 1. Redistributions of source code must retain the above copyright11# notice, this list of conditions and the following disclaimer.12# 2. Redistributions in binary form must reproduce the above copyright13# notice, this list of conditions and the following disclaimer in the14# documentation and/or other materials provided with the distribution.15#16# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND17# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE18# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE19# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE20# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL21# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS22# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)23# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT24# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF26# SUCH DAMAGE.27#2829# Buildworld / quota test scenario.3031# "panic: chkdquot: missing dquot" seen32# https://people.freebsd.org/~pho/stress/log/kostik1113.txt33# Fixed in r338798 + r3387993435. ../default.cfg3637[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 13839[ "`sysctl -in kern.features.ufs_quota`" != "1" ] && exit 040[ -d /usr/src/sys ] || exit 041mount | grep -q "on $mntpoint " && umount $mntpoint42mdconfig -a -t swap -s 2g -u $mdstart43newfs $newfs_flags md$mdstart > /dev/null4445export PATH_FSTAB=/tmp/fstab46trap "rm -f $PATH_FSTAB" EXIT INT47echo "/dev/md$mdstart $mntpoint ufs rw,userquota 2 2" > $PATH_FSTAB48mount $mntpoint49set `df -ik $mntpoint | tail -1 | awk '{print $4,$7}'`50export QK=$(($1 / 2))51export QI=$(($2 / 2))52edquota -u -f $mntpoint -e \53${mntpoint}:$((QK - 50)):$QK:$((QI - 50 )):$QI $testuser54quotaon $mntpoint55mount | grep $mntpoint5657cd /usr/src58export MAKEOBJDIRPREFIX=$mntpoint/obj59export TMPDIR=$mntpoint/tmp60mkdir $TMPDIR $MAKEOBJDIRPREFIX61chmod 0777 $TMPDIR $MAKEOBJDIRPREFIX6263p=$((`sysctl -n hw.ncpu`+ 1))64[ $p -gt 32 ] && p=32 # Arbitrary cap65su $testuser -c \66"make -i -j $p buildworld DESTDIR=$mntpoint TARGET=amd64 \67TARGET_ARCH=amd64 > /dev/null" &68sleep 269start=`date +%s`70while [ $((`date +%s` - start)) -lt 1200 ]; do71kill -0 $! > /dev/null 2>&1 || break72sleep 273done74kill $! > /dev/null 2>&175# Let make run 50% of the time so quotaoff runs on an active FS76[ `jot -r 1 0 1` -eq 1 ] &&77pkill -U$testuser make78wait7980while ! quotaoff $mntpoint; do81sync82sleep 583done84pgrep -q -U$testuser make && pkill -U$testuser make85export tmp=/tmp/$(basename $0).$$86quotacheck -v $mntpoint > $tmp 2>&187grep -q failed $tmp && { cat $tmp; s=1; }88while mount | grep -q "on $mntpoint "; do89umount $mntpoint || sleep 190done91checkfs /dev/md$mdstart || s=$?92mdconfig -d -u $mdstart93rm -f $PATH_FSTAB94exit $s959697