File tree 2 files changed +30
-10
lines changed
2 files changed +30
-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_pvs $ devs
36
46
return $test_status
37
47
}
38
48
49
+ cleanup_pvs () {
50
+ local devs=$1
51
+ for dev in $devs ; do
52
+ pvremove -y ${dev} >> $LOGS 2>&1
53
+ done
54
+ wipe_signatures " $devs "
55
+ }
56
+
39
57
# Make sure a disk with lvm signature is rejected and is not overriden
40
58
# by css. Returns 0 on success and 1 on failure.
41
59
Original file line number Diff line number Diff line change @@ -58,11 +58,13 @@ lv_exists() {
58
58
return 1
59
59
}
60
60
61
- remove_pvs () {
61
+ remove_pvs_part () {
62
62
local dev devs=$1 pv
63
63
for dev in $devs ; do
64
64
pv=$( lsblk -npl -o NAME " $dev " | tail -n +2 | head -1)
65
- pvremove -y ${pv} >> $LOGS 2>&1
65
+ if [ -n " $pv " ]; then
66
+ pvremove -y ${pv} >> $LOGS 2>&1
67
+ fi
66
68
done
67
69
}
68
70
@@ -113,7 +115,7 @@ cleanup() {
113
115
114
116
115
117
vgremove -y $vg_name >> $LOGS 2>&1
116
- remove_pvs " $devs "
118
+ remove_pvs_part " $devs "
117
119
remove_partitions " $devs "
118
120
# After removing partitions let udev settle down. In some
119
121
# cases it has been observed that udev rule kept the device
You can’t perform that action at this time.
0 commit comments