diff mbox series

[net-next,v4,2/6] selftests: forwarding: move initial root check to the beginning

Message ID 20240418160830.3751846-3-jiri@resnulli.us (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series selftests: virtio_net: introduce initial testing infrastructure | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 1 maintainers not CCed: linux-kselftest@vger.kernel.org
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success net selftest script(s) already in Makefile
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 22 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-04-19--18-00 (tests: 963)

Commit Message

Jiri Pirko April 18, 2024, 4:08 p.m. UTC
From: Jiri Pirko <jiri@nvidia.com>

This check can be done at the very beginning of the script.
As the follow up patch needs to add early code that needs to be executed
after the check, move it.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
v3->v4:
- removed NUM_NETIFS mode, rephrased the patch subject and description
  accordingly
---
 tools/testing/selftests/net/forwarding/lib.sh | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Petr Machata April 18, 2024, 4:56 p.m. UTC | #1
Jiri Pirko <jiri@resnulli.us> writes:

> From: Jiri Pirko <jiri@nvidia.com>
>
> This check can be done at the very beginning of the script.
> As the follow up patch needs to add early code that needs to be executed
> after the check, move it.
>
> Signed-off-by: Jiri Pirko <jiri@nvidia.com>

Reviewed-by: Petr Machata <petrm@nvidia.com>
Benjamin Poirier April 18, 2024, 6:48 p.m. UTC | #2
On 2024-04-18 18:08 +0200, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@nvidia.com>
> 
> This check can be done at the very beginning of the script.
> As the follow up patch needs to add early code that needs to be executed
> after the check, move it.
> 
> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
> ---
> v3->v4:
> - removed NUM_NETIFS mode, rephrased the patch subject and description
>   accordingly
> ---
>  tools/testing/selftests/net/forwarding/lib.sh | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
> index 7913c6ee418d..b63a5866ce97 100644
> --- a/tools/testing/selftests/net/forwarding/lib.sh
> +++ b/tools/testing/selftests/net/forwarding/lib.sh
> @@ -84,6 +84,11 @@ declare -A NETIFS=(
>  # e.g. a low-power board.
>  : "${KSFT_MACHINE_SLOW:=no}"
>  
> +if [[ "$(id -u)" -ne 0 ]]; then
> +	echo "SKIP: need root privileges"
> +	exit $ksft_skip
> +fi
> +

There's a small problem here. ksft_skip is defined in net/lib.sh which
hasn't yet been imported at this point.

Also, on my system at least, the code in the next patch can run
successfully as an unprivileged user. So what is this patch needed for
exactly?
Jiri Pirko April 19, 2024, 1:51 p.m. UTC | #3
Thu, Apr 18, 2024 at 08:48:20PM CEST, benjamin.poirier@gmail.com wrote:
>On 2024-04-18 18:08 +0200, Jiri Pirko wrote:
>> From: Jiri Pirko <jiri@nvidia.com>
>> 
>> This check can be done at the very beginning of the script.
>> As the follow up patch needs to add early code that needs to be executed
>> after the check, move it.
>> 
>> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
>> ---
>> v3->v4:
>> - removed NUM_NETIFS mode, rephrased the patch subject and description
>>   accordingly
>> ---
>>  tools/testing/selftests/net/forwarding/lib.sh | 10 +++++-----
>>  1 file changed, 5 insertions(+), 5 deletions(-)
>> 
>> diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
>> index 7913c6ee418d..b63a5866ce97 100644
>> --- a/tools/testing/selftests/net/forwarding/lib.sh
>> +++ b/tools/testing/selftests/net/forwarding/lib.sh
>> @@ -84,6 +84,11 @@ declare -A NETIFS=(
>>  # e.g. a low-power board.
>>  : "${KSFT_MACHINE_SLOW:=no}"
>>  
>> +if [[ "$(id -u)" -ne 0 ]]; then
>> +	echo "SKIP: need root privileges"
>> +	exit $ksft_skip
>> +fi
>> +
>
>There's a small problem here. ksft_skip is defined in net/lib.sh which
>hasn't yet been imported at this point.
>
>Also, on my system at least, the code in the next patch can run
>successfully as an unprivileged user. So what is this patch needed for
>exactly?

Okay, you are right. Will remove this patch.
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index 7913c6ee418d..b63a5866ce97 100644
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -84,6 +84,11 @@  declare -A NETIFS=(
 # e.g. a low-power board.
 : "${KSFT_MACHINE_SLOW:=no}"
 
+if [[ "$(id -u)" -ne 0 ]]; then
+	echo "SKIP: need root privileges"
+	exit $ksft_skip
+fi
+
 net_forwarding_dir=$(dirname "$(readlink -e "${BASH_SOURCE[0]}")")
 
 if [[ -f $net_forwarding_dir/forwarding.config ]]; then
@@ -241,11 +246,6 @@  check_port_mab_support()
 	fi
 }
 
-if [[ "$(id -u)" -ne 0 ]]; then
-	echo "SKIP: need root privileges"
-	exit $ksft_skip
-fi
-
 if [[ "$CHECK_TC" = "yes" ]]; then
 	check_tc_version
 fi