Linux Device Mapper development
 help / color / mirror / Atom feed
From: Martin Wilck <mwilck@suse.com>
To: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: Stef Walter <stefw@redhat.com>,
	dm-devel@redhat.com, Martin Wilck <mwilck@suse.com>,
	Yuval Turgeman <yturgema@redhat.com>
Subject: [PATCH 1/8] test-kpartx: add test for invocation on image file
Date: Wed, 10 Oct 2018 22:04:59 +0200	[thread overview]
Message-ID: <20181010200506.15796-2-mwilck@suse.com> (raw)
In-Reply-To: <20181010200506.15796-1-mwilck@suse.com>

Add a test for kpartx invocation on an image file that is not
yet part of a loop device, passing a relative path to kpartx:

        # kpartx -av disk.img
        ...
        # kpartx -d disk.img

The recent patches 95c4189b "kpartx: Use absolute paths to create mappings"
and c1adcc5b "kpartx: Use absolute paths to create mappings" both
independently fixed this behavior, which had been broken previously by
9bdfa3eb "kpartx: use absolute path for regular files".

Cc: Stef Walter <stefw@redhat.com>
Cc: Yuval Turgeman <yturgema@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 kpartx/test-kpartx | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/kpartx/test-kpartx b/kpartx/test-kpartx
index d2001dce..d3c9aef5 100755
--- a/kpartx/test-kpartx
+++ b/kpartx/test-kpartx
@@ -87,6 +87,7 @@ step preparation
 FILE1=kpartx1
 FILE2=kpartx2
 FILE3=kpartx3
+FILE4=kpartx4
 SIZE=$((1024*1024*1024))  # use bytes as units here
 SECTSIZ=512
 OFFS=32                # offset of linear mapping into dev, sectors
@@ -108,6 +109,7 @@ step "create loop devices"
 truncate -s $SIZE $FILE1
 truncate -s $SIZE $FILE2
 truncate -s $SIZE $FILE3
+truncate -s $SIZE $FILE4
 
 LO1=$(losetup -f $FILE1 --show)
 push_cleanup 'losetup -d $LO1'
@@ -115,8 +117,10 @@ LO2=$(losetup -f $FILE2 --show)
 push_cleanup 'losetup -d $LO2'
 LO3=$(losetup -f $FILE3 --show)
 push_cleanup 'losetup -d $LO3'
+LO4=$(losetup -f $FILE4 --show)
+push_cleanup 'losetup -d $LO4'
 
-[[ $LO1 && $LO2 && $LO3 && -b $LO1 && -b $LO2 && -b $LO3 ]]
+[[ $LO1 && $LO2 && $LO3 && $LO4 && -b $LO1 && -b $LO2 && -b $LO3 && -b $LO4 ]]
 DEV1=$(stat -c "%t:%T" $LO1)
 DEV2=$(stat -c "%t:%T" $LO2)
 DEV3=$(stat -c "%t:%T" $LO3)
@@ -173,6 +177,7 @@ step "create partitions on loop devices"
 
 mk_partitions $LO1
 mk_partitions $LO2
+mk_partitions $LO4
 
 # Test invocation of kpartx with regular file here
 LO2P1=/dev/mapper/$(basename $LO2)-foo1
@@ -310,4 +315,21 @@ $KPARTX $KPARTX_OPTS -f -d $LO3
 [[ -b /dev/mapper/$SPAN1 ]]
 [[ -b /dev/mapper/$SPAN2 ]]
 
+step "test kpartx creation/deletion on an image file with no existing loopdev"
+losetup -d $LO4
+
+OUTPUT=$($KPARTX $KPARTX_OPTS -v -a $FILE4 2>&1)
+read loop dm < \
+     <(sed -n  's/^add map \(loop[0-9]*\)p1 ([0-9]*:\([0-9]*\)).*$/\1 dm-\2/p' \
+	   <<<$OUTPUT)
+[[ $dm && $loop ]]
+push_cleanup "dmsetup remove -f /dev/$dm"
+push_cleanup "losetup -d /dev/$loop"
+
+[[ -b /dev/mapper/${loop}p1 ]]
+$KPARTX -d $KPARTX_OPTS $FILE4
+[[ ! -b /dev/mapper/${loop}p1 ]]
+# /dev/$loop is _not_ automatically deleted
+[[ -b /dev/${loop} ]]
+
 OK=yes
-- 
2.19.0

  reply	other threads:[~2018-10-10 20:04 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-10 20:04 [PATCH 0/8] various multipath-tools patches Martin Wilck
2018-10-10 20:04 ` Martin Wilck [this message]
2018-10-12 21:45   ` [PATCH 1/8] test-kpartx: add test for invocation on image file Benjamin Marzinski
2018-10-10 20:05 ` [PATCH 2/8] libmultipath: scsi_ioctl_pathinfo doesn't fail Martin Wilck
2018-10-12 21:46   ` Benjamin Marzinski
2018-10-10 20:05 ` [PATCH 3/8] libmultipath: cciss_ioctl_pathinfo " Martin Wilck
2018-10-12 21:47   ` Benjamin Marzinski
2018-10-10 20:05 ` [PATCH 4/8] multipath.rules: add comment about DM_MULTIPATH_DEVICE_PATH=2 Martin Wilck
2018-10-12 21:49   ` Benjamin Marzinski
2018-10-10 20:05 ` [PATCH 5/8] multipath.8: man page update Martin Wilck
2018-10-12 21:51   ` Benjamin Marzinski
2018-10-10 20:05 ` [PATCH 6/8] libmultipath: test code for "zombie" TUR threads Martin Wilck
2018-10-12 21:51   ` Benjamin Marzinski
2018-10-10 20:05 ` [PATCH 7/8] libmultipath: handle TUR threads that can't be cancelled Martin Wilck
2018-10-12 22:11   ` Benjamin Marzinski
2018-10-23 10:58     ` Martin Wilck
2018-10-10 20:05 ` [PATCH 8/8] multipathd: handle repeated udev retrigger failure Martin Wilck
2018-10-12 22:30   ` Benjamin Marzinski
2018-10-13  8:48 ` [PATCH 0/8] various multipath-tools patches Christophe Varoqui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181010200506.15796-2-mwilck@suse.com \
    --to=mwilck@suse.com \
    --cc=christophe.varoqui@opensvc.com \
    --cc=dm-devel@redhat.com \
    --cc=stefw@redhat.com \
    --cc=yturgema@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox