File tree Expand file tree Collapse file tree 2 files changed +33
-10
lines changed Expand file tree Collapse file tree 2 files changed +33
-10
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ test_lvm_sig() {
7
7
local test_status=1
8
8
local testname=` basename " $0 " `
9
9
local vg_name=" css-test-foo"
10
+ local tmplog=${WORKDIR} /tmplog
11
+ local errmsg=" Wipe signatures using wipefs or use WIPE_SIGNATURES=true and retry."
10
12
11
13
# Error out if any pre-existing volume group vg named css-test-foo
12
14
if vg_exists " $vg_name " ; then
25
27
done
26
28
27
29
# Run container-storage-setup
28
- $CSSBIN >> $LOGS 2>&1
29
-
30
- # Css should fail. If it did not, then test failed. This is very crude
31
- # check though as css can fail for so many reasons. A more precise check
32
- # would be too check for exact error message.
33
- [ $? -ne 0 ] && test_status=0
30
+ $CSSBIN > $tmplog 2>&1
31
+ rc=$?
32
+ cat $tmplog >> $LOGS 2>&1
33
+
34
+ # Test failed.
35
+ if [ $rc -ne 0 ]; then
36
+ if grep --no-messages -q " $errmsg " $tmplog ; then
37
+ test_status=0
38
+ else
39
+ echo " ERROR: $testname : $CSSBIN Failed for a reason other then \" $errmsg \" " >> $LOGS
40
+ fi
41
+ else
42
+ echo " ERROR: $testname : $CSSBIN Succeeded. Should have failed since LVM2_member signature exists on devices $devs " >> $LOGS
43
+ fi
34
44
35
- cleanup $vg_name " $devs "
45
+ cleanup " $vg_name " " $devs "
36
46
return $test_status
37
47
}
38
48
Original file line number Diff line number Diff line change @@ -50,6 +50,11 @@ vg_exists() {
50
50
return 1
51
51
}
52
52
53
+ # Tests if the physical volume exists
54
+ pv_exists () {
55
+ pvs $1 > /dev/null 2>&1
56
+ }
57
+
53
58
# Tests if the logical volume lv_name exists
54
59
lv_exists () {
55
60
local vg_name=$1
@@ -76,7 +81,14 @@ remove_pvs() {
76
81
local dev devs=$1 pv
77
82
for dev in $devs ; do
78
83
pv=$( lsblk -npl -o NAME " $dev " | tail -n +2 | head -1)
79
- pvremove -y ${pv} >> $LOGS 2>&1
84
+ # If lsblk output physical volume (pv) name, pv exists on partition.
85
+ if [ -n " $pv " ]; then
86
+ pvremove -y ${pv} >> $LOGS 2>&1
87
+ # If lsblk output nothing, there might be a pv on block device.
88
+ # pv name would be same as block device name in this case.
89
+ elif pv_exists " $dev " ; then
90
+ pvremove -y ${dev} >> $LOGS 2>&1
91
+ fi
80
92
done
81
93
}
82
94
@@ -125,8 +137,9 @@ cleanup() {
125
137
outfile=$4
126
138
fi
127
139
128
-
129
- vgremove -y $vg_name >> $LOGS 2>&1
140
+ if vg_exists " $vg_name " ; then
141
+ vgremove -y $vg_name >> $LOGS 2>&1
142
+ fi
130
143
remove_pvs " $devs "
131
144
remove_partitions " $devs "
132
145
# After removing partitions let udev settle down. In some
You can’t perform that action at this time.
0 commit comments