From: Karel Zak Date: Wed, 4 Feb 2009 21:38:34 +0000 (+0100) Subject: tests: check also for /dev/loop/X X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3ff2557c92398a611e42ad6b428c78e9c5c120ed;p=util-linux tests: check also for /dev/loop/X Signed-off-by: Karel Zak --- diff --git a/tests/functions.sh b/tests/functions.sh index d57d19d8..371deb6a 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -244,6 +244,17 @@ function ts_device_has_uuid { return $? } +function ts_is_mounted { + local DEV=$1 + + grep -q $DEV /proc/mounts && return 0 + + if [ "${DEV#/dev/loop/}" != "$DEV" ]; then + return grep -q "/dev/loop${DEV#/dev/loop/}" /proc/mounts + fi + return 1 +} + function ts_swapoff { local DEV="$1" diff --git a/tests/ts-cramfs-mkfs b/tests/ts-cramfs-mkfs index 4ed8114b..651f4e34 100755 --- a/tests/ts-cramfs-mkfs +++ b/tests/ts-cramfs-mkfs @@ -74,8 +74,7 @@ ts_log "mount the image" $TS_CMD_MOUNT -L $LABEL $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT # check it -grep -q $DEVICE /proc/mounts -[ "$?" == "0" ] || ts_die "Cannot found $DEVICE in /proc/mounts" $DEVICE +ts_is_mounted $DEVICE || ts_die "Cannot found $DEVICE in /proc/mounts" $DEVICE ts_log "list the image" ls -laR --time-style=long-iso $TS_MOUNTPOINT >> $TS_OUTPUT diff --git a/tests/ts-fstab-devname b/tests/ts-fstab-devname index b7eabd7f..87483afd 100755 --- a/tests/ts-fstab-devname +++ b/tests/ts-fstab-devname @@ -39,14 +39,12 @@ ts_fstab_add $DEVICE # variant A) $TS_CMD_MOUNT $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT -grep -q $DEVICE /proc/mounts \ - || ts_die "A) Cannot found $DEVICE in /proc/mounts" $DEVICE +ts_is_mounted $DEVICE || ts_die "A) Cannot found $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE" $DEVICE # variant B) $TS_CMD_MOUNT $DEVICE 2>&1 >> $TS_OUTPUT -grep -q $DEVICE /proc/mounts \ - || ts_die "B) Cannot found $DEVICE in /proc/mounts" $DEVICE +ts_is_mounted $DEVICE || ts_die "B) Cannot found $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" $DEVICE ts_device_deinit $DEVICE diff --git a/tests/ts-fstab-devname2label b/tests/ts-fstab-devname2label index dda38a1d..575acaa7 100755 --- a/tests/ts-fstab-devname2label +++ b/tests/ts-fstab-devname2label @@ -41,7 +41,7 @@ ts_device_has "LABEL" $LABEL $DEVICE \ ts_fstab_add "LABEL=$LABEL" $TS_CMD_MOUNT $DEVICE 2>&1 >> $TS_OUTPUT -grep -q $DEVICE /proc/mounts || ts_die "Cannot found $DEVICE in /proc/mounts" $DEVICE +ts_is_mounted $DEVICE || ts_die "Cannot found $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "Cannot umount $DEVICE" $DEVICE ts_device_deinit $DEVICE diff --git a/tests/ts-fstab-devname2uuid b/tests/ts-fstab-devname2uuid index f9f62c89..d6bf72b9 100755 --- a/tests/ts-fstab-devname2uuid +++ b/tests/ts-fstab-devname2uuid @@ -40,7 +40,7 @@ UUID=$(ts_uuid_by_devname $DEVICE) ts_fstab_add "UUID=$UUID" $TS_CMD_MOUNT $DEVICE 2>&1 >> $TS_OUTPUT -grep -q $DEVICE /proc/mounts || ts_die "Cannot found $DEVICE in /proc/mounts" $DEVICE +ts_is_mounted $DEVICE || ts_die "Cannot found $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "Cannot umount $DEVICE" $DEVICE ts_device_deinit $DEVICE diff --git a/tests/ts-fstab-label b/tests/ts-fstab-label index ac5ad130..d47fbb16 100755 --- a/tests/ts-fstab-label +++ b/tests/ts-fstab-label @@ -44,19 +44,17 @@ ts_fstab_add "LABEL=$LABEL" # variant A) $TS_CMD_MOUNT $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT -grep -q $DEVICE /proc/mounts || ts_die "A) Cannot found $DEVICE in /proc/mounts" $DEVICE +ts_is_mounted $DEVICE || ts_die "A) Cannot found $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE" $DEVICE # variant B) $TS_CMD_MOUNT -L $LABEL 2>&1 >> $TS_OUTPUT -grep -q $DEVICE /proc/mounts \ - || ts_die "B) Cannot found $DEVICE in /proc/mounts" $DEVICE +ts_is_mounted $DEVICE || ts_die "B) Cannot found $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" $DEVICE # variant C) $TS_CMD_MOUNT LABEL=$LABEL 2>&1 >> $TS_OUTPUT -grep -q $DEVICE /proc/mounts \ - || ts_die "C) Cannot found $DEVICE in /proc/mounts" $DEVICE +ts_is_mounted $DEVICE || ts_die "C) Cannot found $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "C) Cannot umount $DEVICE" $DEVICE ts_device_deinit $DEVICE diff --git a/tests/ts-fstab-label2devname b/tests/ts-fstab-label2devname index eb58c25c..a6e1e7a9 100755 --- a/tests/ts-fstab-label2devname +++ b/tests/ts-fstab-label2devname @@ -44,14 +44,12 @@ ts_fstab_add "$DEVICE" # variant A) $TS_CMD_MOUNT -L $LABEL 2>&1 >> $TS_OUTPUT -grep -q $DEVICE /proc/mounts \ - || ts_die "A) Cannot found $DEVICE in /proc/mounts" $DEVICE +ts_is_mounted $DEVICE || ts_die "A) Cannot found $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE" $DEVICE # variant B) $TS_CMD_MOUNT "LABEL=$LABEL" 2>&1 >> $TS_OUTPUT -grep -q $DEVICE /proc/mounts \ - || ts_die "B) Cannot found $DEVICE in /proc/mounts" $DEVICE +ts_is_mounted $DEVICE || ts_die "B) Cannot found $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" $DEVICE ts_device_deinit $DEVICE diff --git a/tests/ts-fstab-label2uuid b/tests/ts-fstab-label2uuid index 7eaed4e3..18960164 100755 --- a/tests/ts-fstab-label2uuid +++ b/tests/ts-fstab-label2uuid @@ -48,14 +48,12 @@ ts_fstab_add "UUID=$UUID" # variant A) $TS_CMD_MOUNT -L $LABEL 2>&1 >> $TS_OUTPUT -grep -q $DEVICE /proc/mounts \ - || ts_die "A) Cannot found $DEVICE in /proc/mounts" $DEVICE +ts_is_mounted $DEVICE || ts_die "A) Cannot found $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE" $DEVICE # variant B) $TS_CMD_MOUNT "LABEL=$LABEL" 2>&1 >> $TS_OUTPUT -grep -q $DEVICE /proc/mounts \ - || ts_die "B) Cannot found $DEVICE in /proc/mounts" $DEVICE +ts_is_mounted $DEVICE || ts_die "B) Cannot found $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" $DEVICE ts_device_deinit $DEVICE diff --git a/tests/ts-fstab-symlink b/tests/ts-fstab-symlink index 5722d2c3..336ecdba 100755 --- a/tests/ts-fstab-symlink +++ b/tests/ts-fstab-symlink @@ -43,8 +43,7 @@ ts_fstab_add $LINKNAME $TS_MOUNTPOINT "auto" "defaults,user" # variant A) -- UID=0 $TS_CMD_MOUNT $LINKNAME 2>&1 >> $TS_OUTPUT -grep -q $DEVICE /proc/mounts \ - || ts_die "A) Cannot found $DEVICE in /proc/mounts" $DEVICE +ts_is_mounted $DEVICE || ts_die "A) Cannot found $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $LINKNAME || ts_die "A) Cannot umount $LINKNAME" $DEVICE # varian B) @@ -52,8 +51,7 @@ ts_init_suid $TS_CMD_MOUNT ts_init_suid $TS_CMD_UMOUNT su $TS_TESTUSER -c "$TS_CMD_MOUNT $LINKNAME" 2>&1 >> $TS_OUTPUT -grep -q $DEVICE /proc/mounts \ - || ts_die "B) Cannot found $DEVICE in /proc/mounts" $DEVICE +ts_is_mounted $DEVICE || ts_die "B) Cannot found $DEVICE in /proc/mounts" $DEVICE su $TS_TESTUSER -c "$TS_CMD_UMOUNT $LINKNAME" 2>&1 >> $TS_OUTPUT \ || ts_die "B) Cannot umount $LINKNAME" $DEVICE diff --git a/tests/ts-fstab-uuid b/tests/ts-fstab-uuid index ff39a5f8..bdd56d77 100755 --- a/tests/ts-fstab-uuid +++ b/tests/ts-fstab-uuid @@ -43,17 +43,17 @@ ts_fstab_add "UUID=$UUID" # varian A) $TS_CMD_MOUNT $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT -grep -q $DEVICE /proc/mounts || ts_die "A) Cannot found $DEVICE in /proc/mounts" $DEVICE +ts_is_mounted $DEVICE || ts_die "A) Cannot found $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE" $DEVICE # varian B) $TS_CMD_MOUNT -U $UUID 2>&1 >> $TS_OUTPUT -grep -q $DEVICE /proc/mounts || ts_die "B) Cannot found $DEVICE in /proc/mounts" $DEVICE +ts_is_mounted $DEVICE || ts_die "B) Cannot found $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" $DEVICE # varian C) $TS_CMD_MOUNT UUID=$UUID 2>&1 >> $TS_OUTPUT -grep -q $DEVICE /proc/mounts || ts_die "C) Cannot found $DEVICE in /proc/mounts" $DEVICE +ts_is_mounted $DEVICE || ts_die "C) Cannot found $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "C) Cannot umount $DEVICE" $DEVICE ts_device_deinit $DEVICE diff --git a/tests/ts-fstab-uuid2devname b/tests/ts-fstab-uuid2devname index 0c3e605f..5feac01c 100755 --- a/tests/ts-fstab-uuid2devname +++ b/tests/ts-fstab-uuid2devname @@ -43,14 +43,12 @@ ts_fstab_add "$DEVICE" # variant A) $TS_CMD_MOUNT -U $UUID 2>&1 >> $TS_OUTPUT -grep -q $DEVICE /proc/mounts \ - || ts_die "A) Cannot found $DEVICE in /proc/mounts" $DEVICE +ts_is_mounted $DEVICE || ts_die "A) Cannot found $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE" $DEVICE # variant B) $TS_CMD_MOUNT "UUID=$UUID" 2>&1 >> $TS_OUTPUT -grep -q $DEVICE /proc/mounts \ - || ts_die "B) Cannot found $DEVICE in /proc/mounts" $DEVICE +ts_is_mounted $DEVICE || ts_die "B) Cannot found $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" $DEVICE ts_device_deinit $DEVICE diff --git a/tests/ts-fstab-uuid2label b/tests/ts-fstab-uuid2label index b99323cc..fff28ef2 100755 --- a/tests/ts-fstab-uuid2label +++ b/tests/ts-fstab-uuid2label @@ -48,13 +48,12 @@ ts_fstab_add "LABEL=$LABEL" # variant A) $TS_CMD_MOUNT -U $UUID 2>&1 >> $TS_OUTPUT -grep -q $DEVICE /proc/mounts \ - || ts_die "A) Cannot found $DEVICE in /proc/mounts" $DEVICE +ts_is_mounted $DEVICE || ts_die "A) Cannot found $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE" $DEVICE # variant B) $TS_CMD_MOUNT "UUID=$UUID" 2>&1 >> $TS_OUTPUT -grep -q $DEVICE /proc/mounts || ts_die "B) Cannot found $DEVICE in /proc/mounts" $DEVICE +ts_is_mounted $DEVICE || ts_die "B) Cannot found $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" $DEVICE ts_device_deinit $DEVICE diff --git a/tests/ts-mount-devname b/tests/ts-mount-devname index eceb5e91..f0661f32 100755 --- a/tests/ts-mount-devname +++ b/tests/ts-mount-devname @@ -37,7 +37,7 @@ ts_device_has "TYPE" "ext3" $DEVICE || ts_die "Cannot found ext3 on $DEVICE" $DE $TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT -grep -q $DEVICE /proc/mounts || ts_die "Cannot found $DEVICE in /proc/mounts" $DEVICE +ts_is_mounted $DEVICE || ts_die "Cannot found $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "Cannot umount $DEVICE" $DEVICE diff --git a/tests/ts-mount-label b/tests/ts-mount-label index eb640042..a5b28fa9 100755 --- a/tests/ts-mount-label +++ b/tests/ts-mount-label @@ -43,14 +43,12 @@ ts_udev_dev_support "by-label" $LABEL \ # variant A) $TS_CMD_MOUNT -L $LABEL $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT -grep -q $DEVICE /proc/mounts \ - || ts_die "A) Cannot found $DEVICE in /proc/mounts" $DEVICE +ts_is_mounted $DEVICE || ts_die "A) Cannot found $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE" $DEVICE # variant B) $TS_CMD_MOUNT LABEL=$LABEL $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT -grep -q $DEVICE /proc/mounts \ - || ts_die "B) Cannot found $DEVICE in /proc/mounts" $DEVICE +ts_is_mounted $DEVICE || ts_die "B) Cannot found $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" $DEVICE ts_device_deinit $DEVICE diff --git a/tests/ts-mount-uuid b/tests/ts-mount-uuid index f8bd9a91..ee186f07 100755 --- a/tests/ts-mount-uuid +++ b/tests/ts-mount-uuid @@ -42,12 +42,12 @@ ts_udev_dev_support "by-uuid" $UUID \ # variant A) $TS_CMD_MOUNT -U $UUID $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT -grep -q $DEVICE /proc/mounts || ts_die "A) Cannot found $DEVICE in /proc/mounts" $DEVICE +ts_is_mounted $DEVICE || ts_die "A) Cannot found $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE" $DEVICE # variant B) $TS_CMD_MOUNT UUID=$UUID $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT -grep -q $DEVICE /proc/mounts || ts_die "B) Cannot found $DEVICE in /proc/mounts" $DEVICE +ts_is_mounted $DEVICE || ts_die "B) Cannot found $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" $DEVICE ts_device_deinit $DEVICE