[dm-devel] [PATCH 07/31] test-kpartx: test deletion with empty part table

Martin Wilck mwilck at suse.com
Sat Sep 2 22:38:36 UTC 2017


Added a test case for "kpartx: fix part deletion without partition
table".

Signed-off-by: Martin Wilck <mwilck at suse.com>
---
 kpartx/test-kpartx | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/kpartx/test-kpartx b/kpartx/test-kpartx
index 35b0f064..60b3eb23 100755
--- a/kpartx/test-kpartx
+++ b/kpartx/test-kpartx
@@ -68,6 +68,10 @@ mk_partitions() {
     parted -s -- $1 mkpart prim ext2 1MiB -1s
 }
 
+wipe_ptable() {
+    dd if=/dev/zero of=$1 bs=1b count=1
+}
+
 step preparation
 
 [[ $UID -eq 0 ]]
@@ -165,8 +169,18 @@ mk_partitions $LO2
 # Test invocation of kpartx with regular file here
 LO2P1=/dev/mapper/$(basename $LO2)-foo1
 $KPARTX $KPARTX_OPTS -a -p -foo $FILE2
+[[ -b $LO2P1 ]]
 push_cleanup 'dmsetup remove -f $(basename $LO2P1)'
 
+step "remove partitions with deleted ptable"
+wipe_ptable $LO2
+$KPARTX $KPARTX_OPTS -d $LO2
+[[ ! -b $LO2P1 ]]
+
+mk_partitions $LO2
+$KPARTX $KPARTX_OPTS -a -p -foo $FILE2
+[[ -b $LO2P1 ]]
+
 LO1P1=/dev/mapper/$(basename $LO1)-eggs1
 $KPARTX $KPARTX_OPTS -a -p -eggs $LO1
 push_cleanup 'dmsetup remove -f $(basename $LO1P1)'
-- 
2.14.0




More information about the dm-devel mailing list