]> err.no Git - util-linux/commitdiff
tests: fix blkid cache usage
authorKarel Zak <kzak@redhat.com>
Thu, 11 Oct 2007 22:33:01 +0000 (00:33 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 11 Oct 2007 22:42:09 +0000 (00:42 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
tests/functions.sh
tests/ts-cramfs-mkfs

index fffd7946eb0973140482d48ac8d9bcad4218f4b0..7b555f5fece9643975af0bbca3d3795d14e5f93e 100644 (file)
@@ -155,14 +155,28 @@ function ts_die {
        ts_finalize
 }
 
+function ts_backup_cache {
+       if [ "$TS_HAS_VOLUMEID" != "yes" ] && [ -f "$TS_BLKIDCACHE" ]; then
+               cp $TS_BLKIDCACHE $OUTDIR/$TS_NAME.cache
+       fi
+}
+
+function ts_restore_cache {
+       if [ "$TS_HAS_VOLUMEID" !=  "yes" ] && [ -f "$TS_BLKIDCACHE" ] && [ -s "$OUTDIR/$TS_NAME.cache" ]; then
+               # We have to remove the device from cache otherwise
+               # libblkid will reuse cached information. The cache
+               # refresh time is 2 seconds -- that's too long. We
+               # re-use the same device more quickly.  --kzak
+               mv -f $OUTDIR/$TS_NAME.cache $TS_BLKIDCACHE
+       fi
+}
+
 function ts_device_init {
        local IMAGE="$TS_OUTDIR/$TS_NAME.img"
        local IMAGE_RE=$( echo "$IMAGE" | sed 's:/:\\/:g' )
        local DEV=""
 
-       if [ "$TS_HAS_VOLUMEID" != "yes" ] && [ -f "$TS_BLKIDCACHE" ]; then
-               cp $TS_BLKIDCACHE $OUTDIR/$TS_NAME.cache
-       fi
+       ts_backup_cache
 
        dd if=/dev/zero of="$IMAGE" bs=1M count=5 &> /dev/null
 
@@ -178,19 +192,15 @@ function ts_device_init {
        return 0                        # succes
 }
 
+
+
 function ts_device_deinit {
        local DEV="$1"
 
        if [ -b "$DEV" ]; then
                $TS_CMD_UMOUNT "$DEV" &> /dev/null
                $TS_CMD_LOSETUP -d "$DEV" &> /dev/null
-               if [ "$TS_HAS_VOLUMEID" !=  "yes" ] && [ -f "$TS_BLKIDCACHE" ] && [ -s "$OUTDIR/$TS_NAME.cache" ]; then
-                       # We have to remove the device from cache otherwise
-                       # libblkid will reuse cached information. The cache
-                       # refresh time is 2 seconds -- that's too long. We
-                       # re-use the same device more quickly.  --kzak
-                       mv -f $OUTDIR/$TS_NAME.cache $TS_BLKIDCACHE
-               fi      
+               ts_restore_cache
        fi
 }
 
index affe38d1e822bca813d35c83a7fbadf442f4d141..05673e05c0530005280b8820dd1f018542b8b2a6 100755 (executable)
@@ -62,6 +62,7 @@ md5sum $IMAGE 2>&1 >> $TS_OUTPUT
 echo >> $TS_OUTPUT
 
 ts_log "create loop device from image"
+ts_backup_cache
 DEVICE=$( $TS_CMD_LOSETUP -f )
 $TS_CMD_LOSETUP $DEVICE $IMAGE 2>&1 >> $TS_OUTPUT
 
@@ -90,5 +91,6 @@ echo >> $TS_OUTPUT
 ts_log "umount the image"
 $TS_CMD_UMOUNT $DEVICE
 $TS_CMD_LOSETUP -d $DEVICE 2>&1 >> $TS_OUTPUT
+ts_restore_cache
 ts_finalize