]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
blkid: (tests) test output formats
authorThomas Weißschuh <thomas.weissschuh@linutronix.de>
Wed, 6 Mar 2024 16:36:47 +0000 (17:36 +0100)
committerThomas Weißschuh <thomas.weissschuh@linutronix.de>
Thu, 7 Mar 2024 07:27:18 +0000 (08:27 +0100)
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
12 files changed:
tests/expected/blkid/output-device-cache [new file with mode: 0644]
tests/expected/blkid/output-device-probe [new file with mode: 0644]
tests/expected/blkid/output-export-cache [new file with mode: 0644]
tests/expected/blkid/output-export-probe [new file with mode: 0644]
tests/expected/blkid/output-full-cache [new file with mode: 0644]
tests/expected/blkid/output-full-probe [new file with mode: 0644]
tests/expected/blkid/output-udev-cache [new file with mode: 0644]
tests/expected/blkid/output-udev-probe [new file with mode: 0644]
tests/expected/blkid/output-value-cache [new file with mode: 0644]
tests/expected/blkid/output-value-probe [new file with mode: 0644]
tests/ts/blkid/blkid-output.img.xz [new file with mode: 0644]
tests/ts/blkid/output [new file with mode: 0755]

diff --git a/tests/expected/blkid/output-device-cache b/tests/expected/blkid/output-device-cache
new file mode 100644 (file)
index 0000000..59762f5
--- /dev/null
@@ -0,0 +1 @@
+blkid-output.img
diff --git a/tests/expected/blkid/output-device-probe b/tests/expected/blkid/output-device-probe
new file mode 100644 (file)
index 0000000..59762f5
--- /dev/null
@@ -0,0 +1 @@
+blkid-output.img
diff --git a/tests/expected/blkid/output-export-cache b/tests/expected/blkid/output-export-cache
new file mode 100644 (file)
index 0000000..0de13f4
--- /dev/null
@@ -0,0 +1,3 @@
+DEVNAME=blkid-output.img
+LABEL=tM-CM-)s\"\'^J\ t
+TYPE=cramfs
diff --git a/tests/expected/blkid/output-export-probe b/tests/expected/blkid/output-export-probe
new file mode 100644 (file)
index 0000000..55f2d00
--- /dev/null
@@ -0,0 +1,7 @@
+DEVNAME=blkid-output.img
+LABEL=tM-CM-)s\"\'^J\ t
+FSSIZE=4096
+VERSION=2
+ENDIANNESS=LITTLE
+TYPE=cramfs
+USAGE=filesystem
diff --git a/tests/expected/blkid/output-full-cache b/tests/expected/blkid/output-full-cache
new file mode 100644 (file)
index 0000000..287e327
--- /dev/null
@@ -0,0 +1 @@
+blkid-output.img: LABEL="tM-CM-)s\"'^J t" TYPE="cramfs"
diff --git a/tests/expected/blkid/output-full-probe b/tests/expected/blkid/output-full-probe
new file mode 100644 (file)
index 0000000..8763ece
--- /dev/null
@@ -0,0 +1 @@
+blkid-output.img: LABEL="tM-CM-)s\"'^J t" FSSIZE="4096" VERSION="2" ENDIANNESS="LITTLE" TYPE="cramfs" USAGE="filesystem"
diff --git a/tests/expected/blkid/output-udev-cache b/tests/expected/blkid/output-udev-cache
new file mode 100644 (file)
index 0000000..8e0e6a6
--- /dev/null
@@ -0,0 +1,3 @@
+ID_FS_LABEL=tés"'_t
+ID_FS_LABEL_ENC=tés\x22\x27\x0a\x20t
+ID_FS_TYPE=cramfs
diff --git a/tests/expected/blkid/output-udev-probe b/tests/expected/blkid/output-udev-probe
new file mode 100644 (file)
index 0000000..59a3224
--- /dev/null
@@ -0,0 +1,7 @@
+ID_FS_LABEL=tés"'_t
+ID_FS_LABEL_ENC=tés\x22\x27\x0a\x20t
+ID_FS_FSSIZE=4096
+ID_FS_VERSION=2
+ID_FS_ENDIANNESS=LITTLE
+ID_FS_TYPE=cramfs
+ID_FS_USAGE=filesystem
diff --git a/tests/expected/blkid/output-value-cache b/tests/expected/blkid/output-value-cache
new file mode 100644 (file)
index 0000000..71e8402
--- /dev/null
@@ -0,0 +1,3 @@
+tés"'
+ t
+cramfs
diff --git a/tests/expected/blkid/output-value-probe b/tests/expected/blkid/output-value-probe
new file mode 100644 (file)
index 0000000..56cac72
--- /dev/null
@@ -0,0 +1,7 @@
+tés"'
+ t
+4096
+2
+LITTLE
+cramfs
+filesystem
diff --git a/tests/ts/blkid/blkid-output.img.xz b/tests/ts/blkid/blkid-output.img.xz
new file mode 100644 (file)
index 0000000..126f33a
Binary files /dev/null and b/tests/ts/blkid/blkid-output.img.xz differ
diff --git a/tests/ts/blkid/output b/tests/ts/blkid/output
new file mode 100755 (executable)
index 0000000..ff77f1d
--- /dev/null
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2024 Thomas Weißschuh <thomas.weissschuh@linutronix.de>
+#
+# 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="output formatting"
+
+. "$TS_TOPDIR"/functions.sh
+
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_BLKID"
+ts_check_prog "xz"
+
+outimg="$TS_OUTDIR"/blkid-output.img
+xz -dc "$TS_SELF"/blkid-output.img.xz > $outimg
+
+_blkid() {
+       "$TS_CMD_BLKID" --cache-file "$TS_OUTDIR"/blkid.cache "$@" "$outimg" | sed -e "s#$TS_OUTDIR/##"
+}
+
+for format in value udev export full device; do
+       ts_init_subtest "$format-probe"
+       _blkid --probe --output "$format" >> "$TS_OUTPUT"
+       ts_finalize_subtest
+
+       ts_init_subtest "$format-cache"
+       _blkid --output "$format" >> "$TS_OUTPUT"
+       ts_finalize_subtest
+done
+
+ts_finalize