Re: [PATCH] selftests: Use kselftest skip code for skipped tests

From: Petr Machata
Date: Tue May 25 2021 - 06:20:31 EST



Po-Hsu Lin <po-hsu.lin@xxxxxxxxxxxxx> writes:

> diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
> index 42e28c9..eed9f08 100644
> --- a/tools/testing/selftests/net/forwarding/lib.sh
> +++ b/tools/testing/selftests/net/forwarding/lib.sh
> @@ -4,6 +4,9 @@
> ##############################################################################
> # Defines
>
> +# Kselftest framework requirement - SKIP code is 4.
> +ksft_skip=4
> +
> # Can be overridden by the configuration file.
> PING=${PING:=ping}
> PING6=${PING6:=ping6}
> @@ -121,7 +124,7 @@ check_ethtool_lanes_support()
>
> if [[ "$(id -u)" -ne 0 ]]; then
> echo "SKIP: need root privileges"
> - exit 0
> + exit $ksft_skip
> fi
>
> if [[ "$CHECK_TC" = "yes" ]]; then
> diff --git a/tools/testing/selftests/net/forwarding/router_mpath_nh.sh b/tools/testing/selftests/net/forwarding/router_mpath_nh.sh
> index 76efb1f..bb7dc6d 100755
> --- a/tools/testing/selftests/net/forwarding/router_mpath_nh.sh
> +++ b/tools/testing/selftests/net/forwarding/router_mpath_nh.sh
> @@ -1,6 +1,9 @@
> #!/bin/bash
> # SPDX-License-Identifier: GPL-2.0
>
> +# Kselftest framework requirement - SKIP code is 4.
> +ksft_skip=4
> +
> ALL_TESTS="
> ping_ipv4
> ping_ipv6
> @@ -411,7 +414,7 @@ ping_ipv6()
> ip nexthop ls >/dev/null 2>&1
> if [ $? -ne 0 ]; then
> echo "Nexthop objects not supported; skipping tests"
> - exit 0
> + exit $ksft_skip
> fi
>
> trap cleanup EXIT

router_mpath_nh.sh sources lib.sh, which you changed above. This hunk
should not be necessary.

> diff --git a/tools/testing/selftests/net/forwarding/router_mpath_nh_res.sh b/tools/testing/selftests/net/forwarding/router_mpath_nh_res.sh
> index 4898dd4..e7bb976 100755
> --- a/tools/testing/selftests/net/forwarding/router_mpath_nh_res.sh
> +++ b/tools/testing/selftests/net/forwarding/router_mpath_nh_res.sh
> @@ -1,6 +1,9 @@
> #!/bin/bash
> # SPDX-License-Identifier: GPL-2.0
>
> +# Kselftest framework requirement - SKIP code is 4.
> +ksft_skip=4
> +
> ALL_TESTS="
> ping_ipv4
> ping_ipv6
> @@ -386,7 +389,7 @@ ping_ipv6()
> ip nexthop ls >/dev/null 2>&1
> if [ $? -ne 0 ]; then
> echo "Nexthop objects not supported; skipping tests"
> - exit 0
> + exit $ksft_skip
> fi
>
> trap cleanup EXIT

Likewise.

Unless I'm missing some indirect dependency, no other selftests in your
patch have this problem.