]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: (blkid) add test for --usages
authorChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Tue, 7 Apr 2026 00:28:16 +0000 (20:28 -0400)
committerChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Thu, 9 Apr 2026 12:34:07 +0000 (08:34 -0400)
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
tests/expected/blkid/usages-crypto [new file with mode: 0644]
tests/expected/blkid/usages-filesystem [new file with mode: 0644]
tests/expected/blkid/usages-other [new file with mode: 0644]
tests/expected/blkid/usages-raid [new file with mode: 0644]
tests/ts/blkid/usages [new file with mode: 0755]

diff --git a/tests/expected/blkid/usages-crypto b/tests/expected/blkid/usages-crypto
new file mode 100644 (file)
index 0000000..499f214
--- /dev/null
@@ -0,0 +1 @@
+<removed>: VERSION="2" UUID="202265fe-9842-4c2d-ac9b-aba1b05deb63" LABEL="tst_label" SUBSYSTEM="tst_subsys" TYPE="crypto_LUKS" USAGE="crypto"
diff --git a/tests/expected/blkid/usages-filesystem b/tests/expected/blkid/usages-filesystem
new file mode 100644 (file)
index 0000000..b094f0b
--- /dev/null
@@ -0,0 +1 @@
+<removed>: LABEL="test-ext4" UUID="ada110f6-bd6d-49db-955d-342c27627b61" VERSION="1.0" FSBLOCKSIZE="1024" BLOCK_SIZE="1024" FSLASTBLOCK="65536" FSSIZE="67108864" TYPE="ext4" USAGE="filesystem"
diff --git a/tests/expected/blkid/usages-other b/tests/expected/blkid/usages-other
new file mode 100644 (file)
index 0000000..fd16ed0
--- /dev/null
@@ -0,0 +1 @@
+<removed>: VERSION="0" TYPE="swap" USAGE="other"
diff --git a/tests/expected/blkid/usages-raid b/tests/expected/blkid/usages-raid
new file mode 100644 (file)
index 0000000..d67c3a5
--- /dev/null
@@ -0,0 +1 @@
+<removed>: VERSION="0.90.0" UUID="37c76b91-011a-05c5-d30c-1fd4c5c3dbbc" TYPE="linux_raid_member" USAGE="raid"
diff --git a/tests/ts/blkid/usages b/tests/ts/blkid/usages
new file mode 100755 (executable)
index 0000000..f79a68b
--- /dev/null
@@ -0,0 +1,81 @@
+#!/bin/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="usages"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_BLKID"
+ts_check_prog "xz"
+
+FS_IMG_DIR="$TS_SELF/images-fs"
+REG_FS_IMG="$TS_OUTDIR/usages-reg-fs.img"
+SWAP_IMG="$TS_OUTDIR/usages-swap.img"
+CRYPTO_IMG="$TS_OUTDIR/usages-crypto.img"
+RAID_IMG="$TS_OUTDIR/usages-raid.img"
+
+xz --decompress --stdout "$FS_IMG_DIR"/ext4.img.xz > "$REG_FS_IMG" 2>>"$TS_ERRLOG"
+xz --decompress --stdout "$FS_IMG_DIR"/swap0.img.xz > "$SWAP_IMG" 2>>"$TS_ERRLOG"
+xz --decompress --stdout "$FS_IMG_DIR"/luks2.img.xz > "$CRYPTO_IMG" 2>>"$TS_ERRLOG"
+xz --decompress --stdout "$FS_IMG_DIR"/mdraid.img.xz > "$RAID_IMG" 2>>"$TS_ERRLOG"
+
+# Regular filesystem image
+ts_init_subtest "filesystem"
+$TS_CMD_BLKID --probe --usages filesystem "$REG_FS_IMG" >>"$TS_OUTPUT" 2>>"$TS_ERRLOG"
+sed -i -e "s@$REG_FS_IMG@<removed>@" "$TS_OUTPUT" 2>>"$TS_ERRLOG"
+ts_finalize_subtest
+
+ts_init_subtest "nofilesystem"
+$TS_CMD_BLKID --probe --usages nofilesystem "$REG_FS_IMG" \
+                                               >>"$TS_OUTPUT" 2>>"$TS_ERRLOG"
+ts_finalize_subtest
+
+
+# Swap image
+ts_init_subtest "other"
+$TS_CMD_BLKID --probe --usages other "$SWAP_IMG" >>"$TS_OUTPUT" 2>>"$TS_ERRLOG"
+sed -i -e "s@$SWAP_IMG@<removed>@" "$TS_OUTPUT" 2>>"$TS_ERRLOG"
+ts_finalize_subtest
+
+ts_init_subtest "noother"
+$TS_CMD_BLKID --probe --usages noother "$SWAP_IMG" >>"$TS_OUTPUT" 2>>"$TS_ERRLOG"
+ts_finalize_subtest
+
+
+# Crypto image
+ts_init_subtest "crypto"
+$TS_CMD_BLKID --probe --usages crypto "$CRYPTO_IMG" >>"$TS_OUTPUT" 2>>"$TS_ERRLOG"
+sed -i -e "s@$CRYPTO_IMG@<removed>@" "$TS_OUTPUT" 2>>"$TS_ERRLOG"
+ts_finalize_subtest
+
+ts_init_subtest "nocrypto"
+$TS_CMD_BLKID --probe --usages nocrypto "$CRYPTO_IMG" >>"$TS_OUTPUT" 2>>"$TS_ERRLOG"
+ts_finalize_subtest
+
+
+# RAID image
+ts_init_subtest "raid"
+$TS_CMD_BLKID --probe --usages raid "$RAID_IMG" >>"$TS_OUTPUT" 2>>"$TS_ERRLOG"
+sed -i -e "s@$RAID_IMG@<removed>@" "$TS_OUTPUT" 2>>"$TS_ERRLOG"
+ts_finalize_subtest
+
+ts_init_subtest "noraid"
+$TS_CMD_BLKID --probe --usages noraid "$RAID_IMG" >>"$TS_OUTPUT" 2>>"$TS_ERRLOG"
+ts_finalize_subtest
+
+ts_finalize