mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 09:04:39 +02:00
selftests: net: lib: Move checks from forwarding/lib.sh here
For logging to be useful, something has to set RET and retmsg by calling ret_set_ksft_status(). There is a suite of functions to that end in forwarding/lib: check_err, check_fail et.al. Move them to net/lib.sh so that every net test can use them. Existing lib.sh users might be using these same names for their functions. However lib.sh is always sourced near the top of the file (checked), and whatever new definitions will simply override the ones provided by lib.sh. Signed-off-by: Petr Machata <petrm@nvidia.com> Reviewed-by: Amit Cohen <amcohen@nvidia.com> Acked-by: Shuah Khan <skhan@linuxfoundation.org> Link: https://patch.msgid.link/f488a00dc85b8e0c1f3c71476b32b21b5189a847.1731589511.git.petrm@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
601d9d70a4
commit
af76b44318
|
|
@ -445,79 +445,6 @@ done
|
|||
##############################################################################
|
||||
# Helpers
|
||||
|
||||
# Whether FAILs should be interpreted as XFAILs. Internal.
|
||||
FAIL_TO_XFAIL=
|
||||
|
||||
check_err()
|
||||
{
|
||||
local err=$1
|
||||
local msg=$2
|
||||
|
||||
if ((err)); then
|
||||
if [[ $FAIL_TO_XFAIL = yes ]]; then
|
||||
ret_set_ksft_status $ksft_xfail "$msg"
|
||||
else
|
||||
ret_set_ksft_status $ksft_fail "$msg"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
check_fail()
|
||||
{
|
||||
local err=$1
|
||||
local msg=$2
|
||||
|
||||
check_err $((!err)) "$msg"
|
||||
}
|
||||
|
||||
check_err_fail()
|
||||
{
|
||||
local should_fail=$1; shift
|
||||
local err=$1; shift
|
||||
local what=$1; shift
|
||||
|
||||
if ((should_fail)); then
|
||||
check_fail $err "$what succeeded, but should have failed"
|
||||
else
|
||||
check_err $err "$what failed"
|
||||
fi
|
||||
}
|
||||
|
||||
xfail()
|
||||
{
|
||||
FAIL_TO_XFAIL=yes "$@"
|
||||
}
|
||||
|
||||
xfail_on_slow()
|
||||
{
|
||||
if [[ $KSFT_MACHINE_SLOW = yes ]]; then
|
||||
FAIL_TO_XFAIL=yes "$@"
|
||||
else
|
||||
"$@"
|
||||
fi
|
||||
}
|
||||
|
||||
omit_on_slow()
|
||||
{
|
||||
if [[ $KSFT_MACHINE_SLOW != yes ]]; then
|
||||
"$@"
|
||||
fi
|
||||
}
|
||||
|
||||
xfail_on_veth()
|
||||
{
|
||||
local dev=$1; shift
|
||||
local kind
|
||||
|
||||
kind=$(ip -j -d link show dev $dev |
|
||||
jq -r '.[].linkinfo.info_kind')
|
||||
if [[ $kind = veth ]]; then
|
||||
FAIL_TO_XFAIL=yes "$@"
|
||||
else
|
||||
"$@"
|
||||
fi
|
||||
}
|
||||
|
||||
not()
|
||||
{
|
||||
"$@"
|
||||
|
|
|
|||
|
|
@ -361,3 +361,76 @@ tests_run()
|
|||
$current_test
|
||||
done
|
||||
}
|
||||
|
||||
# Whether FAILs should be interpreted as XFAILs. Internal.
|
||||
FAIL_TO_XFAIL=
|
||||
|
||||
check_err()
|
||||
{
|
||||
local err=$1
|
||||
local msg=$2
|
||||
|
||||
if ((err)); then
|
||||
if [[ $FAIL_TO_XFAIL = yes ]]; then
|
||||
ret_set_ksft_status $ksft_xfail "$msg"
|
||||
else
|
||||
ret_set_ksft_status $ksft_fail "$msg"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
check_fail()
|
||||
{
|
||||
local err=$1
|
||||
local msg=$2
|
||||
|
||||
check_err $((!err)) "$msg"
|
||||
}
|
||||
|
||||
check_err_fail()
|
||||
{
|
||||
local should_fail=$1; shift
|
||||
local err=$1; shift
|
||||
local what=$1; shift
|
||||
|
||||
if ((should_fail)); then
|
||||
check_fail $err "$what succeeded, but should have failed"
|
||||
else
|
||||
check_err $err "$what failed"
|
||||
fi
|
||||
}
|
||||
|
||||
xfail()
|
||||
{
|
||||
FAIL_TO_XFAIL=yes "$@"
|
||||
}
|
||||
|
||||
xfail_on_slow()
|
||||
{
|
||||
if [[ $KSFT_MACHINE_SLOW = yes ]]; then
|
||||
FAIL_TO_XFAIL=yes "$@"
|
||||
else
|
||||
"$@"
|
||||
fi
|
||||
}
|
||||
|
||||
omit_on_slow()
|
||||
{
|
||||
if [[ $KSFT_MACHINE_SLOW != yes ]]; then
|
||||
"$@"
|
||||
fi
|
||||
}
|
||||
|
||||
xfail_on_veth()
|
||||
{
|
||||
local dev=$1; shift
|
||||
local kind
|
||||
|
||||
kind=$(ip -j -d link show dev $dev |
|
||||
jq -r '.[].linkinfo.info_kind')
|
||||
if [[ $kind = veth ]]; then
|
||||
FAIL_TO_XFAIL=yes "$@"
|
||||
else
|
||||
"$@"
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user