summaryrefslogtreecommitdiffstats
path: root/tests/functions.sh
diff options
context:
space:
mode:
authorKarel Zak2009-05-19 16:13:09 +0200
committerKarel Zak2009-05-19 16:13:09 +0200
commit35c636e13b28251f6f1318241fe351fd144fd8dc (patch)
treec8b3f239c8de3eb105e8dab00ac5b443aea64b9c /tests/functions.sh
parentfdisk: (and cfdisk) fix to be consistent about maximum heads (diff)
downloadkernel-qcow2-util-linux-35c636e13b28251f6f1318241fe351fd144fd8dc.tar.gz
kernel-qcow2-util-linux-35c636e13b28251f6f1318241fe351fd144fd8dc.tar.xz
kernel-qcow2-util-linux-35c636e13b28251f6f1318241fe351fd144fd8dc.zip
tests: add functions for work withdisk images
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'tests/functions.sh')
-rw-r--r--tests/functions.sh20
1 files changed, 15 insertions, 5 deletions
diff --git a/tests/functions.sh b/tests/functions.sh
index b2e17f3ca..5e8509f72 100644
--- a/tests/functions.sh
+++ b/tests/functions.sh
@@ -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