summaryrefslogtreecommitdiff
path: root/test/shell/lvcreate-signature-wiping.sh
blob: 4893d9a6670f8a9bedc2fc8e9258cb212f39de4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env bash

# Copyright (C) 2013 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

# 'Exercise signature wiping during lvcreate'


SKIP_WITH_LVMPOLLD=1

. lib/inittest

init_lv_() {
	mkswap "$DM_DEV_DIR/$vg/$lv1"
}

test_blkid_() {
	local type
	type=$(blkid -s TYPE -o value -c /dev/null "$DM_DEV_DIR/$vg/$lv1")
	test "$type" = "swap"
}

test_msg_() {
	grep "Wiping swap signature" out
}

aux prepare_vg

# lvcreate wipes signatures when found on newly created LV - test this on "swap".
# Test all combinatios with -Z{y|n} and -W{y|n} and related lvm.conf settings.

lvcreate -l1 -n $lv1 $vg
init_lv_
# This system has unusable blkid (does not recognize small swap, needs fix...)
test_blkid_ || skip
lvremove -f $vg/$lv1

# Zeroing stops the command when there is a failure (write error in this case)
aux error_dev "$dev1" "$(get first_extent_sector "$dev1"):8"
not lvcreate -l1 -n $lv1 $vg 2>&1 | tee out
grep "Failed to initialize" out
aux enable_dev "$dev1"


aux lvmconf "allocation/wipe_signatures_when_zeroing_new_lvs = 0"

lvcreate -y -Zn -l1 -n $lv1 $vg 2>&1 | tee out
not test_msg_
test_blkid_
lvremove -f $vg/$lv1

lvcreate -y -Zn -Wn -l1 -n $lv1 $vg 2>&1 | tee out
not test_msg_
test_blkid_
lvremove -f $vg/$lv1

lvcreate -y -Zn -Wy -l1 -n $lv1 $vg 2>&1 | tee out
test_msg_
not test_blkid_
init_lv_
lvremove -f $vg/$lv1

lvcreate -y -Zy -l1 -n $lv1 $vg 2>&1 | tee out
not test_msg_
not test_blkid_
init_lv_
lvremove -f $vg/$lv1

lvcreate -y -Zy -Wn -l1 -n $lv1 $vg 2>&1 | tee out
not test_msg_
not test_blkid_
init_lv_
lvremove -f $vg/$lv1

lvcreate -y -Zy -Wy -l1 -n $lv1 $vg 2>&1 | tee out
test_msg_
not test_blkid_
init_lv_
lvremove -f $vg/$lv1


aux lvmconf "allocation/wipe_signatures_when_zeroing_new_lvs = 1"

lvcreate -y -Zn -l1 -n $lv1 $vg 2>&1 | tee out
not test_msg_
test_blkid_
lvremove -f $vg/$lv1

lvcreate -y -Zn -Wn -l1 -n $lv1 $vg 2>&1 | tee out
not test_msg_
test_blkid_
lvremove -f $vg/$lv1

lvcreate -y -Zn -Wy -l1 -n $lv1 $vg 2>&1 | tee out
test_msg_
not test_blkid_
init_lv_
lvremove -f $vg/$lv1

lvcreate -y -Zy -l1 -n $lv1 $vg 2>&1 | tee out
test_msg_
not test_blkid_
init_lv_
lvremove -f $vg/$lv1

lvcreate -y -Zy -Wn -l1 -n $lv1 $vg 2>&1 | tee out
not test_msg_
not test_blkid_
init_lv_
lvremove -f $vg/$lv1

lvcreate -y -Zy -Wy -l1 -n $lv1 $vg 2>&1 | tee out
test_msg_
not test_blkid_
init_lv_
lvremove -f $vg/$lv1

vgremove -f $vg