18a272653SPeter Holm#!/bin/sh 28a272653SPeter Holm 38a272653SPeter Holm# 48a272653SPeter Holm# Copyright (c) 2008-2011 Peter Holm <pho@FreeBSD.org> 58a272653SPeter Holm# All rights reserved. 68a272653SPeter Holm# 78a272653SPeter Holm# Redistribution and use in source and binary forms, with or without 88a272653SPeter Holm# modification, are permitted provided that the following conditions 98a272653SPeter Holm# are met: 108a272653SPeter Holm# 1. Redistributions of source code must retain the above copyright 118a272653SPeter Holm# notice, this list of conditions and the following disclaimer. 128a272653SPeter Holm# 2. Redistributions in binary form must reproduce the above copyright 138a272653SPeter Holm# notice, this list of conditions and the following disclaimer in the 148a272653SPeter Holm# documentation and/or other materials provided with the distribution. 158a272653SPeter Holm# 168a272653SPeter Holm# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 178a272653SPeter Holm# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 188a272653SPeter Holm# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 198a272653SPeter Holm# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 208a272653SPeter Holm# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 218a272653SPeter Holm# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 228a272653SPeter Holm# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 238a272653SPeter Holm# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 248a272653SPeter Holm# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 258a272653SPeter Holm# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 268a272653SPeter Holm# SUCH DAMAGE. 278a272653SPeter Holm# 288a272653SPeter Holm 29*fc22fe5cSPeter Holm# unionfs test using two memory disks 30*fc22fe5cSPeter Holm 318a272653SPeter Holm[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 328a272653SPeter Holm. ../default.cfg 338a272653SPeter Holm 34*fc22fe5cSPeter Holm# unionfs usage example from the man page: 35*fc22fe5cSPeter Holm# mount -t cd9660 -o ro /dev/cd0 /usr/src 36*fc22fe5cSPeter Holm# mount -t unionfs -o noatime /var/obj /usr/src 378a272653SPeter Holm 38*fc22fe5cSPeter Holmmd1=$mdstart 39*fc22fe5cSPeter Holmmd2=$((md1 + 1)) 40*fc22fe5cSPeter Holmmp1=/mnt$md1 41*fc22fe5cSPeter Holmmp2=/mnt$md2 42*fc22fe5cSPeter Holmmkdir -p $mp1 $mp2 43*fc22fe5cSPeter Holmset -e 44*fc22fe5cSPeter Holmfor i in $mp1 $mp2; do 45*fc22fe5cSPeter Holm mount | grep -q "on $i " && umount -f $i 468a272653SPeter Holmdone 47*fc22fe5cSPeter Holmfor i in $md1 $md2; do 48*fc22fe5cSPeter Holm mdconfig -l | grep -q md$i && mdconfig -d -u $i 49*fc22fe5cSPeter Holmdone 50*fc22fe5cSPeter Holm 51*fc22fe5cSPeter Holmmdconfig -a -t swap -s 2g -u $md1 52*fc22fe5cSPeter Holmmdconfig -a -t swap -s 2g -u $md2 53*fc22fe5cSPeter Holmnewfs $newfs_flags -n md$md1 > /dev/null 54*fc22fe5cSPeter Holmnewfs $newfs_flags -n md$md2 > /dev/null 55*fc22fe5cSPeter Holmmount /dev/md$md1 $mp1 56*fc22fe5cSPeter Holmmount /dev/md$md2 $mp2 57*fc22fe5cSPeter Holm 58*fc22fe5cSPeter Holmmount -t unionfs -o noatime $mp1 $mp2 59*fc22fe5cSPeter Holmmount | grep -E "$mp1|$mp2" 60*fc22fe5cSPeter Holmset +e 61*fc22fe5cSPeter Holm 62*fc22fe5cSPeter Holmexport RUNDIR=$mp2/stressX 63*fc22fe5cSPeter Holmexport CTRLDIR=$mp2/stressX.control 64*fc22fe5cSPeter Holmexport runRUNTIME=2m 65*fc22fe5cSPeter Holm 66*fc22fe5cSPeter Holm# SU work around for "disk full" 67*fc22fe5cSPeter Holmset `df -ik $mp2 | tail -1 | awk '{print $4,$7}'` 68*fc22fe5cSPeter Holmexport KBLOCKS=$(($1 / 2)) 69*fc22fe5cSPeter Holmexport INODES=$(($2 / 2)) 70*fc22fe5cSPeter Holm 71*fc22fe5cSPeter Holm(cd ..; ./run.sh disk.cfg) 72*fc22fe5cSPeter Holm 73*fc22fe5cSPeter Holmfind $RUNDIR -ls 74*fc22fe5cSPeter Holmfor i in `jot 5`; do 75*fc22fe5cSPeter Holm mount | grep -q unionfs || break 76*fc22fe5cSPeter Holm umount $mp2 || sleep 2 # The unionfs mount 77*fc22fe5cSPeter Holmdone 78*fc22fe5cSPeter Holmmount | grep unionfs && exit 1 79*fc22fe5cSPeter Holm 80*fc22fe5cSPeter Holmfor i in `jot 5`; do 81*fc22fe5cSPeter Holm umount $mp2 && break 82*fc22fe5cSPeter Holm sleep 2 83*fc22fe5cSPeter Holmdone 84*fc22fe5cSPeter Holmmount | grep -q "on $mp2 " && exit 1 85*fc22fe5cSPeter Holmn=`find $mp1/stressX | wc -l` 86*fc22fe5cSPeter Holm[ $n -eq 1 ] && s=0 || s=1 87*fc22fe5cSPeter Holmumount $mp1 88*fc22fe5cSPeter Holmmdconfig -d -u $md2 89*fc22fe5cSPeter Holmmdconfig -d -u $md1 90*fc22fe5cSPeter Holmexit $s 91