xref: /freebsd/tools/test/stress2/misc/unionfs7.sh (revision e9e8876a4d6afc1ad5315faaa191b25121a813d7)
1#!/bin/sh
2
3#
4# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
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
63export CTRLDIR=$mp2/stressX.control
64export INCARNATIONS=10
65export LOAD=80
66export RUNDIR=$mp2/stressX
67export runRUNTIME=5m
68export rwLOAD=80
69export symlinkLOAD=80
70
71export TESTPROGS="
72testcases/lockf2/lockf2
73testcases/symlink/symlink
74testcases/openat/openat
75testcases/rw/rw
76testcases/fts/fts
77testcases/link/link
78testcases/lockf/lockf
79testcases/creat/creat
80testcases/mkdir/mkdir
81testcases/rename/rename
82testcases/mkfifo/mkfifo
83testcases/dirnprename/dirnprename
84testcases/dirrename/dirrename
85testcases/swap/swap
86"
87
88cp -r ../../stress2 $mp2
89export TESTPROGS=`echo $TESTPROGS | sed 's/\n/ /g'`
90
91set +e
92chmod 777 $mp2
93su $testuser -c \
94	"(cd $mp2/stress2; ./testcases/run/run $TESTPROGS)"
95
96umount $mp2	# The unionfs mount
97umount $mp2
98n=`find $mp1/stressX | wc -l`
99[ $n -eq 1 ] && s=0 || { find $mp1/stressX -ls | head -12; s=1; }
100umount $mp1
101mdconfig -d -u $md2
102mdconfig -d -u $md1
103exit $s
104