[PATCH 10/10] tests: fix dependence on blkid

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The util-linux-ng tests have to be useful with blkid and also with
volume_id.

Signed-off-by: Karel Zak <kzak@xxxxxxxxxx>
---
 tests/ts-cramfs-mkfs |   15 +++++++++++----
 tests/ts-mkswap-doit |   16 ++++++++++++----
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/tests/ts-cramfs-mkfs b/tests/ts-cramfs-mkfs
index 6a9e029..1f7156e 100755
--- a/tests/ts-cramfs-mkfs
+++ b/tests/ts-cramfs-mkfs
@@ -40,6 +40,11 @@ IMAGE_RE=$( echo $IMAGE | sed 's:/:\\/:g' )
 LABEL="testCramfs"
 MOUNTPOINT="$TS_OUTDIR/cramfs-mnt"
 
+ldd $TS_CMD_MOUNT | grep -q 'libvolume_id' 2>&1 >> $TS_OUTPUT
+if [ "$?" == "0" ]; then
+	HAS_VOLUMEID="yes"
+fi
+
 echo "create mountpoint dir" >> $TS_OUTPUT
 if [ ! -d "$MOUNTPOINT" ]; then
 	mkdir -p $MOUNTPOINT
@@ -78,15 +83,17 @@ echo "create loop device from image" >> $TS_OUTPUT
 DEVICE=$( $TS_CMD_LOSETUP -f )
 $TS_CMD_LOSETUP $DEVICE $IMAGE 2>&1 >> $TS_OUTPUT
 
-
 echo "check the image" >> $TS_OUTPUT
-blkid -c /dev/null -w /dev/null -s TYPE $DEVICE 2>&1 | grep -q 'TYPE="cramfs"' 2>&1 >> $TS_OUTPUT
-
-if [ "$?" != "0" ]; then
+if [ "$($TS_CMD_MOUNT --guess-fstype $DEVICE)" != "cramfs" ]; then
 	echo "Cannot found cramfs on $DEVICE" >> $TS_OUTPUT
 	ts_finalize
 fi
 
+if [ -n "$HAS_VOLUMEID" ] && [ ! -L "/dev/disk/by-label/$LABEL" ]; then
+	$TS_CMD_LOSETUP -d $DEVICE 2>&1 >> $TS_OUTPUT
+	ts_skip "udev ignores /dev/loop*"
+fi
+
 echo "mount the image" >> $TS_OUTPUT
 $TS_CMD_MOUNT -L $LABEL $MOUNTPOINT 2>&1 >> $TS_OUTPUT
 
diff --git a/tests/ts-mkswap-doit b/tests/ts-mkswap-doit
index 6e19b46..e4b5b76 100755
--- a/tests/ts-mkswap-doit
+++ b/tests/ts-mkswap-doit
@@ -38,6 +38,11 @@ IMAGE="$TS_OUTDIR/loop-swap.img"
 IMAGE_RE=$( echo $IMAGE | sed 's:/:\\/:g' )
 LABEL="testSwap"
 
+ldd $TS_CMD_SWAPON | grep -q 'libvolume_id' 2>&1 >> $TS_OUTPUT
+if [ "$?" == "0" ]; then
+	HAS_VOLUMEID="yes"
+fi
+
 dd if=/dev/zero of=$IMAGE bs=1M count=20 &> /dev/null
 
 DEVICE=$( $TS_CMD_LOSETUP -f )
@@ -54,14 +59,17 @@ $TS_CMD_LOSETUP $DEVICE $IMAGE 2>&1 >> $TS_OUTPUT
 $TS_CMD_MKSWAP -L $LABEL $DEVICE 2>&1 >> $TS_OUTPUT
 
 # check it
-blkid -c /dev/null -w /dev/null -s TYPE $DEVICE 2>&1 | grep -q 'TYPE="swap"' 2>&1 >> $TS_OUTPUT
-
-if [ "$?" != "0" ]; then
+if [ "$($TS_CMD_MOUNT --guess-fstype $DEVICE)" != "swap" ]; then
 	echo "Cannot found Linux swap on $DEVICE" >> $TS_OUTPUT
-	#$TS_CMD_LOSETUP -d $DEVICE 2>&1 >> $TS_OUTPUT
+	$TS_CMD_LOSETUP -d $DEVICE 2>&1 >> $TS_OUTPUT
 	ts_finalize
 fi
 
+if [ -n "$HAS_VOLUMEID" ] && [ ! -L "/dev/disk/by-label/$LABEL" ]; then
+	$TS_CMD_LOSETUP -d $DEVICE 2>&1 >> $TS_OUTPUT
+	ts_skip "udev ignores /dev/loop*"
+fi
+
 # try connect it to system (and found the device by label)
 $TS_CMD_SWAPON -L $LABEL 2>&1 >> $TS_OUTPUT
 
-- 
1.5.0.6

-
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux