mirror of
https://github.com/opnsense/src.git
synced 2026-06-14 19:20:18 -04:00
stress2: Add new unionfs test scenarios
This commit is contained in:
parent
f750dce972
commit
02a2005a5a
4 changed files with 297 additions and 0 deletions
86
tools/test/stress2/misc/unionfs15.sh
Executable file
86
tools/test/stress2/misc/unionfs15.sh
Executable file
|
|
@ -0,0 +1,86 @@
|
|||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright (c) 2024 Peter Holm <pho@FreeBSD.org>
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
|
||||
# O_PATH test scenario. Variation of nullfs29.sh
|
||||
|
||||
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||
. ../default.cfg
|
||||
|
||||
md1=$mdstart
|
||||
md2=$((md1 + 1))
|
||||
mp1=/mnt$md1
|
||||
mp2=/mnt$md2
|
||||
mkdir -p $mp1 $mp2
|
||||
set -e
|
||||
for i in $mp1 $mp2; do
|
||||
mount | grep -q "on $i " && umount -f $i
|
||||
done
|
||||
for i in $md1 $md2; do
|
||||
mdconfig -l | grep -q md$i && mdconfig -d -u $i
|
||||
done
|
||||
|
||||
mdconfig -a -t swap -s 2g -u $md1
|
||||
mdconfig -a -t swap -s 2g -u $md2
|
||||
newfs $newfs_flags -n md$md1 > /dev/null
|
||||
newfs $newfs_flags -n md$md2 > /dev/null
|
||||
mount /dev/md$md1 $mp1
|
||||
mount /dev/md$md2 $mp2
|
||||
mount -t unionfs -o noatime $mp1 $mp2
|
||||
set +e
|
||||
|
||||
cat > /tmp/unionfs15.c <<EOF
|
||||
#include <sys/stat.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int
|
||||
main(void) {
|
||||
int new_dir, new_file, ret;
|
||||
struct stat sb;
|
||||
char *dir = "test2";
|
||||
char *path= "test2/what2";
|
||||
|
||||
if (mkdir(dir, 0755) == -1)
|
||||
err(1, "mkdir(test2)");
|
||||
new_dir = openat(AT_FDCWD, dir, O_RDONLY|O_DIRECTORY|O_CLOEXEC|O_PATH, 0700);
|
||||
if (new_dir == -1)
|
||||
err(1, "openat(%s)", dir);
|
||||
|
||||
ret = fstatat(new_dir, "what2", &sb, AT_SYMLINK_NOFOLLOW);
|
||||
if (ret == 0)
|
||||
errx(1, "Expected fstatat() to fail");
|
||||
if (ret == -1 && errno != ENOENT)
|
||||
err(1, "fstatat(%s)", dir);
|
||||
|
||||
close(new_dir);
|
||||
new_file = openat(AT_FDCWD, path, O_WRONLY|O_CREAT|O_EXCL|O_CLOEXEC, 0644);
|
||||
if (new_file== -1)
|
||||
err(1, "openat(%s)", path);
|
||||
}
|
||||
|
||||
EOF
|
||||
mycc -o /tmp/unionfs15 -Wall -Wextra -O2 /tmp/unionfs15.c || exit 1
|
||||
cd $mp2
|
||||
/tmp/unionfs15; s=$?
|
||||
cd $here
|
||||
umount $mp2
|
||||
|
||||
while mount | grep -Eq "on $mp2 .*unionfs"; do
|
||||
umount $mp2 && break
|
||||
sleep 5
|
||||
done
|
||||
umount $mp2
|
||||
umount $mp1
|
||||
mdconfig -d -u $md2
|
||||
mdconfig -d -u $md1
|
||||
rm -f /tmp/unionfs15.c /tmp/unionfs15
|
||||
exit $s
|
||||
65
tools/test/stress2/misc/unionfs16.sh
Executable file
65
tools/test/stress2/misc/unionfs16.sh
Executable file
|
|
@ -0,0 +1,65 @@
|
|||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright (c) 2024 Peter Holm <pho@FreeBSD.org>
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
|
||||
# No problems seen with this test scenario
|
||||
|
||||
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||
. ../default.cfg
|
||||
|
||||
[ -d /usr/src/tools/test/stress2 ] || exit 0
|
||||
prog=$(basename "$0" .sh)
|
||||
log=/tmp/$prog.log
|
||||
md1=$mdstart
|
||||
md2=$((md1 + 1))
|
||||
mp1=/mnt$md1
|
||||
mp2=/mnt$md2
|
||||
s=0
|
||||
|
||||
mkdir -p $mp1 $mp2
|
||||
set -e
|
||||
for i in $mp1 $mp2; do
|
||||
mount | grep -q "on $i " && umount -f $i
|
||||
done
|
||||
for i in $md1 $md2; do
|
||||
mdconfig -l | grep -q md$i && mdconfig -d -u $i
|
||||
done
|
||||
|
||||
mdconfig -a -t swap -s 3g -u $md1
|
||||
mdconfig -a -t swap -s 3g -u $md2
|
||||
newfs $newfs_flags -n md$md1 > /dev/null
|
||||
newfs $newfs_flags -n md$md2 > /dev/null
|
||||
mount /dev/md$md1 $mp1
|
||||
mount /dev/md$md2 $mp2
|
||||
(cd $mp1; cp -a /usr/src/tools/test/stress2 .)
|
||||
(cd $mp2; cp -a /usr/src/tools/test/stress2 .)
|
||||
rm $mp1/stress2/testcases/run/run
|
||||
rm $mp2/stress2/testcases/swap/swap
|
||||
mount -u -o ro $mp1
|
||||
mount -t unionfs -o below $mp1 $mp2
|
||||
rm $mp2/stress2/testcases/mkdir/mkdir
|
||||
chmod 777 $mp2
|
||||
set +e
|
||||
|
||||
(cd $mp2/stress2; make > /dev/null 2>&1)
|
||||
export RUNDIR=$mp2/stressX
|
||||
export runRUNTIME=1m
|
||||
su $testuser -c "cd $mp2/stress2; ./run.sh vfs.cfg" > /dev/null 2>&1
|
||||
umount $mp2
|
||||
|
||||
while mount | grep -Eq "unionfs.* on $mp2 "; do
|
||||
umount $mp2 && break
|
||||
sleep 5
|
||||
done
|
||||
fsck_ffs -fy /dev/md$md2 > $log 2>&1
|
||||
grep -Eq "WAS MODIFIED" $log && { cat $log; s=1; }
|
||||
umount $mp2
|
||||
umount $mp1
|
||||
mdconfig -d -u $md1
|
||||
mdconfig -d -u $md2
|
||||
rm -f $log
|
||||
exit $s
|
||||
73
tools/test/stress2/misc/unionfs17.sh
Executable file
73
tools/test/stress2/misc/unionfs17.sh
Executable file
|
|
@ -0,0 +1,73 @@
|
|||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright (c) 2024 Peter Holm <pho@FreeBSD.org>
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
|
||||
# unionfs(8) test
|
||||
# Variation of unionfs7.sh, but with tmpfs
|
||||
|
||||
# "mkdir: rmdir(d17) Directory not empty" seen.
|
||||
|
||||
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||
. ../default.cfg
|
||||
|
||||
mp1=/mnt$mdstart
|
||||
mp2=/mnt$((mdstart + 1))
|
||||
mkdir -p $mp1 $mp2
|
||||
set -e
|
||||
for i in $mp1 $mp2; do
|
||||
mount | grep -q "on $i " && umount -f $i
|
||||
done
|
||||
|
||||
mount -o size=4g -t tmpfs dummy $mp1
|
||||
mount -o size=4g -t tmpfs dummy $mp2
|
||||
|
||||
mount -t unionfs -o noatime $mp1 $mp2
|
||||
set +e
|
||||
export 'INODES=100000'
|
||||
|
||||
export CTRLDIR=$mp2/stressX.control
|
||||
export INCARNATIONS=10
|
||||
export LOAD=80
|
||||
export RUNDIR=$mp2/stressX
|
||||
export runRUNTIME=5m
|
||||
export rwLOAD=80
|
||||
export symlinkLOAD=80
|
||||
|
||||
export TESTPROGS="
|
||||
testcases/lockf2/lockf2
|
||||
testcases/symlink/symlink
|
||||
testcases/openat/openat
|
||||
testcases/rw/rw
|
||||
testcases/fts/fts
|
||||
testcases/link/link
|
||||
testcases/lockf/lockf
|
||||
testcases/creat/creat
|
||||
testcases/mkdir/mkdir
|
||||
testcases/rename/rename
|
||||
testcases/mkfifo/mkfifo
|
||||
testcases/dirnprename/dirnprename
|
||||
testcases/dirrename/dirrename
|
||||
testcases/swap/swap
|
||||
"
|
||||
|
||||
cp -r ../../stress2 $mp2
|
||||
export TESTPROGS=`echo $TESTPROGS | sed 's/\n/ /g'`
|
||||
|
||||
set +e
|
||||
chmod 777 $mp2
|
||||
su $testuser -c \
|
||||
"(cd $mp2/stress2; ./testcases/run/run $TESTPROGS)"
|
||||
|
||||
while mount | grep -Eq "on $mp2 .*unionfs"; do
|
||||
umount $mp2 && break
|
||||
sleep 5
|
||||
done
|
||||
umount $mp2
|
||||
n=`find $mp1/stressX | wc -l`
|
||||
[ $n -eq 1 ] && s=0 || { find $mp1/stressX -ls | head -12; s=1; }
|
||||
umount $mp1
|
||||
exit $s
|
||||
73
tools/test/stress2/misc/unionfs18.sh
Executable file
73
tools/test/stress2/misc/unionfs18.sh
Executable file
|
|
@ -0,0 +1,73 @@
|
|||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright (c) 2024 Peter Holm <pho@FreeBSD.org>
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
|
||||
# Simple unionfs(8) + tmpfs test
|
||||
|
||||
# "rmdir: d2: Directory not empty" seen.
|
||||
|
||||
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||
. ../default.cfg
|
||||
|
||||
mp1=/mnt$mdstart
|
||||
mp2=/mnt$((mdstart + 1))
|
||||
mkdir -p $mp1 $mp2
|
||||
set -e
|
||||
for i in $mp1 $mp2; do
|
||||
mount | grep -q "on $i " && umount -f $i
|
||||
done
|
||||
|
||||
md1=$mdstart
|
||||
md2=$((md1 + 1))
|
||||
mp1=/mnt$md1
|
||||
mp2=/mnt$md2
|
||||
mkdir -p $mp1 $mp2
|
||||
for i in $mp1 $mp2; do
|
||||
mount | grep -q "on $i " && umount -f $i
|
||||
done
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "tmpfs version"
|
||||
mount -o size=4g -t tmpfs dummy $mp1
|
||||
mount -o size=4g -t tmpfs dummy $mp2
|
||||
else
|
||||
echo "UFS version"
|
||||
for i in $md1 $md2; do
|
||||
mdconfig -l | grep -q md$i && mdconfig -d -u $i
|
||||
done
|
||||
mdconfig -a -t swap -s 4g -u $md1
|
||||
mdconfig -a -t swap -s 4g -u $md2
|
||||
newfs $newfs_flags -n md$md1 > /dev/null
|
||||
newfs $newfs_flags -n md$md2 > /dev/null
|
||||
mount /dev/md$md1 $mp1
|
||||
mount /dev/md$md2 $mp2
|
||||
fi
|
||||
|
||||
mount -t unionfs -o noatime $mp1 $mp2
|
||||
set +e
|
||||
|
||||
N=3 # Tree depth
|
||||
here=`pwd`
|
||||
cd $mp2
|
||||
mkdir dir; cd dir
|
||||
for j in `seq 1 $N`; do
|
||||
mkdir d$j && cd d$j
|
||||
done
|
||||
for j in `seq $N 1`; do
|
||||
cd .. && rmdir d$j
|
||||
done
|
||||
cd ..
|
||||
rmdir dir || { s=1; find dir -ls; }
|
||||
cd $here
|
||||
|
||||
while mount | grep -Eq "on $mp2 .*unionfs"; do
|
||||
umount $mp2 && break
|
||||
sleep 5
|
||||
done
|
||||
umount $mp2
|
||||
umount $mp1
|
||||
exit $s
|
||||
Loading…
Reference in a new issue