From: Masatake YAMATO Date: Mon, 13 Feb 2023 14:54:14 +0000 (+0900) Subject: lsfd: (test) add a case for TCPv6 sockets X-Git-Tag: v2.39-rc1~66^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5840d8297a0dbfc407790f5ee6e0557ec578c70d;p=thirdparty%2Futil-linux.git lsfd: (test) add a case for TCPv6 sockets --- diff --git a/tests/expected/lsfd/mkfds-tcp6 b/tests/expected/lsfd/mkfds-tcp6 new file mode 100644 index 0000000000..26b6039f19 --- /dev/null +++ b/tests/expected/lsfd/mkfds-tcp6 @@ -0,0 +1,4 @@ + 3 TCPv6 SOCK state=listen laddr=[::1]:34567 listen stream 1 ::1 :: [::1]:34567 34567 [::]:0 0 + 4 TCPv6 SOCK state=established laddr=[::1]:23456 raddr=[::1]:34567 established stream 0 ::1 ::1 [::1]:23456 23456 [::1]:34567 34567 + 5 TCPv6 SOCK state=established laddr=[::1]:34567 raddr=[::1]:23456 established stream 0 ::1 ::1 [::1]:34567 34567 [::1]:23456 23456 +ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET6.LADDR,INET6.RADDR,TCP.LADDR,TCP.LPORT,TCP.RADDR,TCP.RPORT: 0 diff --git a/tests/ts/lsfd/mkfds-tcp6 b/tests/ts/lsfd/mkfds-tcp6 new file mode 100755 index 0000000000..b987c88b51 --- /dev/null +++ b/tests/ts/lsfd/mkfds-tcp6 @@ -0,0 +1,50 @@ +#!/bin/bash +# +# Copyright (C) 2023 Masatake YAMATO +# +# 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="TCP6 sockets" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_LSFD" +ts_check_test_command "$TS_HELPER_MKFDS" +ts_check_native_byteorder + +ts_cd "$TS_OUTDIR" + +PID= +FDS=3 +FDC=4 +FDA=5 +EXPR='(TYPE == "TCPv6") and (FD >= 3) and (FD <= 5)' + +{ + coproc MKFDS { "$TS_HELPER_MKFDS" tcp6 $FDS $FDC $FDA \ + server-port=34567 \ + client-port=23456 ; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET6.LADDR,INET6.RADDR,TCP.LADDR,TCP.LPORT,TCP.RADDR,TCP.RPORT \ + -p "${PID}" -Q "${EXPR}" + echo 'ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET6.LADDR,INET6.RADDR,TCP.LADDR,TCP.LPORT,TCP.RADDR,TCP.RPORT': $? + + kill -CONT "${PID}" + wait "${MKFDS_PID}" + fi +} > "$TS_OUTPUT" 2>&1 + +ts_finalize