[LTP] [PATCH v2 2/6] tst_test.sh: Redesing tst_mkfs() API
Petr Vorel
pvorel@suse.cz
Thu Feb 10 17:27:35 CET 2022
the goal is to add support for extra opts after device name
(e.g. size) - to sync with C API.
But instead adding new variable for extra opts we specify only
$fs_type and the rest of args we just pass to the mkfs.* command.
Still keep $TST_FS_TYPE and $TST_DEVICE as a default when no parameters
are passed.
NOTE: not adding it to legacy shell API (thus no need to change
test_robind.sh).
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
testcases/lib/tst_test.sh | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index fa4c90f787..64e65f9f53 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -342,19 +342,21 @@ tst_umount()
tst_mkfs()
{
local fs_type=${1:-$TST_FS_TYPE}
- local device=${2:-$TST_DEVICE}
[ $# -ge 1 ] && shift
- [ $# -ge 1 ] && shift
- local fs_opts="$@"
- if [ -z "$device" ]; then
- tst_brk TBROK "No device specified"
+ local opts="$@"
+
+ if [ -z "$opts" ]; then
+ if [ "$TST_NEEDS_DEVICE" != 1 ]; then
+ tst_brk "Using default parameters in tst_mkfs requires TST_NEEDS_DEVICE=1"
+ fi
+ opts="$TST_DEVICE"
fi
tst_require_cmds mkfs.$fs_type
- tst_res TINFO "Formatting $device with $fs_type extra opts='$fs_opts'"
- ROD_SILENT mkfs.$fs_type $fs_opts $device
+ tst_res TINFO "Formatting $fs_type with opts='$opts'"
+ ROD_SILENT mkfs.$fs_type $opts
}
# Detect whether running under hypervisor: Microsoft Hyper-V
--
2.35.1
More information about the ltp
mailing list