]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: fold ts_failed_subtest into ts_failed
authorThomas Weißschuh <thomas@t-8ch.de>
Tue, 19 May 2026 20:54:44 +0000 (22:54 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Wed, 20 May 2026 07:55:17 +0000 (09:55 +0200)
The differences between ts_failed_subtest and ts_failed are miniminal.
Make ts_failed usable from subtest context and remove the now unnecessary
ts_failed_subtest.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
tests/functions.sh
tests/ts/chrt/all-tasks
tests/ts/getino/getino
tests/ts/lsfd/lsfd-functions.bash
tests/ts/lsfd/mkfds-unix-dgram

index f28e18c7db403146570b233da0c186e0d4de790a..a54064b79f31cefbee59268578147518f03d8b1f 100644 (file)
@@ -194,7 +194,7 @@ function ts_runs_on_qemu {
        return
 }
 
-function ts_failed_subtest {
+function ts_failed {
        local msg="FAILED"
        local ret=1
 
@@ -211,12 +211,11 @@ function ts_failed_subtest {
                ts_report " $msg ($1)"
        fi
 
-       return $ret
-}
+       if [ -z "$TS_SUBNAME" ]; then
+               exit $ret
+       fi
 
-function ts_failed {
-       ts_failed_subtest "$1"
-       exit $?
+       return $ret
 }
 
 function ts_report_ok {
@@ -652,7 +651,7 @@ function ts_finalize_subtest {
        else
                ts_gen_diff
                if [ $? -eq 1 ]; then
-                       ts_failed_subtest "$1"
+                       ts_failed "$1"
                        res=1
                else
                        ts_report_ok "$(tt_gen_mem_report "$1")"
index 4e9c26228a219ca562502362ce351d2b9f460fd3..f3203a256532b5b9fa924759c70010338980716a 100755 (executable)
@@ -72,7 +72,7 @@ function search_tids() {
 ts_init_subtest "get-attributes"
 
 if ! start_threads_create 5 5; then
-    ts_failed_subtest "failed to start threads helper program"
+    ts_failed "failed to start threads helper program"
 else
     chrt_output="$("$TS_CMD_CHRT" --all-tasks --pid "$HELPER_PID" 2>>"$TS_ERRLOG"\
                     | sed -E 's/pid ([0-9]*).*/\1/g' | sort | uniq)"
@@ -101,7 +101,7 @@ ts_init_subtest "set-attributes"
 
 PRIORITY=33
 if ! start_threads_create 5 5; then
-    ts_failed_subtest "failed to start threads helper program"
+    ts_failed "failed to start threads helper program"
 else
     # Set the real-time scheduling attributes for all tasks
     "$TS_CMD_CHRT" --all-tasks --fifo --pid "$PRIORITY" "$HELPER_PID" 2>>"$TS_ERRLOG"
index 61d138a2fe50efb83c97d926b3b1b9c66d7ead4e..044ac928e97117eb2fe994ca82297a632c926553 100755 (executable)
@@ -77,7 +77,7 @@ function do_ns_check() {
                                     "$TS_CMD_GETINO --${ns_name}ns \$\$" 2>>"$TS_ERRLOG")
 
     if (( ts_ns_ino == unshare_ns_ino )); then
-      ts_failed_subtest "${ns_name} namespace unchanged (NS ID: $ts_ns_ino)"
+      ts_failed "${ns_name} namespace unchanged (NS ID: $ts_ns_ino)"
     fi
   else
     ts_skip "no ${ns_name} namespace support"
@@ -125,7 +125,7 @@ if [ -r /proc/self/ns/user ]; then
   if grep "$("$TS_HELPER_STRERROR" EACCES)" "$TS_ERRLOG" &>/dev/null; then
     ts_skip "missing permissions to obtain user namespace"
   else
-    (( ts_user_ns == unshare_user_ns )) && ts_failed_subtest "user namespace unchanged"
+    (( ts_user_ns == unshare_user_ns )) && ts_failed "user namespace unchanged"
   fi
 else
   ts_skip "no user namespace support"
index 2b581724188d3a73fd24640fb9e19fc14796f587..29229b343b48e1870617e16d2684cb6891d4833a 100644 (file)
@@ -139,7 +139,7 @@ function lsfd_check_sockdiag
            "$ENOENT")
                ts_skip "sockdiag netlink socket is not available";;
            *)
-               ts_failed$suffix "failed to create a sockdiag netlink socket $family ($err): $msg";;
+               ts_failed "failed to create a sockdiag netlink socket $family ($err): $msg";;
        esac
 
        return 1
index 9f0916e54454522f284739561b233671d273d2b2..8d647f60e01afa84560133fc8876db9d06b7a2b5 100755 (executable)
@@ -75,7 +75,7 @@ ts_finalize_subtest
 
 ts_init_subtest "ENDPOINTS-column"
 if ! lsfd_check_sockdiag --subtest unix; then
-    # lsfd_check_sockdiag calls ts_skip or ts_failed_subtest.
+    # lsfd_check_sockdiag calls ts_skip or ts_failed.
     :
 elif ts_is_in_docker; then
     ts_skip "unsupported in docker environment"
@@ -107,7 +107,7 @@ ts_finalize_subtest
 
 ts_init_subtest "UNIX.IPEEER-column"
 if ! lsfd_check_sockdiag --subtest unix; then
-    # lsfd_check_sockdiag calls ts_skip or ts_failed_subtest.
+    # lsfd_check_sockdiag calls ts_skip or ts_failed.
     :
 elif ts_is_in_docker; then
     ts_skip "unsupported in docker environment"