]> err.no Git - util-linux/commitdiff
tests: code refactoring -- new ts_udev_loop_support function
authorKarel Zak <kzak@redhat.com>
Wed, 16 May 2007 00:07:07 +0000 (02:07 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 18 May 2007 11:09:12 +0000 (13:09 +0200)
The patch moves generic and duplicated code to a new
ts_udev_loop_support function.

Signed-off-by: Karel Zak <kzak@redhat.com>
tests/functions.sh
tests/ts-cramfs-mkfs
tests/ts-mkswap-doit

index 86abfb4e98aca3b6583194d43818c3a48d87c964..6c0658b1b29f55eb85a532a1ff116d9c07315671 100644 (file)
@@ -99,4 +99,16 @@ function ts_device_deinit {
                rm -f "$IMAGE" &> /dev/null
        fi
 }
+
+function ts_udev_loop_support {
+       ldd $TS_CMD_MOUNT | grep -q 'libvolume_id' 2>&1 >> $TS_OUTPUT
+       if [ "$?" == "0" ]; then
+               HAS_VOLUMEID="yes"
+       fi
+       if [ -n "$HAS_VOLUMEID" ] && [ ! -L "/dev/disk/by-label/$1" ]; then
+               return 1
+       fi
+       return 0
+}
+
                
index c1f46f11609413d3e4adc94107f13acc70e13b34..715f575c099c4ec5c1e646bc12ec686b3f92ef92 100755 (executable)
@@ -36,11 +36,6 @@ 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
@@ -85,8 +80,9 @@ if [ "$($TS_CMD_MOUNT --guess-fstype $DEVICE)" != "cramfs" ]; then
        ts_finalize
 fi
 
-if [ -n "$HAS_VOLUMEID" ] && [ ! -L "/dev/disk/by-label/$LABEL" ]; then
-       $TS_CMD_LOSETUP -d $DEVICE 2>&1 >> $TS_OUTPUT
+ts_udev_loop_support $LABEL
+if [ "$?" != "0" ]; then
+       ts_device_deinit;
        ts_skip "udev ignores /dev/loop*"
 fi
 
index cd567cf32dead88841e36508fae338da5177b14d..600acbac7d6198de2705cfa1d231bb179ed92d5f 100755 (executable)
@@ -32,11 +32,6 @@ touch $TS_OUTPUT
 
 LABEL="testSwap"
 
-ldd $TS_CMD_SWAPON | grep -q 'libvolume_id' 2>&1 >> $TS_OUTPUT
-if [ "$?" == "0" ]; then
-       HAS_VOLUMEID="yes"
-fi
-
 ts_device_init || ts_finalize
 $TS_CMD_MKSWAP -L $LABEL $DEVICE 2>&1 >> $TS_OUTPUT
 
@@ -47,8 +42,9 @@ if [ "$($TS_CMD_MOUNT --guess-fstype $DEVICE)" != "swap" ]; then
        ts_finalize
 fi
 
-if [ -n "$HAS_VOLUMEID" ] && [ ! -L "/dev/disk/by-label/$LABEL" ]; then
-       ts_device_deinit
+ts_udev_loop_support $LABEL
+if [ "$?" != "0" ]; then
+       ts_device_deinit;
        ts_skip "udev ignores /dev/loop*"
 fi