summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2019-10-02 14:11:08 -0500
committerDavid Teigland <teigland@redhat.com>2019-10-02 14:11:08 -0500
commitd69304114948451c72b399346194af6ed4e10f9c (patch)
tree1d2d8da2b8f84ba44f1da0e33b872a563421523c
parentc2ff8876f97a5840cd9d6fcda1bec55ef6220dc3 (diff)
downloadlvm2-d69304114948451c72b399346194af6ed4e10f9c.tar.gz
tests: add wipefs wrapper
which falls back to using dd on old systems without the wipefs command
-rw-r--r--test/lib/aux.sh11
-rw-r--r--test/shell/allow-mixed-block-sizes.sh5
-rw-r--r--test/shell/duplicate-pvs-md0.sh26
-rw-r--r--test/shell/duplicate-pvs-md1.sh38
-rw-r--r--test/shell/lvm-on-md.sh14
-rw-r--r--test/shell/pvcreate-operation-md.sh10
6 files changed, 53 insertions, 51 deletions
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 3c7ee62c1..8ceb5db7f 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -797,6 +797,17 @@ wait_md_create() {
echo "$md" > WAIT_MD_DEV
}
+wipefs_a() {
+ local dev=$1
+ shift
+
+ if wipefs -V >/dev/null; then
+ wipefs -a "$dev"
+ else
+ dd if=/dev/zero of="$dev" bs=1024 || true
+ fi
+}
+
prepare_backing_dev() {
local size=${1=32}
shift
diff --git a/test/shell/allow-mixed-block-sizes.sh b/test/shell/allow-mixed-block-sizes.sh
index ec60bc613..b51232a84 100644
--- a/test/shell/allow-mixed-block-sizes.sh
+++ b/test/shell/allow-mixed-block-sizes.sh
@@ -15,7 +15,6 @@ SKIP_WITH_LVMPOLLD=1
. lib/inittest
losetup -h | grep sector-size || skip
-wipefs -V || skip
dd if=/dev/zero of=loopa bs=$((1024*1024)) count=2 2> /dev/null
dd if=/dev/zero of=loopb bs=$((1024*1024)) count=2 2> /dev/null
@@ -32,8 +31,8 @@ not vgcreate --config 'devices {allow_mixed_block_sizes=0 scan="/dev"}' $vg $LOO
vgcreate --config 'devices {allow_mixed_block_sizes=1 scan="/dev"}' $vg $LOOP1 $LOOP2
vgs --config 'devices {allow_mixed_block_sizes=1 scan="/dev"}' $vg
-wipefs -a $LOOP1
-wipefs -a $LOOP2
+aux wipefs_a $LOOP1
+aux wipefs_a $LOOP2
vgcreate --config 'devices {allow_mixed_block_sizes=1 scan="/dev"}' $vg $LOOP1
vgs --config 'devices {allow_mixed_block_sizes=1 scan="/dev"}' $vg
diff --git a/test/shell/duplicate-pvs-md0.sh b/test/shell/duplicate-pvs-md0.sh
index e3f453fef..21f1442b2 100644
--- a/test/shell/duplicate-pvs-md0.sh
+++ b/test/shell/duplicate-pvs-md0.sh
@@ -28,8 +28,6 @@ _clear_online_files() {
. lib/inittest
-wipefs -V || skip
-
test -f /proc/mdstat && grep -q raid0 /proc/mdstat || \
modprobe raid0 || skip
@@ -125,8 +123,8 @@ vgchange -an $vg
vgremove -f $vg
mdadm --stop "$mddev"
aux udev_wait
-wipefs -a "$dev1"
-wipefs -a "$dev2"
+aux wipefs_a "$dev1"
+aux wipefs_a "$dev2"
aux udev_wait
@@ -197,8 +195,8 @@ vgchange -an $vg
vgremove -f $vg
mdadm --stop "$mddev"
aux udev_wait
-wipefs -a "$dev1"
-wipefs -a "$dev2"
+aux wipefs_a "$dev1"
+aux wipefs_a "$dev2"
aux udev_wait
@@ -253,8 +251,8 @@ pvscan --cache -aay "$dev2"
not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
not ls "$RUNDIR/lvm/vgs_online/$vg"
-wipefs -a "$dev1"
-wipefs -a "$dev2"
+aux wipefs_a "$dev1"
+aux wipefs_a "$dev2"
aux udev_wait
##########################################
@@ -311,8 +309,8 @@ not ls "$RUNDIR/lvm/vgs_online/$vg"
lvs -o active $vg |tee out || true
not grep "active" out
-wipefs -a "$dev1"
-wipefs -a "$dev2"
+aux wipefs_a "$dev1"
+aux wipefs_a "$dev2"
aux udev_wait
@@ -372,8 +370,8 @@ cat /proc/mdstat
# for some reason enabling dev2 starts an odd md dev
mdadm --stop "$mddev" || true
cat /proc/mdstat
-wipefs -a "$dev1" || true
-wipefs -a "$dev2" || true
+aux wipefs_a "$dev1" || true
+aux wipefs_a "$dev2" || true
aux udev_wait
##########################################
@@ -437,6 +435,6 @@ cat /proc/mdstat
# for some reason enabling dev2 starts an odd md dev
mdadm --stop "$mddev" || true
cat /proc/mdstat
-wipefs -a "$dev1" || true
-wipefs -a "$dev2" || true
+aux wipefs_a "$dev1" || true
+aux wipefs_a "$dev2" || true
aux udev_wait
diff --git a/test/shell/duplicate-pvs-md1.sh b/test/shell/duplicate-pvs-md1.sh
index a642c5555..be223df30 100644
--- a/test/shell/duplicate-pvs-md1.sh
+++ b/test/shell/duplicate-pvs-md1.sh
@@ -33,8 +33,6 @@ _clear_online_files() {
. lib/inittest
-wipefs -V || skip
-
test -f /proc/mdstat && grep -q raid1 /proc/mdstat || \
modprobe raid1 || skip
@@ -130,8 +128,8 @@ vgchange -an $vg
vgremove -f $vg
mdadm --stop "$mddev"
aux udev_wait
-wipefs -a "$dev1"
-wipefs -a "$dev2"
+aux wipefs_a "$dev1"
+aux wipefs_a "$dev2"
aux udev_wait
@@ -216,8 +214,8 @@ vgchange -an $vg
vgremove -f $vg
mdadm --stop "$mddev"
aux udev_wait
-wipefs -a "$dev1"
-wipefs -a "$dev2"
+aux wipefs_a "$dev1"
+aux wipefs_a "$dev2"
aux udev_wait
@@ -272,8 +270,8 @@ pvscan --cache -aay "$dev2"
not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
not ls "$RUNDIR/lvm/vgs_online/$vg"
-wipefs -a "$dev1"
-wipefs -a "$dev2"
+aux wipefs_a "$dev1"
+aux wipefs_a "$dev2"
aux udev_wait
@@ -340,8 +338,8 @@ not pvscan --cache -aay "$dev1"
ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
ls "$RUNDIR/lvm/vgs_online/$vg"
-wipefs -a "$dev1" || true
-wipefs -a "$dev2" || true
+aux wipefs_a "$dev1" || true
+aux wipefs_a "$dev2" || true
##########################################
@@ -419,8 +417,8 @@ cat /proc/mdstat
# for some reason enabling dev2 starts an odd md dev
mdadm --stop "$mddev" || true
cat /proc/mdstat
-wipefs -a "$dev1" || true
-wipefs -a "$dev2" || true
+aux wipefs_a "$dev1" || true
+aux wipefs_a "$dev2" || true
##########################################
# PV on an md raid1 device, auto+stopped
@@ -483,8 +481,8 @@ cat /proc/mdstat
# for some reason enabling dev2 starts an odd md dev
mdadm --stop "$mddev" || true
cat /proc/mdstat
-wipefs -a "$dev1" || true
-wipefs -a "$dev2" || true
+aux wipefs_a "$dev1" || true
+aux wipefs_a "$dev2" || true
##########################################
@@ -545,9 +543,9 @@ pvscan --cache -aay "$dev4"
not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
not ls "$RUNDIR/lvm/vgs_online/$vg"
-wipefs -a "$dev1"
-wipefs -a "$dev2"
-wipefs -a "$dev4"
+aux wipefs_a "$dev1"
+aux wipefs_a "$dev2"
+aux wipefs_a "$dev4"
aux udev_wait
@@ -621,7 +619,7 @@ cat /proc/mdstat
# for some reason enabling dev2 starts an odd md dev
mdadm --stop "$mddev" || true
cat /proc/mdstat
-wipefs -a "$dev1" || true
-wipefs -a "$dev2" || true
-wipefs -a "$dev4" || true
+aux wipefs_a "$dev1" || true
+aux wipefs_a "$dev2" || true
+aux wipefs_a "$dev4" || true
diff --git a/test/shell/lvm-on-md.sh b/test/shell/lvm-on-md.sh
index 726adf24e..910ebc742 100644
--- a/test/shell/lvm-on-md.sh
+++ b/test/shell/lvm-on-md.sh
@@ -28,8 +28,6 @@ _clear_online_files() {
. lib/inittest
-wipefs -V || skip
-
test -f /proc/mdstat && grep -q raid1 /proc/mdstat || \
modprobe raid1 || skip
@@ -168,8 +166,8 @@ vgremove -f $vg
mdadm --stop "$mddev"
aux udev_wait
-wipefs -a "$dev1"
-wipefs -a "$dev2"
+aux wipefs_a "$dev1"
+aux wipefs_a "$dev2"
aux udev_wait
@@ -293,8 +291,8 @@ vgremove -f $vg
mdadm --stop "$mddev"
aux udev_wait
-wipefs -a "$dev1"
-wipefs -a "$dev2"
+aux wipefs_a "$dev1"
+aux wipefs_a "$dev2"
aux udev_wait
@@ -461,7 +459,7 @@ vgremove -f $vg
mdadm --stop "$mddev"
aux udev_wait
-wipefs -a "$dev1"
-wipefs -a "$dev2"
+aux wipefs_a "$dev1"
+aux wipefs_a "$dev2"
aux udev_wait
diff --git a/test/shell/pvcreate-operation-md.sh b/test/shell/pvcreate-operation-md.sh
index 49edf4c68..f4b2a0d92 100644
--- a/test/shell/pvcreate-operation-md.sh
+++ b/test/shell/pvcreate-operation-md.sh
@@ -18,8 +18,6 @@ SKIP_WITH_LVMPOLLD=1
# skip this test if mdadm or sfdisk (or others) aren't available
which sfdisk || skip
-wipefs -V || skip
-
test -f /proc/mdstat && grep -q raid0 /proc/mdstat || \
modprobe raid0 || skip
mddev="/dev/md33"
@@ -115,8 +113,8 @@ fi
mdadm --stop "$mddev"
aux udev_wait
-wipefs -a "$dev1"
-wipefs -a "$dev2"
+aux wipefs_a "$dev1"
+aux wipefs_a "$dev2"
aux udev_wait
# Test newer topology-aware alignment detection w/ --dataalignment override
@@ -142,8 +140,8 @@ if aux kernel_at_least 2 6 33 ; then
mdadm --stop "$mddev"
aux udev_wait
- wipefs -a "$dev1"
- wipefs -a "$dev2"
+ aux wipefs_a "$dev1"
+ aux wipefs_a "$dev2"
aux udev_wait
fi