]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: (lsns::*) revise the way to use "$?"
authorMasatake YAMATO <yamato@redhat.com>
Tue, 24 Feb 2026 18:16:40 +0000 (03:16 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Tue, 24 Feb 2026 18:23:29 +0000 (03:23 +0900)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
tests/ts/lsns/filter
tests/ts/lsns/netns-from-sock
tests/ts/lsns/netnsid-for-persistent-namespaces

index d4b9fb4a1cbb6f4fade22cf7f9efc6216490344e..8dd4a5377b6441963edb762b4a5a7638a485b2f1 100755 (executable)
@@ -39,6 +39,7 @@ lsfd_check_userns
 ts_cd "$TS_OUTDIR"
 PID=
 FD=4
+RC=
 
 {
     coproc MKFDS { "$TS_HELPER_MKFDS" --comm ABC userns $FD; }
@@ -72,8 +73,9 @@ FD=4
        echo DONE >&"${MKFDS[1]}"
     fi
     wait "${MKFDS_PID}"
+    RC=$?
 } > $TS_OUTPUT 2>&1
-if [ "$?" == "$EPERM" ]; then
+if [ "$RC" == "$EPERM" ]; then
     ts_skip "unshare(2) is not permitted on this platform"
 fi
 ts_finalize
index 051167f730aa094b92d5e5997f57a2eba8ca946a..69947d7120d5162f865290510e3e448d40997d90 100755 (executable)
@@ -49,6 +49,7 @@ tcase[COMMAND]=
 
 PID_UNUSED=
 NETNS=
+RC=
 
 {
     coproc MKFDS { "$TS_HELPER_MKFDS" foreign-sockets 3 4; }
@@ -73,8 +74,9 @@ NETNS=
     fi
 
     wait "${MKFDS_PID}"
+    RC=$?
 } > $TS_OUTPUT 2>&1
-if [[ "$?" == "$EPERM" ]]; then
+if [[ "$RC" == "$EPERM" ]]; then
     ts_skip "unshare(2) is not permitted on this platform"
 fi
 ts_finalize
index 6c3cf59cf0208f76e7986e822bfaeebe0dbd0d89..49e751e6c39c35ad4480129043ded1bc7119941f 100755 (executable)
@@ -53,9 +53,12 @@ function netnsid_subtest {
     local column=$1
     local eval_func=eval_"$column"
     local O
+    local rc
     
     ts_init_subtest "$1"
-    if O=$($TS_CMD_LSNS --raw --noheadings --filter "NETNSID == '$NETNSID'" --output $1); then
+    O=$($TS_CMD_LSNS --raw --noheadings --filter "NETNSID == '$NETNSID'" --output $1)
+    rc=$?
+    if [[ $rc -eq 0 ]]; then
        if "$eval_func" "$O"; then
            echo OK
        else
@@ -63,7 +66,7 @@ function netnsid_subtest {
            echo "$O"
        fi
     else
-       echo ERROR $?
+       echo ERROR $rc
     fi > "$TS_OUTPUT" 2>&1
     ts_finalize_subtest
 }