Debian Codegraph @

tests/ts/lsfd/mkfds-ro-regular-file

raw
1 #!/bin/bash
2 #
3 # Copyright (C) 2021 Masatake YAMATO <[email protected]>
4 #
5 # This file is part of util-linux.
6 #
7 # This file is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # This file is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 TS_TOPDIR="${0%/*}/../.."
18 TS_DESC="read-only regular file"
19
20 . "$TS_TOPDIR"/functions.sh
21 ts_init "$*"
22
23 . "$TS_SELF"/lsfd-functions.bash
24
25 ts_check_test_command "$TS_CMD_LSFD"
26
27 ts_check_test_command "$TS_HELPER_MKFDS"
28
29 ts_check_prog "stat"
30 ts_check_prog "id"
31
32 ts_cd "$TS_OUTDIR"
33
34 PID=
35 FD=3
36 EXPR=
37
38 {
39 target=/etc/passwd
40 coproc MKFDS { "$TS_HELPER_MKFDS" --comm ABC ro-regular-file $FD offset=1 file=$target; }
41 if read -u ${MKFDS[0]} PID; then
42 EXPR='(PID == '"${PID}"') and (FD == '"$FD"')'
43 ${TS_CMD_LSFD} -n -o COMMAND,ASSOC,MODE,TYPE,NAME,POS -Q "${EXPR}"
44 echo 'COMMAND,ASSOC,MODE,TYPE,NAME,POS': $?
45
46 LSFD_PID=$(${TS_CMD_LSFD} --raw -n -o PID -Q "${EXPR}")
47 echo 'PID[RUN]:' $?
48 [ "${LSFD_PID}" == "${PID}" ]
49 echo 'PID[STR]:' $?
50
51 LSFD_INODE=$(${TS_CMD_LSFD} --raw -n -o INODE -Q "${EXPR}")
52 echo 'INODE[RUN]:' $?
53 [ "${LSFD_INODE}" == "$(stat -c %i $target)" ]
54 echo 'INODE[STR]:' $?
55
56 LSFD_UID=$(${TS_CMD_LSFD} --raw -n -o UID -Q "${EXPR}")
57 echo 'UID[RUN]:' $?
58 [ "${LSFD_UID}" == $(id -u) ]
59 echo 'UID[STR]:' $?
60
61 LSFD_USER=$(${TS_CMD_LSFD} --raw -n -o USER -Q "${EXPR}")
62 echo 'USER[RUN]:' $?
63 [ "${LSFD_USER}" == $(id -u -n) ]
64 echo 'USER[STR]:' $?
65
66 LSFD_SIZE=$(${TS_CMD_LSFD} --raw -n -o SIZE -Q "${EXPR}")
67 echo 'SIZE[RUN]:' $?
68 [ "${LSFD_SIZE}" == $(stat -c %s $target) ]
69 echo 'SIZE[STR]:' $?
70
71 lsfd_compare_dev "${TS_CMD_LSFD}" $target "${EXPR}"
72
73 echo DONE >&"${MKFDS[1]}"
74 fi
75 wait ${MKFDS_PID}
76 } > $TS_OUTPUT 2>&1
77
78 ts_finalize