xref: /freebsd/tools/test/stress2/misc/unionfs16.sh (revision 6580f5c38dd5b01aeeaed16b370f1a12423437f0)
1#!/bin/sh
2
3#
4# Copyright (c) 2024 Peter Holm <pho@FreeBSD.org>
5#
6# SPDX-License-Identifier: BSD-2-Clause
7#
8
9# No problems seen with this test scenario
10
11[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
12. ../default.cfg
13
14[ -d /usr/src/tools/test/stress2 ] || exit 0
15prog=$(basename "$0" .sh)
16log=/tmp/$prog.log
17md1=$mdstart
18md2=$((md1 + 1))
19mp1=/mnt$md1
20mp2=/mnt$md2
21s=0
22
23mkdir -p $mp1 $mp2
24set -e
25for i in $mp1 $mp2; do
26	mount | grep -q "on $i " && umount -f $i
27done
28for i in $md1 $md2; do
29	mdconfig -l | grep -q md$i && mdconfig -d -u $i
30done
31
32mdconfig -a -t swap -s 3g -u $md1
33mdconfig -a -t swap -s 3g -u $md2
34newfs $newfs_flags -n md$md1 > /dev/null
35newfs $newfs_flags -n md$md2 > /dev/null
36mount /dev/md$md1 $mp1
37mount /dev/md$md2 $mp2
38(cd $mp1; cp -a /usr/src/tools/test/stress2 .)
39(cd $mp2; cp -a /usr/src/tools/test/stress2 .)
40rm $mp1/stress2/testcases/run/run
41rm $mp2/stress2/testcases/swap/swap
42mount -u -o ro $mp1
43mount -t unionfs -o below $mp1 $mp2
44rm $mp2/stress2/testcases/mkdir/mkdir
45chmod 777 $mp2
46set +e
47
48(cd $mp2/stress2; make > /dev/null 2>&1)
49export RUNDIR=$mp2/stressX
50export runRUNTIME=1m
51su $testuser -c "cd $mp2/stress2; ./run.sh vfs.cfg" > /dev/null 2>&1
52umount $mp2
53
54while mount | grep -Eq "unionfs.* on $mp2 "; do
55	umount $mp2 && break
56	sleep 5
57done
58fsck_ffs -fy /dev/md$md2 > $log 2>&1
59grep -Eq "WAS MODIFIED" $log && { cat $log; s=1; }
60umount $mp2
61umount $mp1
62mdconfig -d -u $md1
63mdconfig -d -u $md2
64rm -f $log
65exit $s
66