Skip to content

Commit af76b44

Browse files
pmachatakuba-moo
authored andcommitted
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>
1 parent 601d9d7 commit af76b44

2 files changed

Lines changed: 73 additions & 73 deletions

File tree

tools/testing/selftests/net/forwarding/lib.sh

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -445,79 +445,6 @@ done
445445
##############################################################################
446446
# Helpers
447447

448-
# Whether FAILs should be interpreted as XFAILs. Internal.
449-
FAIL_TO_XFAIL=
450-
451-
check_err()
452-
{
453-
local err=$1
454-
local msg=$2
455-
456-
if ((err)); then
457-
if [[ $FAIL_TO_XFAIL = yes ]]; then
458-
ret_set_ksft_status $ksft_xfail "$msg"
459-
else
460-
ret_set_ksft_status $ksft_fail "$msg"
461-
fi
462-
fi
463-
}
464-
465-
check_fail()
466-
{
467-
local err=$1
468-
local msg=$2
469-
470-
check_err $((!err)) "$msg"
471-
}
472-
473-
check_err_fail()
474-
{
475-
local should_fail=$1; shift
476-
local err=$1; shift
477-
local what=$1; shift
478-
479-
if ((should_fail)); then
480-
check_fail $err "$what succeeded, but should have failed"
481-
else
482-
check_err $err "$what failed"
483-
fi
484-
}
485-
486-
xfail()
487-
{
488-
FAIL_TO_XFAIL=yes "$@"
489-
}
490-
491-
xfail_on_slow()
492-
{
493-
if [[ $KSFT_MACHINE_SLOW = yes ]]; then
494-
FAIL_TO_XFAIL=yes "$@"
495-
else
496-
"$@"
497-
fi
498-
}
499-
500-
omit_on_slow()
501-
{
502-
if [[ $KSFT_MACHINE_SLOW != yes ]]; then
503-
"$@"
504-
fi
505-
}
506-
507-
xfail_on_veth()
508-
{
509-
local dev=$1; shift
510-
local kind
511-
512-
kind=$(ip -j -d link show dev $dev |
513-
jq -r '.[].linkinfo.info_kind')
514-
if [[ $kind = veth ]]; then
515-
FAIL_TO_XFAIL=yes "$@"
516-
else
517-
"$@"
518-
fi
519-
}
520-
521448
not()
522449
{
523450
"$@"

tools/testing/selftests/net/lib.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,3 +361,76 @@ tests_run()
361361
$current_test
362362
done
363363
}
364+
365+
# Whether FAILs should be interpreted as XFAILs. Internal.
366+
FAIL_TO_XFAIL=
367+
368+
check_err()
369+
{
370+
local err=$1
371+
local msg=$2
372+
373+
if ((err)); then
374+
if [[ $FAIL_TO_XFAIL = yes ]]; then
375+
ret_set_ksft_status $ksft_xfail "$msg"
376+
else
377+
ret_set_ksft_status $ksft_fail "$msg"
378+
fi
379+
fi
380+
}
381+
382+
check_fail()
383+
{
384+
local err=$1
385+
local msg=$2
386+
387+
check_err $((!err)) "$msg"
388+
}
389+
390+
check_err_fail()
391+
{
392+
local should_fail=$1; shift
393+
local err=$1; shift
394+
local what=$1; shift
395+
396+
if ((should_fail)); then
397+
check_fail $err "$what succeeded, but should have failed"
398+
else
399+
check_err $err "$what failed"
400+
fi
401+
}
402+
403+
xfail()
404+
{
405+
FAIL_TO_XFAIL=yes "$@"
406+
}
407+
408+
xfail_on_slow()
409+
{
410+
if [[ $KSFT_MACHINE_SLOW = yes ]]; then
411+
FAIL_TO_XFAIL=yes "$@"
412+
else
413+
"$@"
414+
fi
415+
}
416+
417+
omit_on_slow()
418+
{
419+
if [[ $KSFT_MACHINE_SLOW != yes ]]; then
420+
"$@"
421+
fi
422+
}
423+
424+
xfail_on_veth()
425+
{
426+
local dev=$1; shift
427+
local kind
428+
429+
kind=$(ip -j -d link show dev $dev |
430+
jq -r '.[].linkinfo.info_kind')
431+
if [[ $kind = veth ]]; then
432+
FAIL_TO_XFAIL=yes "$@"
433+
else
434+
"$@"
435+
fi
436+
}

0 commit comments

Comments
 (0)