Imported Upstream version 2.02.79
[platform/upstream/device-mapper.git] / test / t-lock-blocking.sh
1 #!/bin/sh
2 # Copyright (C) 2008 Red Hat, Inc. All rights reserved.
3 #
4 # This copyrighted material is made available to anyone wishing to use,
5 # modify, copy, or redistribute it subject to the terms and conditions
6 # of the GNU General Public License v.2.
7 #
8 # You should have received a copy of the GNU General Public License
9 # along with this program; if not, write to the Free Software Foundation,
10 # Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
11
12 test_description='test some blocking / non-blocking multi-vg operations'
13
14 . ./test-utils.sh
15
16 aux prepare_devs 3
17 test -n "$LOCAL_CLVMD" && exit 200
18 pvcreate $dev1 $dev2
19 vgcreate $vg $dev1 $dev2
20
21 # if wait_for_locks set, vgremove should wait for orphan lock
22 # flock process should have exited by the time first vgremove completes
23 flock -w 5 $TESTDIR/var/lock/lvm/P_orphans -c "sleep 10" &
24 flock_pid=`jobs -p`
25 vgremove --config 'global { wait_for_locks = 1 }' $vg
26 not vgremove --config 'global { wait_for_locks = 1 }' $vg
27 not ps $flock_pid # finished
28
29 # if wait_for_locks not set, vgremove should fail on non-blocking lock
30 # we must wait for flock process at the end - vgremove won't wait
31 vgcreate $vg $dev1 $dev2
32 flock -w 5 $TESTDIR/var/lock/lvm/P_orphans -c "sleep 10" &
33 flock_pid=`jobs -p`
34 not vgremove --config 'global { wait_for_locks = 0 }' $vg
35 ps $flock_pid # still running
36 kill $flock_pid