summaryrefslogtreecommitdiffstats
path: root/tests/functions.sh
diff options
context:
space:
mode:
authorKarel Zak2007-10-12 00:33:01 +0200
committerKarel Zak2007-10-12 00:40:01 +0200
commitec3f45d33cc431832a4e5a49848b613fb2b6ecc3 (patch)
tree5ab3ac7b970d75de973227d4d767cf8f85d11165 /tests/functions.sh
parentmount: -L|-U segfault when label or uuid doesn't exist (diff)
downloadkernel-qcow2-util-linux-ec3f45d33cc431832a4e5a49848b613fb2b6ecc3.tar.gz
kernel-qcow2-util-linux-ec3f45d33cc431832a4e5a49848b613fb2b6ecc3.tar.xz
kernel-qcow2-util-linux-ec3f45d33cc431832a4e5a49848b613fb2b6ecc3.zip
tests: fix blkid cache usage
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'tests/functions.sh')
-rw-r--r--tests/functions.sh30
1 files changed, 20 insertions, 10 deletions
diff --git a/tests/functions.sh b/tests/functions.sh
index fffd7946e..7b555f5fe 100644
--- a/tests/functions.sh
+++ b/tests/functions.sh
@@ -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
}