From: Masatake YAMATO Date: Fri, 24 Feb 2023 17:24:51 +0000 (+0900) Subject: tests: (lsfd) add a case for PING and PINGv6 sockets X-Git-Tag: v2.39-rc1~52^2~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f27139806eb80625dcd270cd26768180c321e8cd;p=thirdparty%2Futil-linux.git tests: (lsfd) add a case for PING and PINGv6 sockets Signed-off-by: Masatake YAMATO --- diff --git a/tests/expected/lsfd/mkfds-ping-ping b/tests/expected/lsfd/mkfds-ping-ping new file mode 100644 index 0000000000..cad42b1c23 --- /dev/null +++ b/tests/expected/lsfd/mkfds-ping-ping @@ -0,0 +1,4 @@ + 3 PING state=established id=9999 laddr=127.0.0.1 raddr=127.0.0.1 established dgram 127.0.0.1 127.0.0.1 9999 +ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,INET.LADDR,INET.RADDR,PING.ID: 0 + 3 PING state=close id=9999 laddr=127.0.0.1 close dgram 127.0.0.1 0.0.0.0 9999 +ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,INET.LADDR,INET.RADDR,PING.ID: 0 diff --git a/tests/expected/lsfd/mkfds-ping-ping6 b/tests/expected/lsfd/mkfds-ping-ping6 new file mode 100644 index 0000000000..3ef973040c --- /dev/null +++ b/tests/expected/lsfd/mkfds-ping-ping6 @@ -0,0 +1,4 @@ + 3 PINGv6 state=established id=9999 laddr=::1 raddr=::1 established dgram ::1 ::1 9999 +ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,INET6.LADDR,INET6.RADDR,PING.ID: 0 + 3 PINGv6 state=close id=9999 laddr=::1 close dgram ::1 :: 9999 +ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,INET6.LADDR,INET6.RADDR,PING.ID: 0 diff --git a/tests/ts/lsfd/mkfds-ping b/tests/ts/lsfd/mkfds-ping new file mode 100755 index 0000000000..610901cee8 --- /dev/null +++ b/tests/ts/lsfd/mkfds-ping @@ -0,0 +1,83 @@ +#!/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="PING and PINGv6 sockets" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_skip_nonroot + +ts_check_test_command "$TS_CMD_LSFD" +ts_check_test_command "$TS_HELPER_MKFDS" +ts_check_native_byteorder + +ts_cd "$TS_OUTDIR" + +PID= +FD=3 +EXPR=( + '(TYPE == "PING") and (FD == 3)' + '(TYPE == "PINGv6") and (FD == 3)' +) +FACTORY=( + ping + ping6 +) +TYPE=( + 'PING' + 'PINGv6' +) +COLNS=( + INET + INET6 +) +ID=9999 + +for i in 0 1; do + if ! "$TS_HELPER_MKFDS" -c -q "${FACTORY[$i]}" 3 id=$ID; then + ts_skip "making ${TYPE[$i]} socket with specifying id is failed (blocked by SELinux?)" + fi +done + +for i in 0 1; do + ts_init_subtest "${FACTORY[$i]}" + { + coproc MKFDS { "$TS_HELPER_MKFDS" "${FACTORY[$i]}" $FD id=$ID; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,${COLNS[$i]}.LADDR,${COLNS[$i]}.RADDR,PING.ID \ + -p "${PID}" -Q "${EXPR[$i]}" + echo "ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,${COLNS[$i]}.LADDR,${COLNS[$i]}.RADDR,PING.ID": $? + kill -CONT "${PID}" + fi + wait "${MKFDS_PID}" + + coproc MKFDS { "$TS_HELPER_MKFDS" "${FACTORY[$i]}" $FD id=$ID connect=0; } + if read -r -u "${MKFDS[0]}" PID; then + ${TS_CMD_LSFD} -n \ + -o ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,${COLNS[$i]}.LADDR,${COLNS[$i]}.RADDR,PING.ID \ + -p "${PID}" -Q "${EXPR[$i]}" + echo "ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,${COLNS[$i]}.LADDR,${COLNS[$i]}.RADDR,PING.ID": $? + kill -CONT "${PID}" + fi + } > "$TS_OUTPUT" 2>&1 + wait "${MKFDS_PID}" + ts_finalize_subtest +done + +ts_finalize