git: f6fd5af80a37 - main - stress2: Do not wait forever for swap usage

From: Peter Holm <pho_at_FreeBSD.org>
Date: Fri, 30 Aug 2024 08:05:35 UTC
The branch main has been updated by pho:

URL: https://cgit.FreeBSD.org/src/commit/?id=f6fd5af80a37ef0560959bd55c2c86d17ee2033f

commit f6fd5af80a37ef0560959bd55c2c86d17ee2033f
Author:     Peter Holm <pho@FreeBSD.org>
AuthorDate: 2024-08-30 08:04:46 +0000
Commit:     Peter Holm <pho@FreeBSD.org>
CommitDate: 2024-08-30 08:04:46 +0000

    stress2: Do not wait forever for swap usage
---
 tools/test/stress2/misc/mmap40.sh | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/tools/test/stress2/misc/mmap40.sh b/tools/test/stress2/misc/mmap40.sh
index 7f4d07885e05..2314596e2f5d 100755
--- a/tools/test/stress2/misc/mmap40.sh
+++ b/tools/test/stress2/misc/mmap40.sh
@@ -53,13 +53,14 @@ mount /dev/md$mdstart $mntpoint
 set +e
 
 u1=`swapinfo | tail -1 | awk '{print $3}'`
-(nice $odir/../testcases/swap/swap -t 10m -i 30 -h -l 100) &
-while [ $((`swapinfo | tail -1 | awk '{print $3}'` - $u1)) -le 100 ]; do
+(nice $odir/../testcases/swap/swap -t 10m -i 30 -h -l 100) > /dev/null &
+for i in `jot 120`; do
+	u2=`swapinfo | tail -1 | awk '{print $3}'`
+	[ $u2 -lt $u1 ] && u1=$u2
+	[ $((u2 - $u1)) -gt 100 ] && break
 	sleep 1
 done
-
-$dir/mmap40
-s=0
+/usr/bin/timeout 10m $dir/mmap40; s=$?
 while pkill swap; do :; done
 wait
 [ -f mmap40.core -a $s -eq 0 ] &&