Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: net: cope with slow env in so_txtime.sh test

The mentioned test is failing in slow environments:

# SO_TXTIME ipv4 clock monotonic
# ./so_txtime: recv: timeout: Resource temporarily unavailable
not ok 1 selftests: net: so_txtime.sh # exit=1

Tuning the tolerance in the test binary is error-prone and doomed
to failures is slow-enough environment.

Just resort to suppress any error in such cases. Note to suppress
them we need first to refactor a bit the code moving it to explicit
error handling.

Fixes: af5136f95045 ("selftests/net: SO_TXTIME with ETF and FQ")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Link: https://lore.kernel.org/r/2142d9ed4b5c5aa07dd1b455779625d91b175373.1707730902.git.pabeni@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Paolo Abeni and committed by
Jakub Kicinski
a7ee79b9 e58779f4

+25 -4
+25 -4
tools/testing/selftests/net/so_txtime.sh
··· 5 5 6 6 set -e 7 7 8 + readonly ksft_skip=4 8 9 readonly DEV="veth0" 9 10 readonly BIN="./so_txtime" 10 11 ··· 47 46 ip -netns "${NS1}" addr add fd::1/64 dev "${DEV}" nodad 48 47 ip -netns "${NS2}" addr add fd::2/64 dev "${DEV}" nodad 49 48 50 - do_test() { 49 + run_test() { 51 50 local readonly IP="$1" 52 51 local readonly CLOCK="$2" 53 52 local readonly TXARGS="$3" ··· 65 64 fi 66 65 67 66 local readonly START="$(date +%s%N --date="+ 0.1 seconds")" 67 + 68 68 ip netns exec "${NS2}" "${BIN}" -"${IP}" -c "${CLOCK}" -t "${START}" -S "${SADDR}" -D "${DADDR}" "${RXARGS}" -r & 69 69 ip netns exec "${NS1}" "${BIN}" -"${IP}" -c "${CLOCK}" -t "${START}" -S "${SADDR}" -D "${DADDR}" "${TXARGS}" 70 70 wait "$!" 71 71 } 72 72 73 + do_test() { 74 + run_test $@ 75 + [ $? -ne 0 ] && ret=1 76 + } 77 + 78 + do_fail_test() { 79 + run_test $@ 80 + [ $? -eq 0 ] && ret=1 81 + } 82 + 73 83 ip netns exec "${NS1}" tc qdisc add dev "${DEV}" root fq 84 + set +e 85 + ret=0 74 86 do_test 4 mono a,-1 a,-1 75 87 do_test 6 mono a,0 a,0 76 88 do_test 6 mono a,10 a,10 ··· 91 77 do_test 6 mono a,20,b,10 b,20,a,20 92 78 93 79 if ip netns exec "${NS1}" tc qdisc replace dev "${DEV}" root etf clockid CLOCK_TAI delta 400000; then 94 - ! do_test 4 tai a,-1 a,-1 95 - ! do_test 6 tai a,0 a,0 80 + do_fail_test 4 tai a,-1 a,-1 81 + do_fail_test 6 tai a,0 a,0 96 82 do_test 6 tai a,10 a,10 97 83 do_test 4 tai a,10,b,20 a,10,b,20 98 84 do_test 6 tai a,20,b,10 b,10,a,20 99 85 else 100 86 echo "tc ($(tc -V)) does not support qdisc etf. skipping" 87 + [ $ret -eq 0 ] && ret=$ksft_skip 101 88 fi 102 89 103 - echo OK. All tests passed 90 + if [ $ret -eq 0 ]; then 91 + echo OK. All tests passed 92 + elif [[ $ret -ne $ksft_skip && -n "$KSFT_MACHINE_SLOW" ]]; then 93 + echo "Ignoring errors due to slow environment" 1>&2 94 + ret=0 95 + fi 96 + exit $ret