The differences between ts_skip_subtest and ts_skip are miniminal.
Make ts_skip usable from subtest context and remove the now unnecessary
ts_skip_subtest.
This allows subtests to make use of all of the convenient helpers built
around ts_skip.
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
function ts_skip {
ts_report_skip "$1"
- ts_cleanup_on_exit
- exit 0
+ if [ -n "$TS_SUBNAME" ]; then
+ TS_SUBSKIPPED="yes"
+ else
+ ts_cleanup_on_exit
+ exit 0
+ fi
}
function ts_skip_nonroot {
return $res
}
-function ts_skip_subtest {
- TS_SUBSKIPPED="yes"
- ts_report_skip "$1"
-}
-
# Specify the kernel version X.Y.Z you wish to compare against like:
#
# ts_kernel_ver_lt X Y Z
function skip_policy {
$TS_CMD_CHRT --max | grep $1 | grep 'priority' &> /dev/null
if [ $? == 1 ]; then
- ts_skip_subtest "unsupported"
+ ts_skip "unsupported"
ts_finalize_subtest
return 1
fi
function skip_kernel_lt {
if ts_kernel_ver_lt $1 $2 $3; then
- ts_skip_subtest "kernel version must be >= $1.$2.$3"
+ ts_skip "kernel version must be >= $1.$2.$3"
ts_finalize_subtest
return 1
fi
function skip_kernel_ge {
ts_kernel_ver_lt $1 $2 $3
if [ $? == 1 ]; then
- ts_skip_subtest "kernel version must be < $1.$2.$3"
+ ts_skip "kernel version must be < $1.$2.$3"
ts_finalize_subtest
return 1
fi
function skip_policy {
$TS_CMD_CHRT --max | grep $1 | grep 'priority' &> /dev/null
if [ $? == 1 ]; then
- ts_skip_subtest "unsupported"
+ ts_skip "unsupported"
ts_finalize_subtest
return 1
fi
TEST_LINK="$TS_OUTDIR/fakelink"
if ! ln -s / "$TEST_LINK"; then
- ts_skip_subtest "failed to create symbolic link to root filesystem"
+ ts_skip "failed to create symbolic link to root filesystem"
else
# This return the right mount target
$TS_CMD_FINDMNT --output TARGET --canonicalize "$TEST_LINK" >>"$TS_OUTPUT" 2>>"$TS_ERRLOG"
ts_failed_subtest "${ns_name} namespace unchanged (NS ID: $ts_ns_ino)"
fi
else
- ts_skip_subtest "no ${ns_name} namespace support"
+ ts_skip "no ${ns_name} namespace support"
fi
}
bash -c "$TS_CMD_GETINO --userns \$\$" 2>>"$TS_ERRLOG")
if grep "$("$TS_HELPER_STRERROR" EACCES)" "$TS_ERRLOG" &>/dev/null; then
- ts_skip_subtest "missing permissions to obtain user namespace"
+ ts_skip "missing permissions to obtain user namespace"
else
(( ts_user_ns == unshare_user_ns )) && ts_failed_subtest "user namespace unchanged"
fi
else
- ts_skip_subtest "no user namespace support"
+ ts_skip "no user namespace support"
fi
ts_finalize_subtest
ts_init_subtest "o-loop-val"
if [ "$TS_PARALLEL" = "yes" ]; then
# There is a race in $LODEV is usage
- ts_skip_subtest "no-reentrant"
+ ts_skip "no-reentrant"
else
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
LODEV=$( $TS_CMD_LOSETUP --find 2>> "$TS_OUTPUT" )
ts_finalize_subtest
ts_init_subtest "is-mounted-btrfs"
-grep -q '#define HAVE_BTRFS_SUPPORT' ${top_builddir}/config.h || ts_skip_subtest "no btrfs support"
+grep -q '#define HAVE_BTRFS_SUPPORT' ${top_builddir}/config.h || ts_skip "no btrfs support"
ts_run $TESTPROG --is-mounted "$TS_SELF/files/fstab_btrfs" "$TS_SELF/files/mountinfo_btrfs" &> "$TS_OUTPUT"
ts_finalize_subtest
if [ -d /proc ]; then
ts_run $TESTPROG --mountpoint /proc &> "$TS_OUTPUT"
else
- ts_skip_subtest "no /proc"
+ ts_skip "no /proc"
fi
ts_finalize_subtest
if [ -d /proc/sys/kernel ]; then
ts_run $TESTPROG --mountpoint /proc/sys/kernel &> "$TS_OUTPUT"
else
- ts_skip_subtest "no /proc"
+ ts_skip "no /proc"
fi
ts_finalize_subtest
ts_init_subtest "plain-conflict"
if [ "$TS_PARALLEL" = "yes" ]; then
# There is a race in $LODEV is usage
- ts_skip_subtest "no-reentrant"
+ ts_skip "no-reentrant"
else
LODEV=$( $TS_CMD_LOSETUP --find --nooverlap --show $BACKFILE )
if [ -z "$LODEV" ]; then
ts_init_subtest "plain-readonly"
if [ "$TS_PARALLEL" = "yes" ]; then
# There is a race in $LODEV is usage
- ts_skip_subtest "no-reentrant"
+ ts_skip "no-reentrant"
else
LODEV=$( $TS_CMD_LOSETUP --find --nooverlap --show --read-only $BACKFILE )
if [ -z "$LODEV" ]; then
"$TS_CMD_LSCLOCKS" $NO_DISCOVER --dynamic-clock /dev/ptp0 --output TYPE,ID,CLOCK,NAME \
| tail -1 > "$TS_OUTPUT" 2>> "$TS_ERRLOG"
else
- ts_skip_subtest "/dev/ptp0 not usable"
+ ts_skip "/dev/ptp0 not usable"
fi
ts_finalize_subtest
"$TS_CMD_LSCLOCKS" $NO_DISCOVER --rtc /dev/rtc0 --output TYPE,ID,CLOCK,NAME \
| tail -1 > "$TS_OUTPUT" 2>> "$TS_ERRLOG"
else
- ts_skip_subtest "/dev/rtc0 not usable"
+ ts_skip "/dev/rtc0 not usable"
fi
ts_finalize_subtest
} > "$TS_OUTPUT" 2>&1
if [ "$C-$RC" == "pidfd-$TS_EXIT_NOTSUPP" ]; then
- ts_skip_subtest "pidfd_open(2) is not available"
+ ts_skip "pidfd_open(2) is not available"
ts_finalize_subtest
continue
fi
STTYPE="$(head -n1 "$TS_OUTPUT" | awk '{print $2}')"
if [ "$C-$STTYPE" == "pidfd-REG" ]; then
- ts_skip_subtest "pidfd is from pidfs instead of anon inode"
+ ts_skip "pidfd is from pidfs instead of anon inode"
ts_finalize_subtest
continue
fi
RC=$?
if [ "$C-$RC" == "pidfd-$TS_EXIT_NOTSUPP" ]; then
- ts_skip_subtest "pidfd_open(2) is not available"
+ ts_skip "pidfd_open(2) is not available"
ts_finalize_subtest
continue
fi
} > "$TS_OUTPUT" 2>&1
if [ "$C-$RC" == "pidfd-$TS_EXIT_NOTSUPP" ]; then
- ts_skip_subtest "pidfd_open(2) is not available"
+ ts_skip "pidfd_open(2) is not available"
ts_finalize_subtest
continue
fi
EXPR='(ASSOC == "mem") and (INODE == '"$INO"') and (MODE != "r--") and (MODE != "rw-") and (MODE != "rwx")'
ts_init_subtest "MODE-x-bit"
if [ "$QEMU_USER" == "1" ]; then
- ts_skip_subtest "running under qemu-user emulation"
+ ts_skip "running under qemu-user emulation"
elif [ "$UID" != "0" ]; then
- ts_skip_subtest "no root permissions"
+ ts_skip "no root permissions"
else
{
coproc MKFDS { "$TS_HELPER_MKFDS" ro-regular-file $FD; }
ts_init_subtest "XMODE-x-bit"
if [ "$QEMU_USER" == "1" ]; then
- ts_skip_subtest "running under qemu-user emulation"
+ ts_skip "running under qemu-user emulation"
elif [ "$UID" != "0" ]; then
- ts_skip_subtest "no root permissions"
+ ts_skip "no root permissions"
else
{
coproc MKFDS { "$TS_HELPER_MKFDS" ro-regular-file $FD; }
wait "${MKFDS_PID}"
RC=$?
if [ "$RC" == "$TS_EXIT_NOTSUPP" ]; then
- ts_skip_subtest "$m lock is not available"
+ ts_skip "$m lock is not available"
ts_finalize_subtest
continue
fi
wait "${MKFDS_PID}"
RC=$?
if [ "$RC" == "$TS_EXIT_NOTSUPP" ]; then
- ts_skip_subtest "$m lock is not available"
+ ts_skip "$m lock is not available"
ts_finalize_subtest
continue
fi
0)
return 0;;
"$EPROTONOSUPPORT")
- ts_skip$suffix "NETLINK_SOCK_DIAG protocol is not supported in socket(2)";;
+ ts_skip "NETLINK_SOCK_DIAG protocol is not supported in socket(2)";;
"$EACCES")
- ts_skip$suffix "sending a msg via a sockdiag netlink socket is not permitted";;
+ ts_skip "sending a msg via a sockdiag netlink socket is not permitted";;
"$ENOENT")
- ts_skip$suffix "sockdiag netlink socket is not available";;
+ ts_skip "sockdiag netlink socket is not available";;
*)
ts_failed$suffix "failed to create a sockdiag netlink socket $family ($err): $msg";;
esac
ts_init_subtest "$tname"-devnetns
if [[ -z "${devnetns_available}" ]]; then
- ts_skip_subtest "no method to access devnetns on this platform"
+ ts_skip "no method to access devnetns on this platform"
else
{
output=$(${TS_CMD_LSFD} -p "${PID}" -n --raw -o TUN.DEVNETNS -Q "${EXPR}")
for multiplexer in pselect6 select poll ppoll; do
ts_init_subtest "${multiplexer}"
if ! "$TS_HELPER_MKFDS" -W | grep -q "^$multiplexer\$"; then
- ts_skip_subtest "the multiplexer ${multiplexer} is not available"
+ ts_skip "the multiplexer ${multiplexer} is not available"
ts_finalize_subtest
continue
fi
if [[ "$syscall_status" != 0 ]]; then
kill -CONT "${PID}"
wait "${MKFDS_PID}"
- ts_skip_subtest "cannot open /proc/${PID}/syscall"
+ ts_skip "cannot open /proc/${PID}/syscall"
ts_finalize_subtest
continue
fi
if [[ "$syscall_n" == 0 ]]; then
kill -CONT "${PID}"
wait "${MKFDS_PID}"
- ts_skip_subtest "incorrect syscall number in /proc/${PID}/syscall"
+ ts_skip "incorrect syscall number in /proc/${PID}/syscall"
ts_finalize_subtest
continue
fi
{
ts_init_subtest "STREAM-ENDPOINT"
if [ "$QEMU_USER" == "1" ]; then
- ts_skip_subtest "running under qemu-user emulation"
+ ts_skip "running under qemu-user emulation"
ts_finalize_subtest
return
fi
{
ts_init_subtest "STREAM-SHUTDOWN-STATE"
if [ "$QEMU_USER" == "1" ]; then
- ts_skip_subtest "running under qemu-user emulation"
+ ts_skip "running under qemu-user emulation"
ts_finalize_subtest
return
fi
{
ts_init_subtest "STREAM-ENDPOINT-halfclose"
if [ "$QEMU_USER" == "1" ]; then
- ts_skip_subtest "running under qemu-user emulation"
+ ts_skip "running under qemu-user emulation"
ts_finalize_subtest
return
fi
ts_init_subtest "ENDPOINTS-column"
if ! lsfd_check_sockdiag --subtest unix; then
- # lsfd_check_sockdiag calls ts_skip_subtest or ts_failed_subtest.
+ # lsfd_check_sockdiag calls ts_skip or ts_failed_subtest.
:
elif ts_is_in_docker; then
- ts_skip_subtest "unsupported in docker environment"
+ ts_skip "unsupported in docker environment"
else
{
coproc MKFDS { "$TS_HELPER_MKFDS" unix-dgram $FDS $FDC \
ts_init_subtest "UNIX.IPEEER-column"
if ! lsfd_check_sockdiag --subtest unix; then
- # lsfd_check_sockdiag calls ts_skip_subtest or ts_failed_subtest.
+ # lsfd_check_sockdiag calls ts_skip or ts_failed_subtest.
:
elif ts_is_in_docker; then
- ts_skip_subtest "unsupported in docker environment"
+ ts_skip "unsupported in docker environment"
else
{
coproc MKFDS { "$TS_HELPER_MKFDS" unix-dgram $FDS $FDC \
RC=$?
} > "$TS_OUTPUT" 2>&1
if [ "$RC" == "$EPERM" ]; then
- ts_skip_subtest "unshare(2) is not permitted on this platform"
+ ts_skip "unshare(2) is not permitted on this platform"
ts_finalize_subtest
continue
fi
ts_check_test_command "$TS_HELPER_CANONICALIZE"
grep -q 'nodev[[:space:]]*tmpfs' /proc/filesystems || \
- ts_skip_subtest "tmpfs unsupported"
+ ts_skip "tmpfs unsupported"
mkdir -p $TS_MOUNTPOINT &> /dev/null
$TS_CMD_MOUNT -t tmpfs tmpfs $TS_MOUNTPOINT >> "$TS_OUTPUT" 2>> "$TS_ERRLOG" \
-- $TESTPROG ${BASE}/root-sym/foo \
| sed "s:${BASE}::g" >> "$TS_OUTPUT" 2>> "$TS_ERRLOG"
else
- ts_skip_subtest "nobody user is missing"
+ ts_skip "nobody user is missing"
fi
ts_finalize_subtest
if [ "$HAVE_WIDECHAR" = true ]; then
$TS_HELPER_MBSENCODE --invalid "${STRINGS[@]}" >> "$TS_OUTPUT" 2>> "$TS_ERRLOG"
else
- ts_skip_subtest 'No widechar support'
+ ts_skip 'No widechar support'
fi
ts_finalize_subtest
LC_ALL=C.UTF-8 \
$TS_HELPER_MBSENCODE --safe "${STRINGS[@]}" >> "$TS_OUTPUT" 2>> "$TS_ERRLOG"
else
- ts_skip_subtest 'No widechar support'
+ ts_skip 'No widechar support'
fi
ts_finalize_subtest
LC_ALL=C.UTF-8 \
$TS_HELPER_MBSENCODE --invalid "${STRINGS[@]}" >> "$TS_OUTPUT" 2>> "$TS_ERRLOG"
else
- ts_skip_subtest 'No widechar support'
+ ts_skip 'No widechar support'
fi
ts_finalize_subtest
unset LIBMOUNT_UTAB
rm -f $MOUNTER
else
- ts_skip_subtest "tmpfs not mounted"
+ ts_skip "tmpfs not mounted"
fi
else
- ts_skip_subtest "tmpfs unsupported"
+ ts_skip "tmpfs unsupported"
fi
ts_finalize_subtest
unset -v UL_TEST_VAR
if grep "$($TS_HELPER_STRERROR ENOTTY)" "$TS_ERRLOG"; then
- ts_skip_subtest "failed to launch login session: ENOTTY"
+ ts_skip "failed to launch login session: ENOTTY"
fi
ts_finalize_subtest
ps --version >/dev/null
if ! compare_ptys; then
- ts_skip_subtest "$errmsg"
+ ts_skip "$errmsg"
unset -v errmsg
fi
ts_finalize_subtest
| grep -o "$grp_name" \
| uniq >> "$TS_OUTPUT"
-grep -q 'Authentication failure' "$TS_ERRLOG" && ts_skip_subtest "authentication failure"
+grep -q 'Authentication failure' "$TS_ERRLOG" && ts_skip "authentication failure"
ts_finalize_subtest
ts_init_subtest "supplemental-no-login"
| grep -o "$grp_name" \
| uniq >> "$TS_OUTPUT"
-grep -q 'Authentication failure' "$TS_ERRLOG" && ts_skip_subtest "authentication failure"
+grep -q 'Authentication failure' "$TS_ERRLOG" && ts_skip "authentication failure"
ts_finalize_subtest
ts_init_subtest "group-id"
unset -v UL_TEST_ENV
if grep -q "$($TS_HELPER_STRERROR EPERM)" "$TS_OUTPUT" "$TS_ERRLOG"; then
- ts_skip_subtest "missing permissions"
+ ts_skip "missing permissions"
fi
ts_finalize_subtest
"$TS_CMD_UNSHARE" --whitelist-env UL_TEST_ENV1 /bin/bash -c 'echo "${UL_TEST_ENV1}${UL_TEST_ENV2}"' >>"$TS_OUTPUT" 2>>"$TS_ERRLOG"
if grep -q "$($TS_HELPER_STRERROR EPERM)" "$TS_OUTPUT" "$TS_ERRLOG"; then
- ts_skip_subtest "missing permissions"
+ ts_skip "missing permissions"
fi
ts_finalize_subtest