xref: /freebsd/tools/test/stress2/misc/nullfs27.sh (revision fe6060f10f634930ff71b7c50291ddc610da2475)
1#!/bin/sh
2
3#
4# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
5#
6# Copyright (c) 2019 Dell EMC Isilon
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[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
31
32# Run all the rename(2) test scenarios with nullfs.
33# Used in connection with WiP work on nullfs.
34
35. ../default.cfg
36
37set -e
38mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint
39mdconfig -l | grep -q md$mdstart &&  mdconfig -d -u $mdstart
40
41mdconfig -a -t swap -s 2g -u $mdstart || exit 1
42bsdlabel -w md$mdstart auto
43
44newfs $newfs_flags md${mdstart}$part > /dev/null
45mount /dev/md${mdstart}$part $mntpoint
46chmod 777 $mntpoint
47
48mp2=${mntpoint}2
49[ -d $mp2 ] || mkdir -p $mp2
50mount | grep -wq $mp2 && umount $mp2
51mount -t nullfs $mntpoint $mp2
52chmod 777 $mp2
53set +e
54
55export LOAD=80
56export MAXSWAPPCT=80
57export RUNDIR=$mp2/stressX
58export runRUNTIME=10m
59export rwLOAD=80
60export TESTPROGS='
61testcases/lockf2/lockf2
62testcases/symlink/symlink
63testcases/openat/openat
64testcases/socket/socket
65testcases/rw/rw
66testcases/mmap/mmap
67testcases/fts/fts
68testcases/link/link
69testcases/lockf/lockf
70testcases/creat/creat
71testcases/mkdir/mkdir
72testcases/rename/rename
73testcases/swap/swap
74testcases/mkfifo/mkfifo
75testcases/dirnprename/dirnprename
76testcases/dirrename/dirrename
77'
78
79su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS'
80
81while mount | grep $mp2 | grep -q nullfs; do
82	umount $mp2 || sleep 1
83done
84n=0
85while mount | grep $mntpoint | grep -q /dev/md; do
86	umount $mntpoint || sleep 1
87	n=$((n + 1))
88	[ $n -gt 30 ] && { echo FAIL; status=2; }
89done
90mdconfig -d -u $mdstart
91exit $status
92