Debian Codegraph @

tests/ts/lsfd/mkfds-rw-character-device

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="character device with O_RDWR"
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_cd "$TS_OUTDIR"
30
31 PID=
32 FD=3
33 EXPR=
34
35 {
36 target=/dev/zero
37 coproc MKFDS { "$TS_HELPER_MKFDS" rw-character-device $FD chrdev=$target; }
38 if read -u ${MKFDS[0]} PID; then
39 EXPR='(PID == '"${PID}"') and (FD == '"$FD"')'
40 ${TS_CMD_LSFD} -n -o ASSOC,MODE,TYPE,NAME,SOURCE,POS,MAJ:MIN,CHRDRV,DEVTYPE,RDEV -Q "${EXPR}"
41 echo 'ASSOC,MODE,TYPE,NAME,SOURCE,POS,MAJ:MIN,CHRDRV,DEVTYPE,RDEV': $?
42
43 lsfd_compare_dev "${TS_CMD_LSFD}" $target "${EXPR}"
44
45 echo DONE >&"${MKFDS[1]}"
46 fi
47 wait ${MKFDS_PID}
48 } > $TS_OUTPUT 2>&1
49
50 ts_finalize