xref: /netbsd-src/external/gpl2/lvm2/dist/test/t-lvcreate-usage.sh (revision 274254cdae52594c1aa480a736aef78313d15c9c)
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# 'Exercise some lvcreate diagnostics'
13
14. ./test-utils.sh
15
16aux prepare_pvs 2
17aux pvcreate --metadatacopies 0 $dev1
18vgcreate -cn $vg $devs
19
20# "lvcreate rejects repeated invocation (run 2 times) (bz178216)"
21lvcreate -n $lv -l 4 $vg
22not lvcreate -n $lv -l 4 $vg
23lvremove -ff $vg/$lv
24
25# "lvcreate rejects a negative stripe_size"
26not lvcreate -L 64M -n $lv -i2 --stripesize -4 $vg 2>err;
27grep "^  Negative stripesize is invalid\$" err
28
29# 'lvcreate rejects a too-large stripesize'
30not lvcreate -L 64M -n $lv -i2 --stripesize 4294967291 $vg 2>err
31grep "^  Stripe size cannot be larger than 512.00 GB\$" err
32
33# 'lvcreate w/single stripe succeeds with diagnostics to stdout'
34lvcreate -L 64M -n $lv -i1 --stripesize 4 $vg >out 2>err
35grep "^  Redundant stripes argument: default is 1\$" out
36grep "^  Ignoring stripesize argument with single stripe\$" out
37lvdisplay $vg
38lvremove -ff $vg
39
40# 'lvcreate w/default (64KB) stripe size succeeds with diagnostics to stdout'
41lvcreate -L 64M -n $lv -i2 $vg > out
42grep "^  Using default stripesize" out
43lvdisplay $vg
44check_lv_field_ $vg/$lv stripesize "64.00K"
45lvremove -ff $vg
46
47# 'lvcreate rejects an invalid number of stripes'
48not lvcreate -L 64M -n $lv -i129 $vg 2>err
49grep "^  Number of stripes (129) must be between 1 and 128\$" err
50
51# 'lvcreate rejects an invalid regionsize (bz186013)'
52not lvcreate -L 64M -n $lv -R0 $vg 2>err
53grep "Non-zero region size must be supplied." err
54
55# The case on lvdisplay output is to verify that the LV was not created.
56# 'lvcreate rejects an invalid stripe size'
57not lvcreate -L 64M -n $lv -i2 --stripesize 3 $vg 2>err
58grep "^  Invalid stripe size 3\.00 KB\$" err
59case $(lvdisplay $vg) in "") true ;; *) false ;; esac
60
61