Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/tools/test/stress2/misc/buildworld3.sh
39536 views
1
#!/bin/sh
2
3
#
4
# SPDX-License-Identifier: BSD-2-Clause
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
42
mount | grep -q "on $mntpoint " && umount $mntpoint
43
mdconfig -a -t swap -s 2g -u $mdstart
44
newfs $newfs_flags md$mdstart > /dev/null
45
46
export PATH_FSTAB=/tmp/fstab
47
trap "rm -f $PATH_FSTAB" EXIT INT
48
echo "/dev/md$mdstart $mntpoint ufs rw,userquota 2 2" > $PATH_FSTAB
49
mount $mntpoint
50
set `df -ik $mntpoint | tail -1 | awk '{print $4,$7}'`
51
export QK=$(($1 / 2))
52
export QI=$(($2 / 2))
53
edquota -u -f $mntpoint -e \
54
${mntpoint}:$((QK - 50)):$QK:$((QI - 50 )):$QI $testuser
55
quotaon $mntpoint
56
mount | grep $mntpoint
57
58
cd /usr/src
59
export MAKEOBJDIRPREFIX=$mntpoint/obj
60
export TMPDIR=$mntpoint/tmp
61
mkdir $TMPDIR $MAKEOBJDIRPREFIX
62
chmod 0777 $TMPDIR $MAKEOBJDIRPREFIX
63
64
p=$((`sysctl -n hw.ncpu`+ 1))
65
[ $p -gt 32 ] && p=32 # Arbitrary cap
66
su $testuser -c \
67
"make -i -j $p buildworld DESTDIR=$mntpoint TARGET=amd64 \
68
TARGET_ARCH=amd64 > /dev/null" &
69
sleep 2
70
start=`date +%s`
71
while [ $((`date +%s` - start)) -lt 1200 ]; do
72
kill -0 $! > /dev/null 2>&1 || break
73
sleep 2
74
done
75
kill $! > /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
79
wait
80
81
while ! quotaoff $mntpoint; do
82
sync
83
sleep 5
84
done
85
pgrep -q -U$testuser make && pkill -U$testuser make
86
export tmp=/tmp/$(basename $0).$$
87
quotacheck -v $mntpoint > $tmp 2>&1
88
grep -q failed $tmp && { cat $tmp; s=1; }
89
while mount | grep -q "on $mntpoint "; do
90
umount $mntpoint || sleep 1
91
done
92
checkfs /dev/md$mdstart || s=$?
93
mdconfig -d -u $mdstart
94
rm -f $PATH_FSTAB
95
exit $s
96
97