]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: add blkdiscard offsets test
authorFederico Simoncelli <fsimonce@redhat.com>
Fri, 24 Oct 2014 15:13:53 +0000 (15:13 +0000)
committerKarel Zak <kzak@redhat.com>
Mon, 27 Oct 2014 08:16:46 +0000 (09:16 +0100)
Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
tests/commands.sh
tests/expected/blkdiscard/offsets [new file with mode: 0644]
tests/ts/blkdiscard/offsets [new file with mode: 0755]

index 4c7455e4ca5f2caf03104d000fce507715c92ce4..e11bd2ab28b140fab6edf145c89dc4818c9dcfdd 100644 (file)
@@ -29,6 +29,7 @@ TS_HELPER_SYSINFO="$top_builddir/test_sysinfo"
 # paths to commands
 TS_CMD_ADDPART=${TS_CMD_ADDPART:-"$top_builddir/addpart"}
 TS_CMD_DELPART=${TS_CMD_DELPART:-"$top_builddir/delpart"}
+TS_CMD_BLKDISCARD=${TS_CMD_BLKID-"$top_builddir/blkdiscard"}
 TS_CMD_BLKID=${TS_CMD_BLKID-"$top_builddir/blkid"}
 TS_CMD_CAL=${TS_CMD_CAL-"$top_builddir/cal"}
 TS_CMD_COLRM=${TS_CMD_COLRM:-"$top_builddir/colrm"}
diff --git a/tests/expected/blkdiscard/offsets b/tests/expected/blkdiscard/offsets
new file mode 100644 (file)
index 0000000..766c39d
--- /dev/null
@@ -0,0 +1,16 @@
+create loop device from image
+testing offsets with full block size
+Discarded 10485760 bytes from the offset 0
+Discarded 10485248 bytes from the offset 512
+Discarded 10485248 bytes from the offset 512
+Discarded 10485248 bytes from the offset 512
+Discarded 10484736 bytes from the offset 1024
+testing offsets with specific length
+Discarded 5242880 bytes from the offset 0
+Discarded 5242880 bytes from the offset 0
+Discarded 5242880 bytes from the offset 0
+Discarded 5242880 bytes from the offset 512
+Discarded 5242880 bytes from the offset 512
+Discarded 5242880 bytes from the offset 512
+Discarded 5242880 bytes from the offset 1024
+detach loop device from image
diff --git a/tests/ts/blkdiscard/offsets b/tests/ts/blkdiscard/offsets
new file mode 100755 (executable)
index 0000000..04bd437
--- /dev/null
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2014 Federico Simoncelli <fsimonce@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="offsets"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_BLKDISCARD"
+
+ts_skip_nonroot
+ts_check_losetup
+
+set -o pipefail
+
+ORIGPWD=$(pwd)
+IMAGE_NAME="${TS_TESTNAME}-loop.img"
+IMAGE_PATH="$TS_OUTDIR/$IMAGE_NAME"
+
+truncate -s 10M $IMAGE_PATH
+
+ts_log "create loop device from image"
+DEVICE=$($TS_CMD_LOSETUP --show -f $IMAGE_PATH)
+CMD_SED_DEVICE="sed s#$DEVICE:\s##"
+
+ts_log "testing offsets with full block size"
+$TS_CMD_BLKDISCARD -v $DEVICE 2>&1 | $CMD_SED_DEVICE >> $TS_OUTPUT
+$TS_CMD_BLKDISCARD -v -o 1 $DEVICE 2>&1 | $CMD_SED_DEVICE >> $TS_OUTPUT
+$TS_CMD_BLKDISCARD -v -o 511 $DEVICE 2>&1 | $CMD_SED_DEVICE >> $TS_OUTPUT
+$TS_CMD_BLKDISCARD -v -o 512 $DEVICE 2>&1 | $CMD_SED_DEVICE >> $TS_OUTPUT
+$TS_CMD_BLKDISCARD -v -o 1024 $DEVICE 2>&1 | $CMD_SED_DEVICE >> $TS_OUTPUT
+
+ts_log "testing offsets with specific length"
+$TS_CMD_BLKDISCARD -v -l 5242880 $DEVICE 2>&1 | $CMD_SED_DEVICE >> $TS_OUTPUT
+$TS_CMD_BLKDISCARD -v -l 5242881 $DEVICE 2>&1 | $CMD_SED_DEVICE >> $TS_OUTPUT
+$TS_CMD_BLKDISCARD -v -l 5243391 $DEVICE 2>&1 | $CMD_SED_DEVICE >> $TS_OUTPUT
+$TS_CMD_BLKDISCARD -v -o 1 -l 5242880 $DEVICE 2>&1 | $CMD_SED_DEVICE >> $TS_OUTPUT
+$TS_CMD_BLKDISCARD -v -o 511 -l 5242880 $DEVICE 2>&1 | $CMD_SED_DEVICE >> $TS_OUTPUT
+$TS_CMD_BLKDISCARD -v -o 512 -l 5242880 $DEVICE 2>&1 | $CMD_SED_DEVICE >> $TS_OUTPUT
+$TS_CMD_BLKDISCARD -v -o 1024 -l 5242880 $DEVICE 2>&1 | $CMD_SED_DEVICE >> $TS_OUTPUT
+
+ts_log "detach loop device from image"
+$TS_CMD_LOSETUP -d $DEVICE 2>&1 >> $TS_OUTPUT
+
+ts_cd "$ORIGPWD"
+
+ts_finalize