]> err.no Git - util-linux/commitdiff
tests: add functions for work withdisk images
authorKarel Zak <kzak@redhat.com>
Tue, 19 May 2009 14:13:09 +0000 (16:13 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 19 May 2009 14:13:09 +0000 (16:13 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
tests/functions.sh

index b2e17f3ca48e30cf1c1cc42ddcc913378a758c96..5e8509f720bb13aea3c44ff718b63756d1c967be 100644 (file)
@@ -246,13 +246,23 @@ function ts_die {
        ts_finalize
 }
 
-function ts_device_init {
-       local img="$TS_OUTDIR/${TS_TESTNAME}.img"
-       local dev=""
+function ts_image_md5sum {
+       local img=${1:-"$TS_OUTDIR/${TS_TESTNAME}.img"}
+       echo $(md5sum "$img" | awk '{printf $1}') $(basename "$img")
+}
 
-       dd if=/dev/zero of="$img" bs=1M count=5 &> /dev/null
+function ts_image_init {
+       local mib=${1:-"5"}     # size in MiBs
+       local img=${2:-"$TS_OUTDIR/${TS_TESTNAME}.img"}
+       
+       dd if=/dev/zero of="$img" bs=1M count=$mib &> /dev/null
+       echo "$img"
+       return 0
+}
 
-       dev=$($TS_CMD_LOSETUP -s -f "$img")
+function ts_device_init {
+       local img=$(ts_image_init)
+       local dev=$($TS_CMD_LOSETUP -s -f "$img")
 
        if [ -z "$dev" ]; then
                ts_device_deinit $dev