]> git.ipfire.org Git - thirdparty/util-linux.git/blobdiff - tests/ts/lsfd/lsfd-functions.bash
tests: (lsfd) don't refer "$?" on the line follwoing the use of "local"
[thirdparty/util-linux.git] / tests / ts / lsfd / lsfd-functions.bash
index d7eab146a70dac63314ac748d361c3361c16e167..9c2eb0785b3cd1c589bc582ffbd6f37623240362 100644 (file)
@@ -20,6 +20,7 @@ readonly EPERM=18
 readonly ENOPROTOOPT=19
 readonly EPROTONOSUPPORT=20
 readonly EACCES=21
+readonly ENOENT=22
 
 function lsfd_wait_for_pausing {
        ts_check_prog "sleep"
@@ -39,13 +40,18 @@ function lsfd_compare_dev {
     ts_check_prog "expr"
     ts_check_prog "stat"
 
-    local DEV=$("${LSFD}" --raw -n -o DEV -Q "${EXPR}")
+    local DEV
+    DEV=$("${LSFD}" --raw -n -o DEV -Q "${EXPR}")
     echo 'DEV[RUN]:' $?
+
     local MAJ=${DEV%:*}
     local MIN=${DEV#*:}
-    local DEVNUM=$(( ( MAJ << 8 ) + MIN ))
-    local STAT_DEVNUM=$(stat -c "%d" "$FILE")
+    local DEVNUM=$(ts_makedev "$MAJ" "$MIN")
+
+    local STAT_DEVNUM
+    STAT_DEVNUM=$(stat -c "%d" "$FILE")
     echo 'STAT[RUN]:' $?
+
     if [ "${DEVNUM}" == "${STAT_DEVNUM}" ]; then
        echo 'DEVNUM[STR]:' 0
     else
@@ -92,3 +98,29 @@ function lsfd_check_mkfds_factory
                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
+}