summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/functions.sh50
-rwxr-xr-xtests/ts/libmount/tabfiles-tags6
-rwxr-xr-xtests/ts/libmount/tabfiles-tags-py6
-rwxr-xr-xtests/ts/mount/fstab-devname2label2
-rwxr-xr-xtests/ts/mount/fstab-devname2uuid6
-rwxr-xr-xtests/ts/mount/fstab-label2
-rwxr-xr-xtests/ts/mount/fstab-label2devname2
-rwxr-xr-xtests/ts/mount/fstab-label2uuid7
-rwxr-xr-xtests/ts/mount/fstab-uuid6
-rwxr-xr-xtests/ts/mount/fstab-uuid2devname6
-rwxr-xr-xtests/ts/mount/fstab-uuid2label7
-rwxr-xr-xtests/ts/mount/label2
-rwxr-xr-xtests/ts/mount/uuid6
-rwxr-xr-xtests/ts/swapon/label4
-rwxr-xr-xtests/ts/swapon/uuid6
15 files changed, 59 insertions, 59 deletions
diff --git a/tests/functions.sh b/tests/functions.sh
index 66eaa9d6e..0f991881a 100644
--- a/tests/functions.sh
+++ b/tests/functions.sh
@@ -555,16 +555,34 @@ function ts_device_deinit {
fi
}
+function ts_blkidtag_by_devname()
+{
+ local tag=$1
+ local dev=$2
+ local out
+ local rval
+
+ out=$($TS_CMD_BLKID -p -s "$tag" -o value "$dev")
+ rval=$?
+ printf "%s\n" "$out"
+
+ test -n "$out" -a "$rval" = "0"
+ return $?
+}
+
function ts_uuid_by_devname {
- echo $($TS_CMD_BLKID -p -s UUID -o value $1)
+ ts_blkidtag_by_devname "UUID" "$1"
+ return $?
}
function ts_label_by_devname {
- echo $($TS_CMD_BLKID -p -s LABEL -o value $1)
+ ts_blkidtag_by_devname "LABEL" "$1"
+ return $?
}
function ts_fstype_by_devname {
- echo $($TS_CMD_BLKID -p -s TYPE -o value $1)
+ ts_blkidtag_by_devname "TYPE" "$1"
+ return $?
}
function ts_device_has {
@@ -573,24 +591,24 @@ function ts_device_has {
local DEV="$3"
local vl=""
- case $TAG in
- "TYPE") vl=$(ts_fstype_by_devname $DEV);;
- "LABEL") vl=$(ts_label_by_devname $DEV);;
- "UUID") vl=$(ts_uuid_by_devname $DEV);;
- *) return 1;;
- esac
-
- if [ "$vl" == "$VAL" ]; then
- return 0
- fi
- return 1
+ vl=$(ts_blkidtag_by_devname "$TAG" "$DEV")
+ test $? = 0 -a "$vl" = "$VAL"
+ return $?
}
-function ts_device_has_uuid {
- ts_uuid_by_devname "$1" | egrep -q '^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$'
+function ts_is_uuid()
+{
+ printf "%s\n" "$1" | egrep -q '^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$'
return $?
}
+function ts_udevadm_settle()
+{
+ local dev=$1 # optional, might be empty
+ shift # all other args are tags, LABEL, UUID, ...
+ udevadm settle
+}
+
function ts_mount {
local out
local result
diff --git a/tests/ts/libmount/tabfiles-tags b/tests/ts/libmount/tabfiles-tags
index 4933876d4..38858f47b 100755
--- a/tests/ts/libmount/tabfiles-tags
+++ b/tests/ts/libmount/tabfiles-tags
@@ -26,9 +26,8 @@ UUID="de1bc6e9-34ab-4151-a1d7-900042eee8d9"
# Create filesystem
#
mkfs.ext3 -F -L $LABEL $TS_DEVICE -U $UUID &> /dev/null || ts_die "Cannot make ext3 on $TS_DEVICE"
-udevadm settle
-
-ts_device_has_uuid $TS_DEVICE || ts_die "Cannot find UUID on $TS_DEVICE"
+ts_device_has "LABEL" "$LABEL" "$TS_DEVICE" || ts_die "Cannot find LABEL '$LABEL' on $TS_DEVICE"
+ts_device_has "UUID" "$UUID" "$TS_DEVICE" || ts_die "Cannot find $UUID on $TS_DEVICE"
FSTAB="$TS_OUTDIR/fstab"
@@ -36,6 +35,7 @@ FSTAB="$TS_OUTDIR/fstab"
# Label in fstab
#
echo "LABEL=$LABEL /mnt/mountpoint auto defaults" > $FSTAB
+ts_udevadm_settle "$TS_DEVICE" "LABEL" "UUID"
ts_init_subtest "fstab-label2uuid"
ts_run $TESTPROG --find-forward $FSTAB source "UUID=$UUID" &> $TS_OUTPUT
diff --git a/tests/ts/libmount/tabfiles-tags-py b/tests/ts/libmount/tabfiles-tags-py
index c1ad596bf..5e72a6f90 100755
--- a/tests/ts/libmount/tabfiles-tags-py
+++ b/tests/ts/libmount/tabfiles-tags-py
@@ -30,9 +30,8 @@ UUID="de1bc6e9-34ab-4151-a1d7-900042eee8d9"
# Create filesystem
#
mkfs.ext3 -F -L $LABEL $TS_DEVICE -U $UUID &> /dev/null || ts_die "Cannot make ext3 on $TS_DEVICE"
-udevadm settle
-
-ts_device_has_uuid $TS_DEVICE || ts_die "Cannot find UUID on $TS_DEVICE"
+ts_device_has "LABEL" "$LABEL" "$TS_DEVICE" || ts_die "Cannot find LABEL '$LABEL' on $TS_DEVICE"
+ts_device_has "UUID" "$UUID" "$TS_DEVICE" || ts_die "Cannot find $UUID on $TS_DEVICE"
FSTAB="$TS_OUTDIR/fstab"
@@ -40,6 +39,7 @@ FSTAB="$TS_OUTDIR/fstab"
# Label in fstab
#
echo "LABEL=$LABEL /mnt/mountpoint auto defaults" > $FSTAB
+ts_udevadm_settle "$DEVICE" "LABEL" "UUID"
ts_init_subtest "fstab-label2uuid"
$PYTHON $TESTPROG --find-forward $FSTAB source "UUID=$UUID" &> $TS_OUTPUT
diff --git a/tests/ts/mount/fstab-devname2label b/tests/ts/mount/fstab-devname2label
index 380b91d03..02ef1ef18 100755
--- a/tests/ts/mount/fstab-devname2label
+++ b/tests/ts/mount/fstab-devname2label
@@ -33,13 +33,13 @@ ts_device_init
DEVICE=$TS_LODEV
mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE"
-
ts_device_has "LABEL" $LABEL $DEVICE \
|| ts_die "Cannot find LABEL '$LABEL' on $DEVICE"
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
ts_fstab_add "LABEL=$LABEL"
+ts_udevadm_settle "$DEVICE" "LABEL"
$TS_CMD_MOUNT $DEVICE >> $TS_OUTPUT 2>&1
ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts"
diff --git a/tests/ts/mount/fstab-devname2uuid b/tests/ts/mount/fstab-devname2uuid
index 3ed19d2df..4cd4f4502 100755
--- a/tests/ts/mount/fstab-devname2uuid
+++ b/tests/ts/mount/fstab-devname2uuid
@@ -32,14 +32,12 @@ ts_device_init
DEVICE=$TS_LODEV
mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE"
-
-ts_device_has_uuid $DEVICE || ts_die "Cannot find UUID on $DEVICE"
-
-UUID=$(ts_uuid_by_devname $DEVICE)
+UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE"
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
ts_fstab_add "UUID=$UUID"
+ts_udevadm_settle "$DEVICE" "UUID"
$TS_CMD_MOUNT $DEVICE >> $TS_OUTPUT 2>&1
ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts"
diff --git a/tests/ts/mount/fstab-label b/tests/ts/mount/fstab-label
index bc5a15f4f..be6292d17 100755
--- a/tests/ts/mount/fstab-label
+++ b/tests/ts/mount/fstab-label
@@ -33,13 +33,13 @@ ts_device_init
DEVICE=$TS_LODEV
mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE"
-
ts_device_has "LABEL" $LABEL $DEVICE \
|| ts_die "Cannot find LABEL '$LABEL' on $DEVICE"
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
ts_fstab_add "LABEL=$LABEL"
+ts_udevadm_settle "$DEVICE" "LABEL"
# variant A)
$TS_CMD_MOUNT $TS_MOUNTPOINT >> $TS_OUTPUT 2>&1
diff --git a/tests/ts/mount/fstab-label2devname b/tests/ts/mount/fstab-label2devname
index 3dcaad54a..ee4642e25 100755
--- a/tests/ts/mount/fstab-label2devname
+++ b/tests/ts/mount/fstab-label2devname
@@ -33,13 +33,13 @@ ts_device_init
DEVICE=$TS_LODEV
mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE"
-
ts_device_has "LABEL" $LABEL $DEVICE \
|| ts_die "Cannot find LABEL '$LABEL' on $DEVICE"
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
ts_fstab_add "$DEVICE"
+ts_udevadm_settle "$DEVICE" "LABEL"
# variant A)
$TS_CMD_MOUNT -L $LABEL >> $TS_OUTPUT 2>&1
diff --git a/tests/ts/mount/fstab-label2uuid b/tests/ts/mount/fstab-label2uuid
index 486d07041..0d2b93154 100755
--- a/tests/ts/mount/fstab-label2uuid
+++ b/tests/ts/mount/fstab-label2uuid
@@ -34,17 +34,14 @@ ts_device_init
DEVICE=$TS_LODEV
mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE"
-
ts_device_has "LABEL" $LABEL $DEVICE \
|| ts_die "Cannot find LABEL '$LABEL' on $DEVICE"
-
-ts_device_has_uuid $DEVICE || ts_die "Cannot find UUID on $DEVICE"
-
-UUID=$(ts_uuid_by_devname $DEVICE)
+UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE"
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
ts_fstab_add "UUID=$UUID"
+ts_udevadm_settle "$DEVICE" "LABEL" "UUID"
# variant A)
$TS_CMD_MOUNT -L $LABEL >> $TS_OUTPUT 2>&1
diff --git a/tests/ts/mount/fstab-uuid b/tests/ts/mount/fstab-uuid
index afe414dc4..1c588fc1b 100755
--- a/tests/ts/mount/fstab-uuid
+++ b/tests/ts/mount/fstab-uuid
@@ -32,14 +32,12 @@ ts_device_init
DEVICE=$TS_LODEV
mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE"
-
-ts_device_has_uuid $DEVICE || ts_die "Cannot find UUID on $DEVICE"
-
-UUID=$(ts_uuid_by_devname $DEVICE)
+UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE"
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
ts_fstab_add "UUID=$UUID"
+ts_udevadm_settle "$DEVICE" "UUID"
# varian A)
$TS_CMD_MOUNT $TS_MOUNTPOINT >> $TS_OUTPUT 2>&1
diff --git a/tests/ts/mount/fstab-uuid2devname b/tests/ts/mount/fstab-uuid2devname
index 3197148bd..39aed65a9 100755
--- a/tests/ts/mount/fstab-uuid2devname
+++ b/tests/ts/mount/fstab-uuid2devname
@@ -32,14 +32,12 @@ ts_device_init
DEVICE=$TS_LODEV
mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE"
-
-ts_device_has_uuid $DEVICE || ts_die "Cannot find UUID on $DEVICE"
-
-UUID=$(ts_uuid_by_devname $DEVICE)
+UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE"
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
ts_fstab_add "$DEVICE"
+ts_udevadm_settle "$DEVICE" "UUID"
# variant A)
$TS_CMD_MOUNT -U $UUID >> $TS_OUTPUT 2>&1
diff --git a/tests/ts/mount/fstab-uuid2label b/tests/ts/mount/fstab-uuid2label
index 22c5647dd..4676c9a7b 100755
--- a/tests/ts/mount/fstab-uuid2label
+++ b/tests/ts/mount/fstab-uuid2label
@@ -33,17 +33,14 @@ ts_device_init
DEVICE=$TS_LODEV
mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE"
-
ts_device_has "LABEL" $LABEL $DEVICE \
|| ts_die "Cannot find LABEL '$LABEL' on $DEVICE"
-
-ts_device_has_uuid $DEVICE || ts_die "Cannot find UUID on $DEVICE"
-
-UUID=$(ts_uuid_by_devname $DEVICE)
+UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE"
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
ts_fstab_add "LABEL=$LABEL"
+ts_udevadm_settle "$DEVICE" "LABEL" "UUID"
# variant A)
$TS_CMD_MOUNT -U $UUID >> $TS_OUTPUT 2>&1
diff --git a/tests/ts/mount/label b/tests/ts/mount/label
index d3a571bc4..45da02b6e 100755
--- a/tests/ts/mount/label
+++ b/tests/ts/mount/label
@@ -34,11 +34,11 @@ ts_device_init
DEVICE=$TS_LODEV
mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE"
-udevadm settle
ts_device_has "LABEL" $LABEL $DEVICE \
|| ts_die "Cannot find LABEL '$LABEL' on $DEVICE"
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+ts_udevadm_settle "$DEVICE" "LABEL"
# variant A)
$TS_CMD_MOUNT -L $LABEL $TS_MOUNTPOINT >> $TS_OUTPUT 2>&1
diff --git a/tests/ts/mount/uuid b/tests/ts/mount/uuid
index efd2774ed..36f75cef9 100755
--- a/tests/ts/mount/uuid
+++ b/tests/ts/mount/uuid
@@ -32,12 +32,10 @@ ts_device_init
DEVICE=$TS_LODEV
mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE"
-
-ts_device_has_uuid $DEVICE || ts_die "Cannot find UUID on $DEVICE"
-
-UUID=$(ts_uuid_by_devname $DEVICE)
+UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE"
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+ts_udevadm_settle "$DEVICE" "UUID"
# variant A)
$TS_CMD_MOUNT -U $UUID $TS_MOUNTPOINT >> $TS_OUTPUT 2>&1
diff --git a/tests/ts/swapon/label b/tests/ts/swapon/label
index 210a12c97..1bb5dbb3e 100755
--- a/tests/ts/swapon/label
+++ b/tests/ts/swapon/label
@@ -34,11 +34,9 @@ DEVICE=$TS_LODEV
$TS_CMD_MKSWAP -L $LABEL $DEVICE > /dev/null 2>> $TS_OUTPUT \
|| ts_die "Cannot make swap on $DEVICE"
-
-udevadm settle
-
ts_device_has "LABEL" $LABEL $DEVICE \
|| ts_die "Cannot find LABEL '$LABEL' on $DEVICE"
+ts_udevadm_settle "$DEVICE" "LABEL"
$TS_CMD_SWAPON -L $LABEL >> $TS_OUTPUT 2>&1
diff --git a/tests/ts/swapon/uuid b/tests/ts/swapon/uuid
index 65af6cb6d..70e62d7f9 100755
--- a/tests/ts/swapon/uuid
+++ b/tests/ts/swapon/uuid
@@ -33,10 +33,8 @@ DEVICE=$TS_LODEV
$TS_CMD_MKSWAP $DEVICE > /dev/null 2>> $TS_OUTPUT \
|| ts_die "Cannot make swap $DEVICE"
-
-ts_device_has_uuid $DEVICE || ts_die "Cannot find UUID on $DEVICE"
-
-UUID=$(ts_uuid_by_devname $DEVICE)
+UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE"
+ts_udevadm_settle "$DEVICE" "UUID"
$TS_CMD_SWAPON -U $UUID >> $TS_OUTPUT 2>&1