dcavalca / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone
069435
From 8822103e30121d95fa58b5e8b7ce8ce91d4e778e Mon Sep 17 00:00:00 2001
069435
From: Karel Zak <kzak@redhat.com>
069435
Date: Mon, 3 Jun 2019 22:29:51 +0200
069435
Subject: [PATCH] tests: make mount -oloop use more robust
069435
069435
The command creates loop device, so udevd is in the game and it seems
069435
better to wait for him.
069435
069435
Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=1681062
069435
Signed-off-by: Karel Zak <kzak@redhat.com>
069435
---
069435
 tests/ts/libmount/loop         |  4 ++++
069435
 tests/ts/libmount/loop-overlay | 11 +++++++++++
069435
 2 files changed, 15 insertions(+)
069435
069435
diff --git a/tests/ts/libmount/loop b/tests/ts/libmount/loop
069435
index 090b79fa4..50764781c 100755
069435
--- a/tests/ts/libmount/loop
069435
+++ b/tests/ts/libmount/loop
069435
@@ -65,6 +65,7 @@ ts_finalize_subtest
069435
 ts_init_subtest "file-o-loop"
069435
 [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
069435
 $TS_CMD_MOUNT -oloop "$BACKFILE" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>&1
069435
+udevadm settle
069435
 $TS_CMD_UMOUNT "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>&1
069435
 udevadm settle
069435
 ts_log "Success"
069435
@@ -89,6 +90,7 @@ else
069435
 	[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
069435
 	LODEV=$( $TS_CMD_LOSETUP --find 2>> $TS_OUTPUT )
069435
 	$TS_CMD_MOUNT -oloop=$LODEV "$BACKFILE" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>&1
069435
+	udevadm settle
069435
 	verify_mount_dev "$LODEV" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>&1
069435
 	$TS_CMD_UMOUNT "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>&1
069435
 	udevadm settle
069435
@@ -122,6 +124,7 @@ ts_init_subtest "o-loop-val-initialized"
069435
 LODEV=$( $TS_CMD_LOSETUP --show -f "$BACKFILE" 2>>$TS_OUTPUT)
069435
 $TS_CMD_MOUNT -oloop=$LODEV "$BACKFILE" "$TS_MOUNTPOINT" 2>&1 \
069435
        | sed 's/:.*:/: <target>/; s/for .*/for <source>/' > $TS_OUTPUT
069435
+udevadm settle
069435
 $TS_CMD_LOSETUP --detach $LODEV >> $TS_OUTPUT 2>&1
069435
 udevadm settle
069435
 ts_log "Success"
069435
@@ -133,6 +136,7 @@ cp "$BACKFILE" "$BACKFILE"-2
069435
 LODEV=$( $TS_CMD_LOSETUP --show -f "$BACKFILE"-2 2>> $TS_OUTPUT)
069435
 $TS_CMD_MOUNT -oloop=$LODEV "$BACKFILE" "$TS_MOUNTPOINT" 2>&1 \
069435
 	| sed 's/:.*:/: <target>/; s/for .*/for <source>/' > $TS_OUTPUT
069435
+udevadm settle
069435
 $TS_CMD_LOSETUP --detach $LODEV >> $TS_OUTPUT 2>&1
069435
 rm "$BACKFILE"-2
069435
 udevadm settle
069435
diff --git a/tests/ts/libmount/loop-overlay b/tests/ts/libmount/loop-overlay
069435
index fffb823c0..1ba6eb06e 100755
069435
--- a/tests/ts/libmount/loop-overlay
069435
+++ b/tests/ts/libmount/loop-overlay
069435
@@ -43,23 +43,34 @@ dd if="$IMG" of="$IMG" oflag=append bs=1024k count=5 conv=notrunc &>/dev/null
069435
 
069435
 echo "second should fail" >>$TS_OUTPUT
069435
 $TS_CMD_MOUNT -oloop "$IMG" "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>&1
069435
+udevadm settle
069435
 $TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" 2>&1 \
069435
        | sed 's/:.*:/: <target>/; s/for .*/for <source>/' >> $TS_OUTPUT
069435
+udevadm settle
069435
 $TS_CMD_UMOUNT "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>&1
069435
+udevadm settle
069435
 
069435
 echo "should succeed" >>$TS_OUTPUT
069435
 $TS_CMD_MOUNT -oloop,sizelimit=$OFFSET "$IMG" "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>&1
069435
+udevadm settle
069435
 $TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" >> $TS_OUTPUT 2>&1
069435
+udevadm settle
069435
 $TS_CMD_UMOUNT "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>&1
069435
+udevadm settle
069435
 $TS_CMD_UMOUNT "$TS_MOUNTPOINT-2" >> $TS_OUTPUT 2>&1
069435
+udevadm settle
069435
 
069435
 echo "both should fail" >>$TS_OUTPUT
069435
 LOOPDEV=$($TS_CMD_LOSETUP --show -f --offset 1 --sizelimit $OFFSET "$IMG")
069435
+udevadm settle
069435
 $TS_CMD_MOUNT -oloop,sizelimit=$OFFSET "$IMG" "$TS_MOUNTPOINT-1" 2>&1 \
069435
 	| sed 's/:.*:/: <target>/; s/for .*/for <source>/' >> $TS_OUTPUT
069435
+udevadm settle
069435
 $TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" 2>&1 \
069435
 	| sed 's/:.*:/: <target>/; s/for .*/for <source>/' >> $TS_OUTPUT
069435
+udevadm settle
069435
 $TS_CMD_LOSETUP --detach $LOOPDEV
069435
+udevadm settle
069435
 
069435
 ts_log "Success"
069435
 ts_finalize
069435
-- 
069435
2.21.0
069435