]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: (blkzone) add missing tests
authorChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Tue, 26 May 2026 03:55:34 +0000 (23:55 -0400)
committerChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Tue, 26 May 2026 11:27:50 +0000 (07:27 -0400)
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
tests/commands.sh
tests/expected/blkzone/options-capacity [new file with mode: 0644]
tests/expected/blkzone/options-finish-reset [new file with mode: 0644]
tests/expected/blkzone/options-open-close [new file with mode: 0644]
tests/expected/blkzone/options-report [new file with mode: 0644]
tests/ts/blkzone/options [new file with mode: 0755]

index e3cc1ddfc142f1f32bb11564a8ab970d30eaafec..79ea2eefc26dc47c34cd35d1518cc8472711dd90 100644 (file)
@@ -76,8 +76,9 @@ TS_HELPER_PARSEPID="${ts_helpersdir}test_parsepid"
 TS_CMD_ADDPART=${TS_CMD_ADDPART:-"${ts_commandsdir}addpart"}
 TS_CMD_DELPART=${TS_CMD_DELPART:-"${ts_commandsdir}delpart"}
 TS_CMD_BITS=${TS_CMD_BITS-"${ts_commandsdir}bits"}
-TS_CMD_BLKDISCARD=${TS_CMD_BLKID-"${ts_commandsdir}blkdiscard"}
+TS_CMD_BLKDISCARD=${TS_CMD_BLKDISCARD-"${ts_commandsdir}blkdiscard"}
 TS_CMD_BLKID=${TS_CMD_BLKID-"${ts_commandsdir}blkid"}
+TS_CMD_BLKZONE=${TS_CMD_BLKZONE-"${ts_commandsdir}blkzone"}
 TS_CMD_CAL=${TS_CMD_CAL-"${ts_commandsdir}cal"}
 TS_CMD_CHOOM=${TS_CMD_CHOOM:-"${ts_commandsdir}choom"}
 TS_CMD_CHSH=${TS_CMD_CHSH:-"${ts_commandsdir}chsh"}
diff --git a/tests/expected/blkzone/options-capacity b/tests/expected/blkzone/options-capacity
new file mode 100644 (file)
index 0000000..8f6145d
--- /dev/null
@@ -0,0 +1 @@
+0x00000c000
diff --git a/tests/expected/blkzone/options-finish-reset b/tests/expected/blkzone/options-finish-reset
new file mode 100644 (file)
index 0000000..d9c4fea
--- /dev/null
@@ -0,0 +1,3 @@
+  start: 0x00000c000, len 0x004000, cap 0x004000, wptr N/A reset:0 non-seq:0, zcond:14(fu) [type: 2(SEQ_WRITE_REQUIRED)]
+---------
+  start: 0x00000c000, len 0x004000, cap 0x004000, wptr 0x000000 reset:0 non-seq:0, zcond: 1(em) [type: 2(SEQ_WRITE_REQUIRED)]
diff --git a/tests/expected/blkzone/options-open-close b/tests/expected/blkzone/options-open-close
new file mode 100644 (file)
index 0000000..e19586c
--- /dev/null
@@ -0,0 +1,2 @@
+  start: 0x000008000, len 0x004000, cap 0x004000, wptr 0x000000 reset:0 non-seq:0, zcond: 3(oe) [type: 2(SEQ_WRITE_REQUIRED)]
+ successful close of zones in range from 32768, to 49152
diff --git a/tests/expected/blkzone/options-report b/tests/expected/blkzone/options-report
new file mode 100644 (file)
index 0000000..1ff987d
--- /dev/null
@@ -0,0 +1,19 @@
+  start: 0x000000000, len 0x004000, cap 0x004000, wptr N/A reset:0 non-seq:0, zcond: 0(nw) [type: 1(CONVENTIONAL)]
+  start: 0x000004000, len 0x004000, cap 0x004000, wptr 0x000000 reset:0 non-seq:0, zcond: 1(em) [type: 2(SEQ_WRITE_REQUIRED)]
+  start: 0x000008000, len 0x004000, cap 0x004000, wptr 0x000000 reset:0 non-seq:0, zcond: 1(em) [type: 2(SEQ_WRITE_REQUIRED)]
+  start: 0x00000c000, len 0x004000, cap 0x004000, wptr 0x000000 reset:0 non-seq:0, zcond: 1(em) [type: 2(SEQ_WRITE_REQUIRED)]
+  start: 0x000010000, len 0x004000, cap 0x004000, wptr 0x000000 reset:0 non-seq:0, zcond: 1(em) [type: 2(SEQ_WRITE_REQUIRED)]
+  start: 0x000014000, len 0x004000, cap 0x004000, wptr 0x000000 reset:0 non-seq:0, zcond: 1(em) [type: 2(SEQ_WRITE_REQUIRED)]
+  start: 0x000018000, len 0x004000, cap 0x004000, wptr 0x000000 reset:0 non-seq:0, zcond: 1(em) [type: 2(SEQ_WRITE_REQUIRED)]
+  start: 0x00001c000, len 0x004000, cap 0x004000, wptr 0x000000 reset:0 non-seq:0, zcond: 1(em) [type: 2(SEQ_WRITE_REQUIRED)]
+---------
+  start: 0x000008000, len 0x004000, cap 0x004000, wptr 0x000000 reset:0 non-seq:0, zcond: 1(em) [type: 2(SEQ_WRITE_REQUIRED)]
+  start: 0x00000c000, len 0x004000, cap 0x004000, wptr 0x000000 reset:0 non-seq:0, zcond: 1(em) [type: 2(SEQ_WRITE_REQUIRED)]
+  start: 0x000010000, len 0x004000, cap 0x004000, wptr 0x000000 reset:0 non-seq:0, zcond: 1(em) [type: 2(SEQ_WRITE_REQUIRED)]
+  start: 0x000014000, len 0x004000, cap 0x004000, wptr 0x000000 reset:0 non-seq:0, zcond: 1(em) [type: 2(SEQ_WRITE_REQUIRED)]
+  start: 0x000018000, len 0x004000, cap 0x004000, wptr 0x000000 reset:0 non-seq:0, zcond: 1(em) [type: 2(SEQ_WRITE_REQUIRED)]
+  start: 0x00001c000, len 0x004000, cap 0x004000, wptr 0x000000 reset:0 non-seq:0, zcond: 1(em) [type: 2(SEQ_WRITE_REQUIRED)]
+---------
+  start: 0x000008000, len 0x004000, cap 0x004000, wptr 0x000000 reset:0 non-seq:0, zcond: 1(em) [type: 2(SEQ_WRITE_REQUIRED)]
+  start: 0x00000c000, len 0x004000, cap 0x004000, wptr 0x000000 reset:0 non-seq:0, zcond: 1(em) [type: 2(SEQ_WRITE_REQUIRED)]
+  start: 0x000010000, len 0x004000, cap 0x004000, wptr 0x000000 reset:0 non-seq:0, zcond: 1(em) [type: 2(SEQ_WRITE_REQUIRED)]
diff --git a/tests/ts/blkzone/options b/tests/ts/blkzone/options
new file mode 100755 (executable)
index 0000000..ec50fa4
--- /dev/null
@@ -0,0 +1,110 @@
+#!/usr/bin/env bash
+
+# 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.
+#
+# Copyright (C) 2026 Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="options"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_BLKZONE"
+
+ts_skip_nonroot
+
+DEV_SIZE_MEBIBYTES="64"
+DEV_SECTOR_SIZE=512
+ZONE_SIZE_MEBIBYTES=8
+ZONE_LENGTH_SECTORS=$(( (ZONE_SIZE_MEBIBYTES * 1024**2) / 512 ))
+
+# https://sg.danny.cz/sg/scsi_debug.html#__RefHeading___Toc121_3679520260
+ts_scsi_debug_init dev_size_mb="$DEV_SIZE_MEBIBYTES"    \
+                    sector_size="$DEV_SECTOR_SIZE"      \
+                    ptype=0x14 zone_size_mb="$ZONE_SIZE_MEBIBYTES" \
+                    zbc=2
+DEV="$TS_DEVICE"
+
+
+ts_init_subtest "report"
+
+offset=$((2 * ZONE_LENGTH_SECTORS ))
+
+{
+    "$TS_CMD_BLKZONE" report "$DEV"
+    echo "---------"
+    "$TS_CMD_BLKZONE" report --offset $offset "$DEV"
+    echo "---------"
+    "$TS_CMD_BLKZONE" report --count 3 --offset $offset "$DEV"
+
+} >>"$TS_OUTPUT" 2>>"$TS_ERRLOG"
+
+unset -v offset
+
+ts_finalize_subtest
+
+
+ts_init_subtest "finish-reset"
+
+offset=$((3 * ZONE_LENGTH_SECTORS ))
+
+{
+    "$TS_CMD_BLKZONE" finish --count 1 --offset $offset "$DEV"
+    "$TS_CMD_BLKZONE" report --count 1 --offset $offset "$DEV"
+    "$TS_CMD_BLKZONE" reset --count 1 --offset $offset "$DEV"
+    echo "---------"
+    "$TS_CMD_BLKZONE" report --count 1 --offset $offset "$DEV"
+
+} >>"$TS_OUTPUT" 2>>"$TS_ERRLOG"
+
+unset -v offset
+
+ts_finalize_subtest
+
+
+ts_init_subtest "open-close"
+
+offset=$((2 * ZONE_LENGTH_SECTORS ))
+
+{
+    "$TS_CMD_BLKZONE" open --count 1 --offset $offset "$DEV"
+    "$TS_CMD_BLKZONE" report --count 1 --offset $offset "$DEV"
+    "$TS_CMD_BLKZONE" close --verbose --count 1 --offset $offset "$DEV"
+
+} >>"$TS_OUTPUT" 2>>"$TS_ERRLOG"
+
+sed -i -e 's|\(/dev/.*\):\(.*\)|\2|' "$TS_OUTPUT" 2>>"$TS_ERRLOG"
+
+unset -v offset
+
+ts_finalize_subtest
+
+
+ts_init_subtest "capacity"
+
+length=$((3 * ZONE_LENGTH_SECTORS ))
+offset=$((2 * ZONE_LENGTH_SECTORS ))
+
+# The capacity sum should be (3 * $ZONE_LENGTH_SECTORS) in hex, i.e. capacity of
+# three zones.
+"$TS_CMD_BLKZONE" capacity --length $length  \
+                    --offset $offset "$DEV" \
+                    >>"$TS_OUTPUT" 2>>"$TS_ERRLOG"
+
+unset -v offset length
+
+ts_finalize_subtest
+
+
+ts_finalize