xref: /freebsd/tools/test/stress2/misc/unionfs7.sh (revision 4e8d558c)
1#!/bin/sh
2
3#
4# SPDX-License-Identifier: BSD-2-Clause
5#
6# Copyright (c) 2021 Peter Holm
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# unionfs(8) test
31
32# "unionfs_get_node_status: 0xfffffe018f356770 is not exclusive locked but
33# should be" seen.
34# https://people.freebsd.org/~pho/stress/log/log0202.txt
35
36[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
37. ../default.cfg
38
39md1=$mdstart
40md2=$((md1 + 1))
41mp1=/mnt$md1
42mp2=/mnt$md2
43mkdir -p $mp1 $mp2
44set -e
45for i in $mp1 $mp2; do
46	mount | grep -q "on $i " && umount -f $i
47done
48for i in $md1 $md2; do
49	mdconfig -l | grep -q md$i && mdconfig -d -u $i
50done
51
52mdconfig -a -t swap -s 4g -u $md1
53mdconfig -a -t swap -s 4g -u $md2
54newfs $newfs_flags -n md$md1 > /dev/null
55newfs $newfs_flags -n md$md2 > /dev/null
56mount /dev/md$md1 $mp1
57mount /dev/md$md2 $mp2
58
59mount -t unionfs -o noatime $mp1 $mp2
60set +e
61mount | grep -E "$mp1|$mp2"
62
63set `df -ik $mp2 | tail -1 | awk '{print $4,$7}'`
64export KBLOCKS=$(($1 / 4))
65export INODES=$(($2 / 4))
66
67export CTRLDIR=$mp2/stressX.control
68export INCARNATIONS=10
69export LOAD=80
70export RUNDIR=$mp2/stressX
71export runRUNTIME=5m
72export rwLOAD=80
73export symlinkLOAD=80
74
75export TESTPROGS="
76testcases/lockf2/lockf2
77testcases/symlink/symlink
78testcases/openat/openat
79testcases/rw/rw
80testcases/fts/fts
81testcases/link/link
82testcases/lockf/lockf
83testcases/creat/creat
84testcases/mkdir/mkdir
85testcases/rename/rename
86testcases/mkfifo/mkfifo
87testcases/dirnprename/dirnprename
88testcases/dirrename/dirrename
89testcases/swap/swap
90"
91
92cp -r ../../stress2 $mp2
93export TESTPROGS=`echo $TESTPROGS | sed 's/\n/ /g'`
94
95set +e
96chmod 777 $mp2
97su $testuser -c \
98	"(cd $mp2/stress2; ./testcases/run/run $TESTPROGS)"
99
100while mount | grep -Eq "on $mp2 .*unionfs"; do
101	umount $mp2 && break
102	sleep 5
103done
104umount $mp2
105n=`find $mp1/stressX | wc -l`
106[ $n -eq 1 ] && s=0 || { find $mp1/stressX -ls | head -12; s=1; }
107umount $mp1
108mdconfig -d -u $md2
109mdconfig -d -u $md1
110exit $s
111