From: Christian Goeschel Ndjomouo Date: Tue, 26 May 2026 03:55:34 +0000 (-0400) Subject: tests: (blkzone) add missing tests X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=30b29d931dd21c467e6d101810d0138f403192fa;p=thirdparty%2Futil-linux.git tests: (blkzone) add missing tests Signed-off-by: Christian Goeschel Ndjomouo --- diff --git a/tests/commands.sh b/tests/commands.sh index e3cc1ddfc..79ea2eefc 100644 --- a/tests/commands.sh +++ b/tests/commands.sh @@ -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 index 000000000..8f6145d81 --- /dev/null +++ b/tests/expected/blkzone/options-capacity @@ -0,0 +1 @@ +0x00000c000 diff --git a/tests/expected/blkzone/options-finish-reset b/tests/expected/blkzone/options-finish-reset new file mode 100644 index 000000000..d9c4fea53 --- /dev/null +++ b/tests/expected/blkzone/options-finish-reset @@ -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 index 000000000..e19586ce5 --- /dev/null +++ b/tests/expected/blkzone/options-open-close @@ -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 index 000000000..1ff987db2 --- /dev/null +++ b/tests/expected/blkzone/options-report @@ -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 index 000000000..ec50fa4ab --- /dev/null +++ b/tests/ts/blkzone/options @@ -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 + +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