summaryrefslogtreecommitdiffstats
path: root/tests/ts/blkdiscard/offsets
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 13:14:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 13:14:44 +0000
commit30ff6afe596eddafacf22b1a5b2d1a3d6254ea15 (patch)
tree9b788335f92174baf7ee18f03ca8330b8c19ce2b /tests/ts/blkdiscard/offsets
parentInitial commit. (diff)
downloadutil-linux-30ff6afe596eddafacf22b1a5b2d1a3d6254ea15.tar.xz
util-linux-30ff6afe596eddafacf22b1a5b2d1a3d6254ea15.zip
Adding upstream version 2.36.1.upstream/2.36.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-xtests/ts/blkdiscard/offsets101
1 files changed, 101 insertions, 0 deletions
diff --git a/tests/ts/blkdiscard/offsets b/tests/ts/blkdiscard/offsets
new file mode 100755
index 0000000..9dddc35
--- /dev/null
+++ b/tests/ts/blkdiscard/offsets
@@ -0,0 +1,101 @@
+#!/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
+
+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)
+ts_register_loop_device "$DEVICE"
+
+function run_tscmd {
+ local ret
+ "$@" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ ret=$?
+ echo "ret: $ret" >> "$TS_OUTPUT"
+ return $ret
+}
+
+ts_log "testing offsets with full block size"
+run_tscmd $TS_CMD_BLKDISCARD -v $DEVICE
+if [ "$?" != "0" ]; then
+ # Skip the rest? For example loop backing files on NFS seem unsupported.
+ grep -q "BLKDISCARD ioctl failed: Operation not supported" "$TS_OUTPUT" \
+ && ts_skip "BLKDISCARD not supported"
+fi
+run_tscmd $TS_CMD_BLKDISCARD -v -o 1 $DEVICE
+run_tscmd $TS_CMD_BLKDISCARD -v -o 511 $DEVICE
+run_tscmd $TS_CMD_BLKDISCARD -v -o 512 $DEVICE
+run_tscmd $TS_CMD_BLKDISCARD -v -o 1024 $DEVICE
+
+ts_log "testing offsets with specific length"
+run_tscmd $TS_CMD_BLKDISCARD -v -l 5242880 $DEVICE
+run_tscmd $TS_CMD_BLKDISCARD -v -l 5242881 $DEVICE
+run_tscmd $TS_CMD_BLKDISCARD -v -l 5243391 $DEVICE
+run_tscmd $TS_CMD_BLKDISCARD -v -o 1 -l 5242880 $DEVICE
+run_tscmd $TS_CMD_BLKDISCARD -v -o 511 -l 5242880 $DEVICE
+run_tscmd $TS_CMD_BLKDISCARD -v -o 512 -l 5242880 $DEVICE
+run_tscmd $TS_CMD_BLKDISCARD -v -o 1024 -l 5242880 $DEVICE
+
+ts_log "testing aligned steps full device"
+run_tscmd $TS_CMD_BLKDISCARD -v -p 5242880 $DEVICE
+run_tscmd $TS_CMD_BLKDISCARD -v -p 1310720 $DEVICE
+
+ts_log "testing aligned steps with offsets and length"
+run_tscmd $TS_CMD_BLKDISCARD -v -p 512 -l 1024 $DEVICE
+run_tscmd $TS_CMD_BLKDISCARD -v -p 512 -o 1 -l 1024 $DEVICE
+run_tscmd $TS_CMD_BLKDISCARD -v -p 512 -o 1 -l 1536 $DEVICE
+run_tscmd $TS_CMD_BLKDISCARD -v -p 512 -o 511 -l 1536 $DEVICE
+run_tscmd $TS_CMD_BLKDISCARD -v -p 512 -o 512 -l 1536 $DEVICE
+run_tscmd $TS_CMD_BLKDISCARD -v -p 512 -o 1024 -l 1024 $DEVICE
+
+ts_log "testing misaligned steps full device"
+run_tscmd $TS_CMD_BLKDISCARD -v -p 1 $DEVICE
+run_tscmd $TS_CMD_BLKDISCARD -v -p 256 $DEVICE
+run_tscmd $TS_CMD_BLKDISCARD -v -p 511 $DEVICE
+run_tscmd $TS_CMD_BLKDISCARD -v -p 513 $DEVICE
+run_tscmd $TS_CMD_BLKDISCARD -v -p 768 $DEVICE
+
+ts_log "testing misaligned steps with offsets and length"
+run_tscmd $TS_CMD_BLKDISCARD -v -p 511 -l 1024 $DEVICE
+run_tscmd $TS_CMD_BLKDISCARD -v -p 511 -o 1 -l 1536 $DEVICE
+run_tscmd $TS_CMD_BLKDISCARD -v -p 511 -o 511 -l 1536 $DEVICE
+run_tscmd $TS_CMD_BLKDISCARD -v -p 511 -l 10240 $DEVICE
+run_tscmd $TS_CMD_BLKDISCARD -v -p 511 -o 1 -l 10240 $DEVICE
+run_tscmd $TS_CMD_BLKDISCARD -v -p 511 -o 511 -l 10240 $DEVICE
+
+sed -i "s#$DEVICE:\s##" $TS_OUTPUT $TS_ERRLOG
+
+ts_log "detach loop device from image"
+
+ts_cd "$ORIGPWD"
+
+ts_finalize