From: Masatake YAMATO Date: Sat, 15 Apr 2023 11:50:29 +0000 (+0900) Subject: tests: (lsfd) adjust the output for unix datagram sockets created by socketpair X-Git-Tag: v2.39-rc3~21^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9a906b8799e5c8dfdcbb5b03c59cb8c118c8ad98;p=thirdparty%2Futil-linux.git tests: (lsfd) adjust the output for unix datagram sockets created by socketpair Though older kernels report such sockets as "unconnected" via /proc/net/unix, the newer kernels report them as "connected". The change is introduced in https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=83301b5367a98c17ec0d76c7bc0ccdc3c7e7ad6d This caused a failure in a test case. To avoid the failure, this change rewrites "state=unconnected" in the lsfd's output to "state=connected". Signed-off-by: Masatake YAMATO --- diff --git a/tests/ts/lsfd/column-name b/tests/ts/lsfd/column-name index 7dff8f7b23..dba86b9b69 100755 --- a/tests/ts/lsfd/column-name +++ b/tests/ts/lsfd/column-name @@ -31,6 +31,15 @@ PID= FD=3 EXPR="(FD == 3)" +make_state_connected() +{ + if [ "$1" = "socketpair" ]; then + lsfd_make_state_connected + else + cat + fi +} + for C in ro-regular-file pidfd socketpair; do ts_init_subtest $C { @@ -47,7 +56,7 @@ for C in ro-regular-file pidfd socketpair; do ${TS_CMD_LSFD} -n -o ASSOC,KNAME,NAME -p "${PID}" -Q "${EXPR}" | { # Replace the unpredictable an inode number for the socket # with "INODENUM". - sed -e 's/\[[0-9]\+\]/[INODENUM]/g' + sed -e 's/\[[0-9]\+\]/[INODENUM]/g' | make_state_connected $C } echo "$C"':ASSOC,KNAME,NAME': ${PIPESTATUS[0]} diff --git a/tests/ts/lsfd/lsfd-functions.bash b/tests/ts/lsfd/lsfd-functions.bash index 1ebc327592..8f68db930f 100644 --- a/tests/ts/lsfd/lsfd-functions.bash +++ b/tests/ts/lsfd/lsfd-functions.bash @@ -66,3 +66,16 @@ lsfd_strip_type_stream() # NAME column. Let's delete the appended string before comparing. sed -e 's/ type=stream//' } + +lsfd_make_state_connected() +{ + # Newer kernels report the states of unix dgram sockets created by + # sockerpair(2) are "connected" via /proc/net/unix though Older + # kernels report "unconnected". + # + # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=83301b5367a98c17ec0d76c7bc0ccdc3c7e7ad6d + # + # This rewriting adjusts the output of lsfd running on older kernels + # to that on newer kernels. + sed -e 's/state=unconnected/state=connected/' +}