]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - tests/ts/lsfd/lsfd-functions.bash
43c02ad7045fe0ac5d0f6d8eb13b55bcf85cf7e8
3 # Copyright (C) 2021 Masatake YAMATO <yamato@redhat.com>
5 # This file is part of util-linux.
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.
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.
18 # The exit-status used in a test target.
20 readonly ENOPROTOOPT
=19
21 readonly EPROTONOSUPPORT
=20
24 function lsfd_wait_for_pausing
{
28 until [[ $
(ps
--no-headers -ostat "${PID}") =~ S.
* ]]; do
33 function lsfd_compare_dev
{
42 local DEV
=$
("${LSFD}" --raw -n -o DEV
-Q "${EXPR}")
46 local DEVNUM
=$
(( ( MAJ
<< 8 ) + MIN ))
47 local STAT_DEVNUM=$(stat -c "%d" "$FILE")
49 if [ "${DEVNUM}" == "${STAT_DEVNUM}" ]; then
53 # Print more information for debugging
55 echo 'MAJ:MIN' "${MAJ}:${MIN}"
56 echo 'DEVNUM:' "${DEVNUM}"
57 echo 'STAT_DEVNUM:' "${STAT_DEVNUM}"
61 lsfd_strip_type_stream()
63 # lsfd changes the output of NAME column for a unix stream socket
64 # whether the kernel reports it is a "UNIX-STREAM" socket or a
65 # "UNIX" socket. For "UNIX", lsfd appends "type=stream" to the
66 # NAME column. Let's delete the appended string before comparing.
67 sed -e 's/ type=stream//'
70 lsfd_make_state_connected()
72 # Newer kernels report the states of unix dgram sockets created by
73 # sockerpair(2) are "connected" via /proc/net/unix though Older
74 # kernels report "unconnected".
76 # Newer kernels report the states of unix dgram sockets already
77 # connect(2)'ed are "connected", too.
79 # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=83301b5367a98c17ec0d76c7bc0ccdc3c7e7ad6d
81 # This rewriting adjusts the output of lsfd running on older kernels
82 # to that on newer kernels.
83 sed -e 's/state=unconnected/state=connected/'
86 function lsfd_check_mkfds_factory
90 ts_check_test_command "$TS_HELPER_MKFDS"
91 if ! "$TS_HELPER_MKFDS" --is-available "$FACTORY"; then
92 ts_skip "test_mkfds has no factory for $FACTORY"