Debian Codegraph @

tests/ts/blkid/options

raw
1 #!/bin/bash
2
3 #
4 # Copyright (C) 2026 Christian Goeschel Ndjomouo <[email protected]>
5 #
6 # This file is part of util-linux.
7 #
8 # This file is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
12 #
13 # This file is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18
19 TS_TOPDIR="${0%/*}/../.."
20 TS_DESC="options"
21
22 . "$TS_TOPDIR"/functions.sh
23
24 ts_init "$*"
25
26 ts_skip_nonroot
27 ts_check_test_command "$TS_CMD_BLKID"
28 ts_check_test_command "$TS_CMD_MKSWAP"
29 ts_check_losetup
30
31 ts_device_init
32
33 "$TS_CMD_MKSWAP" --quiet --endianness little --pagesize 4096 --label UL_TS_SWAPIMG \
34 --uuid b397d7bd-87e9-4f12-8ac1-d3201d14b531 \
35 "$TS_LODEV" >> "$TS_OUTPUT" 2>> "$TS_ERRLOG"
36
37
38 ts_init_subtest label
39
40 if "$TS_CMD_BLKID" --label UL_TS_SWAPIMG | grep "$TS_LODEV" &>/dev/null; then
41 echo "ok" >> "$TS_OUTPUT"
42 fi
43
44 ts_finalize_subtest
45
46
47 ts_init_subtest list-filesystems
48
49 # Atleast swap should be in the list
50 "$TS_CMD_BLKID" --list-filesystems \
51 | grep -o "swap" >> "$TS_OUTPUT" 2>> "$TS_ERRLOG"
52
53 ts_finalize_subtest
54
55
56 ts_init_subtest list-one
57
58 lines=$("$TS_CMD_BLKID" --list-one --match-token TYPE="swap" 2>/dev/null | wc -l);
59
60 if [ "$lines" == 1 ]; then
61 echo "ok" >> "$TS_OUTPUT"
62 fi
63
64 ts_finalize_subtest
65
66
67 ts_init_subtest match-tag
68 "$TS_CMD_BLKID" --match-tag LABEL | grep -o UL_TS_SWAPIMG \
69 >> "$TS_OUTPUT" 2>> "$TS_ERRLOG"
70 ts_finalize_subtest
71
72
73 ts_init_subtest match-token
74
75 if "$TS_CMD_BLKID" --match-token LABEL="UL_TS_SWAPIMG" &>/dev/null; then
76 echo "ok" >> "$TS_OUTPUT"
77 fi
78
79 ts_finalize_subtest
80
81 ts_init_subtest match-types
82
83 if "$TS_CMD_BLKID" --probe --match-types swap "$TS_LODEV" &>/dev/null; then
84 echo "ok" >> "$TS_OUTPUT"
85 fi
86
87 ts_finalize_subtest
88
89 ts_finalize