From 8bb05ac73a5b448b339ce0bc8d396c82c459b47f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 21:33:32 +0200 Subject: Merging upstream version 2.40. Signed-off-by: Daniel Baumann --- tests/ts/lsfd/lsfd-functions.bash | 44 +++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) (limited to 'tests/ts/lsfd/lsfd-functions.bash') diff --git a/tests/ts/lsfd/lsfd-functions.bash b/tests/ts/lsfd/lsfd-functions.bash index d9a3595..3a3f58f 100644 --- a/tests/ts/lsfd/lsfd-functions.bash +++ b/tests/ts/lsfd/lsfd-functions.bash @@ -16,11 +16,11 @@ # # The exit-status used in a test target. -readonly ENOSYS=17 readonly EPERM=18 readonly ENOPROTOOPT=19 readonly EPROTONOSUPPORT=20 -readonly EACCESS=21 +readonly EACCES=21 +readonly ENOENT=22 function lsfd_wait_for_pausing { ts_check_prog "sleep" @@ -59,7 +59,7 @@ function lsfd_compare_dev { fi } -lsfd_strip_type_stream() +function lsfd_strip_type_stream { # lsfd changes the output of NAME column for a unix stream socket # whether the kernel reports it is a "UNIX-STREAM" socket or a @@ -68,7 +68,7 @@ lsfd_strip_type_stream() sed -e 's/ type=stream//' } -lsfd_make_state_connected() +function 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 @@ -83,3 +83,39 @@ lsfd_make_state_connected() # to that on newer kernels. sed -e 's/state=unconnected/state=connected/' } + +function lsfd_check_mkfds_factory +{ + local FACTORY=$1 + + ts_check_test_command "$TS_HELPER_MKFDS" + if ! "$TS_HELPER_MKFDS" --is-available "$FACTORY"; then + ts_skip "test_mkfds has no factory for $FACTORY" + fi +} + +function lsfd_check_sockdiag +{ + local family=$1 + + ts_check_test_command "$TS_HELPER_MKFDS" + + local msg + local err + + msg=$("$TS_HELPER_MKFDS" -c sockdiag 9 family=$family 2>&1) + err=$? + + case $err in + 0) + return;; + $EPROTONOSUPPORT) + ts_skip "NETLINK_SOCK_DIAG protocol is not supported in socket(2)";; + $EACCES) + ts_skip "sending a msg via a sockdiag netlink socket is not permitted";; + $ENOENT) + ts_skip "sockdiag netlink socket is not available";; + *) + ts_failed "failed to create a sockdiag netlink socket $family ($err): $msg";; + esac +} -- cgit v1.2.3