git: a68d11d310dd - main - stress2: Fix script bugs in gnop6.sh, gnop7.sh and fdatasync*.sh

From: Maxim Sobolev <sobomax_at_FreeBSD.org>
Date: Thu, 01 Oct 2026 16:27:50 UTC
The branch main has been updated by sobomax:

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

commit a68d11d310dd5100a18f187c1108df6703315989
Author:     Maxim Sobolev <sobomax@FreeBSD.org>
AuthorDate: 2026-10-01 16:26:06 +0000
Commit:     Maxim Sobolev <sobomax@FreeBSD.org>
CommitDate: 2026-10-01 16:26:06 +0000

    stress2: Fix script bugs in gnop6.sh, gnop7.sh and fdatasync*.sh
    
    gnop6.sh recorded the checkfs result with "checkfs ... || s=1 && s=0",
    which the shell parses as "(checkfs || s=1) && s=0", so the test passed
    even when the file system check failed.
    
    gnop7.sh only sets s when unmount or fsck_ffs fails and ends with
    "exit $s".  On a clean run s is unset, and the script exits with the
    status of the preceding "[ $notloaded ] && gnop unload", which is 1
    whenever geom_nop was already loaded, for instance by an earlier test.
    
    fdatasync.sh and fdatasync2.sh ran "df -i $RUNDIR" before creating the
    directory.  With a RUNDIR that does not exist yet, df failed, the test
    printed "[: -lt: unexpected operator" and the free inode check was
    skipped.
    
    Reviewed by:    pho
    Differential Revision:  https://reviews.freebsd.org/D60136
    Sponsored by:   Sippy Software, Inc.
    MFC after:      2 weeks
---
 tools/test/stress2/misc/fdatasync.sh  | 3 +--
 tools/test/stress2/misc/fdatasync2.sh | 3 +--
 tools/test/stress2/misc/gnop6.sh      | 2 +-
 tools/test/stress2/misc/gnop7.sh      | 1 +
 4 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/tools/test/stress2/misc/fdatasync.sh b/tools/test/stress2/misc/fdatasync.sh
index 9abd31e5bd94..28397f39252d 100755
--- a/tools/test/stress2/misc/fdatasync.sh
+++ b/tools/test/stress2/misc/fdatasync.sh
@@ -37,6 +37,7 @@
 
 dir=$RUNDIR
 nfiles=500
+mkdir -p $dir && chmod 777 $dir
 [ `df -i $dir | tail -1 | awk '{print $7}'` -lt $nfiles ] && exit 0
 
 odir=`pwd`
@@ -46,8 +47,6 @@ rm -f /tmp/fdatasync
 mycc -o fdatasync -Wall -Wextra -O2 -g fdatasync.c -lpthread || exit 1
 rm -f fdatasync.c
 
-mkdir -p $dir && chmod 777 $dir
-
 cd $dir
 jot $nfiles | xargs touch
 jot $nfiles | xargs chmod 666
diff --git a/tools/test/stress2/misc/fdatasync2.sh b/tools/test/stress2/misc/fdatasync2.sh
index 42ade0cedbd3..d790885baf1a 100755
--- a/tools/test/stress2/misc/fdatasync2.sh
+++ b/tools/test/stress2/misc/fdatasync2.sh
@@ -35,6 +35,7 @@
 
 dir=$RUNDIR
 nfiles=10000
+mkdir -p $dir && chmod 777 $dir
 [ `df -i $dir | tail -1 | awk '{print $7}'` -lt $nfiles ] && exit 0
 
 odir=`pwd`
@@ -44,8 +45,6 @@ rm -f /tmp/fdatasync2
 mycc -o fdatasync2 -Wall -Wextra -O2 -g fdatasync2.c -lpthread || exit 1
 rm -f fdatasync2.c
 
-mkdir -p $dir && chmod 777 $dir
-
 cd $dir
 jot $nfiles | xargs touch
 jot $nfiles | xargs chmod 666
diff --git a/tools/test/stress2/misc/gnop6.sh b/tools/test/stress2/misc/gnop6.sh
index 4d32f584662e..f7a49251cf72 100755
--- a/tools/test/stress2/misc/gnop6.sh
+++ b/tools/test/stress2/misc/gnop6.sh
@@ -60,7 +60,7 @@ su $testuser -c 'cd ..; ./run.sh marcus.cfg' > /dev/null 2>&1
 while mount | grep $mntpoint | grep -q /dev/md; do
 	umount $mntpoint || sleep 1
 done
-checkfs /dev/md$mdstart.nop || s=1 && s=0
+checkfs /dev/md$mdstart.nop; s=$?
 gnop destroy /dev/md$mdstart.nop
 mdconfig -d -u $mdstart
 
diff --git a/tools/test/stress2/misc/gnop7.sh b/tools/test/stress2/misc/gnop7.sh
index 76008aabe925..44de25e1cf56 100755
--- a/tools/test/stress2/misc/gnop7.sh
+++ b/tools/test/stress2/misc/gnop7.sh
@@ -49,6 +49,7 @@ newfs $newfs_flags /dev/md$mdstart.nop > /dev/null
 mount /dev/md$mdstart.nop $mntpoint
 chmod 777 $mntpoint
 set +e
+s=0
 
 export runRUNTIME=3m
 export RUNDIR=$mntpoint/stressX